Swiss Army Knife for MCP Servers について
Swiss Army Knife for MCP Servers(MCP Tools)は、stdio と HTTP トランスポートで MCP サーバーとやり取りするためのコマンドラインツールです。ツール、リソース、プロンプトの検出と呼び出しに加え、モックとプロキシの機能を備えており、MCP サーバーやクライアントを開発・デバッグする開発者に適しています。
主な機能
- 01ツール、リソース、プロンプトの一覧表示と呼び出し
- 02stdio、HTTP SSE、Streamable HTTP への対応
- 03表形式、コンパクト JSON、整形 JSON の出力
- 04対話型のコマンドラインシェル
- 05ブラウザーで操作する Web インターフェース
活用シーン
- 01MCP サーバーが提供するツールのコマンドラインでの確認
- 02スクリプトからの MCP ツール呼び出しと JSON 出力の処理
- 03MCP サーバーの応答のデバッグとテスト
MCP 対応
MCP 互換の任意のサーバーに接続し、そのツール、リソース、プロンプトを呼び出すコマンドラインクライアントです。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-serverGITHUB_PERSONAL_ACCESS_TOKENシークレットローカルサーバーにはマシン上の実行環境(Node.js 18 以上など)が必要です。設定ファイルの場所はクライアントごとに異なります。
ghcr.io/github/github-mcp-serverstdioツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
MCP サーバーのスイスアーミーナイフ
MCP(Model Context Protocol)サーバーとやり取りするための包括的なコマンドラインインターフェースです。
MCP 互換サーバーからツール、リソース、プロンプトを検出、呼び出し、管理できます。
複数のトランスポート方式と出力形式に対応し、強力なモックサーバーおよびプロキシサーバー機能も備えています。
目次
- 概要
- MCP Inspector と MCP Tools の違い
- インストール
- はじめに
- 機能
- サーバーエイリアス
- LLM アプリの設定管理
- サーバーモード
- 例
- コントリビューション
- ロードマップ
- ライセンス
概要
MCP Tools は、Model Context Protocol(MCP)サーバーを操作するための多用途な CLI を提供します。次のことができます。
- MCP サーバーが提供するツールを検出して呼び出す
- MCP サーバーが公開するリソースにアクセスして利用する
- クライアントアプリケーションのテスト用にモックサーバーを作成する
- MCP リクエストをシェルスクリプトにプロキシし、簡単に拡張できるようにする
- MCP サーバーを探索、利用するためのインタラクティブシェルを作成する
- TypeScript に対応した新しい MCP プロジェクトのひな形を作成する
- さまざまな形式(JSON、整形表示、テーブル)で出力する
- 特定のツールやリソースへのアクセスを保護、制限する
- すべてのトランスポート方式(HTTP、stdio)に対応する
インストール
Homebrew を使用する(macOS 向け)
brew tap f/mcptools
brew install mcp
❕ バイナリは
mcpとしてインストールされますが、mcpコマンド名を使用するほかのツールとの競合を避けるため、mcptとしても利用できます。
ソースから(Windows および GNU/Linux 向け)
go install github.com/f/mcptools/cmd/mcptools@latest
❕ バイナリは
mcptoolsとしてインストールされますが、使いやすいようにmcptというエイリアスを設定できます。![]()
Windows 11 での実行例
はじめに
MCP Tools を使い始める最も簡単な方法は、MCP サーバーに接続して、利用可能なツールを一覧表示することです。
# List all available tools from a filesystem server
mcp tools npx -y @modelcontextprotocol/server-filesystem ~
# Call a specific tool
mcp call read_file --params '{"path":"README.md"}' npx -y @modelcontextprotocol/server-filesystem ~
# Open an interactive shell
mcp shell npx -y @modelcontextprotocol/server-filesystem ~
機能
MCP Tools は、MCP サーバーとやり取りするための幅広い機能に対応しています。
Usage:
mcp [command]
Available Commands:
version Print the version information
tools List available tools on the MCP server
resources List available resources on the MCP server
prompts List available prompts on the MCP server
call Call a tool, resource, or prompt on the MCP server
get-prompt Get a prompt on the MCP server
read-resource Read a resource on the MCP server
shell Start an interactive shell for MCP commands
web Start a web interface for MCP commands
mock Create a mock MCP server with tools, prompts, and resources
proxy Proxy MCP tool requests to shell scripts
alias Manage MCP server aliases
configs Manage MCP server configurations
new Create a new MCP project component
help Help about any command
completion Generate the autocompletion script for the specified shell
Flags:
-f, --format string Output format (table, json, pretty) (default "table")
-h, --help help for mcp
-p, --params string JSON string of parameters to pass to the tool (for call command) (default "{}")
Use "mcp [command] --help" for more information about a command.
トランスポートオプション
MCP Tools は、MCP サーバーとの通信に複数のトランスポート方式をサポートしています。
Stdio トランスポート
stdin/stdout を使用して、JSON-RPC 2.0 経由で MCP サーバーと通信します。MCP プロトコルを実装するコマンドラインツールに便利です。
mcp tools npx -y @modelcontextprotocol/server-filesystem ~
HTTP SSE トランスポート
HTTP と Server-Sent Events(SSE)を使用して、JSON-RPC 2.0 経由で MCP サーバーと通信します。レガシー MCP プロトコルを実装するリモートサーバーへの接続に便利です。URL が /sse で終わる場合、トランスポートは自動的に検出されます。
mcp tools http://localhost:3001/sse
# Example: Use the everything sample server
# docker run -p 3001:3001 --rm -it tzolov/mcp-everything-server:v1
注: HTTP SSE が現在サポートしているのは、MCP プロトコルバージョン 2024-11-05 のみです。
Streamable HTTP トランスポート(推奨)
JSON-RPC 2.0 を使用し、ストリーム可能な HTTP で MCP サーバーと通信します。これは、MCP プロトコルを実装したリモートサーバーへの接続に推奨される最新の方法です。ストリーミング応答とシンプルなリクエスト/レスポンスの両方に対応しています。HTTP/HTTPS URL のデフォルトのトランスポートです。
# Default transport for HTTP URLs
mcp tools http://localhost:3000
# Streamable HTTP transport (auto-detected from URL)
mcp tools http://localhost:3000
# Examples with remote servers
mcp tools https://api.example.com/mcp
mcp tools https://ne.tools
ストリーム可能な HTTP のメリット:
- セッション管理:セッション ID を使用したステートフルな接続に対応しています
- 再開可能性:中断したセッションに再接続して再開できます(サーバーが対応している場合)
- 柔軟な応答:ストリーミング応答と直接的な JSON 応答の両方に対応しています
- 最新のプロトコル:最新の MCP トランスポート仕様を使用します
出力形式
MCP Tools は、さまざまなニーズに対応する 3 つの出力形式をサポートしています。
テーブル形式(デフォルト)
mcp tools npx -y @modelcontextprotocol/server-filesystem ~
デフォルト形式では、ツールが色付きのマニュアルページ形式で表示されます。
read_file(path:str)
Read the complete contents of a file from the file system.
read_multiple_files(paths:str[])
Read the contents of multiple files simultaneously.
list_dir(path:str)
Lists the contents of a directory.
write_file(path:str, content:str)
Writes content to a file.
grep_search(pattern:str, [excludePatterns:str[]])
Search files with pattern.
edit_file(edits:{newText:str,oldText:str}[], path:str)
Edit a file with multiple text replacements
この形式の主な特徴:
- 関数名はシアンの太字で表示されます
- 必須パラメーターは緑色で表示されます(例:
path:str) - オプションのパラメーターは黄色の角括弧で表示されます(例:[limit:int])
- 配列型は
[]の接尾辞で示されます(例:str[]) - オブジェクト型は波括弧内にプロパティを表示します(例:
{prop1:type1,prop2:type2}) - ネストされたオブジェクトは再帰的に表示されます(例:
{notifications:{enabled:bool,sound:bool}}) - 型名は読みやすいように短縮されます(例:
stringの代わりにstr、integerの代わりにint) - 説明はインデントされ、灰色で表示されます
- パラメーターの順序は一貫しており、必須パラメーターが先に表示されます
JSON 形式(コンパクト)
mcp tools --format json npx -y @modelcontextprotocol/server-filesystem ~
整形済み JSON 形式(インデント付き)
mcp tools --format pretty npx -y @modelcontextprotocol/server-filesystem ~
コマンド
MCP Tools には、MCP サーバーとやり取りするためのいくつかの主要なコマンドが用意されています。
利用可能なツールの一覧表示
mcp tools npx -y @modelcontextprotocol/server-filesystem ~
利用可能なリソースの一覧表示
mcp resources npx -y @modelcontextprotocol/server-filesystem ~
利用可能なプロンプトの一覧表示
mcp prompts npx -y @modelcontextprotocol/server-filesystem ~
ツールの呼び出し
mcp call read_file --params '{"path":"/path/to/file"}' npx -y @modelcontextprotocol/server-filesystem ~
リソースの呼び出し
mcp call resource:test://static/resource/1 npx -y @modelcontextprotocol/server-everything -f json | jq ".contents[0].text"
または
mcp read-resource test://static/resource/1 npx -y @modelcontextprotocol/server-everything -f json | jq ".contents[0].text"
プロンプトの呼び出し
mcp get-prompt simple_prompt npx -y @modelcontextprotocol/server-everything -f json | jq ".messages[0].content.text"
サーバーログの表示
サーバーを呼び出すクライアントコマンドを使用する際に、--server-logs フラグを追加すると、リクエストに関連するサーバーログを確認できます。
# View server logs when listing tools
mcp tools --server-logs npx -y @modelcontextprotocol/server-filesystem ~
出力:
[>] Secure MCP Filesystem Server running on stdio
[>] Allowed directories: [ '/Users/fka/' ]
read_file(path:str)
Read the complete contents of a file from the file system.
read_multiple_files(paths:str[])
Read the contents of multiple files simultaneously.
... and the other tools available on this server
これらのコマンドの実行時にサーバー側で何が起きているかを把握したり、デバッグしたりする際に役立ちます。
対話型シェル
対話型シェルモードを使用すると、1 つのセッション内で複数の MCP コマンドを実行できます。
mcp shell npx -y @modelcontextprotocol/server-filesystem ~
対話型シェルを開くと、次の機能を利用できます。
mcp tools shell
connected to: npx -y @modelcontextprotocol/server-filesystem /Users/fka
mcp > Type '/h' for help or '/q' to quit
mcp > tools
read_file(path:str, [limit:int], [offset:int])
Reads a file from the filesystem
list_dir(path:str)
Lists directory contents
grep_search(pattern:str, [excludePatterns:str[]])
Search files with pattern
edit_file(edits:{newText:str,oldText:str}[], path:str)
Edit a file with multiple text replacements
# Direct tool calling is supported
mcp > read_file {"path":"README.md"}
...content of README.md...
# Calling a tool with complex object parameters
mcp > edit_file {"path":"main.go","edits":[{"oldText":"foo","newText":"bar"}]}
...result of edit operation...
# Get help
mcp > /h
MCP Shell Commands:
tools List available tools
resources List available resources
prompts List available prompts
call <entity> [--params '{...}'] Call a tool, resource, or prompt
format [json|pretty|table] Get or set output format
Special Commands:
/h, /help Show this help
/q, /quit, exit Exit the shell
Web インターフェース
MCP Tools は、ブラウザーベースの UI を通じて MCP サーバーとやり取りするための Web インターフェースを提供します。
# Start a web interface for a filesystem server on default port (41999)
mcp web npx -y @modelcontextprotocol/server-filesystem ~
# Use a custom port
mcp web --port 8080 docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
# Use SSE
mcp web https://ne.tools
Web インターフェースには、次の機能があります。
- 利用可能なすべてのツール、リソース、プロンプトを一覧表示するサイドバー
- フォームベースおよび JSON ベースのパラメーター編集
- 整形済みおよび生の JSON 応答の表示
- ツールスキーマから自動生成される対話型パラメーターフォーム
- 複雑なパラメーター型(配列、オブジェクト、ネストされた構造)のサポート
- ツール呼び出しのための直接的な API アクセス
起動後、ブラウザーで http://localhost:41999(またはカスタムポート)を開くと、インターフェースにアクセスできます。
MCP Tools は、TypeScript で新しい MCP サーバーをすばやく作成するためのスキャフォールディング機能を提供します:
mkdir my-mcp-server
cd my-mcp-server
# Create a project with specific components
mcp new tool:calculate resource:file prompt:greet
# Create a project with a specific SDK (currently only TypeScript/ts supported)
mcp new tool:calculate --sdk=ts
# Create a project with a specific transport type
mcp new tool:calculate --transport=stdio
mcp new tool:calculate --transport=sse
スキャフォールディングは、以下を含む完全なプロジェクト構造を作成します:
- 選択したトランスポート(stdio または SSE)を使用したサーバーセットアップ
- モダンな ES モジュールを使用した TypeScript 設定
- 適切な MCP インターフェースを備えたコンポーネントの実装
- インポートと初期化の自動配線
スキャフォールディング後、MCP サーバーをビルドして実行できます:
# Install dependencies
npm install
# Build the TypeScript code
npm run build
# Test the server with MCP Tools
mcp tools node build/index.js
プロジェクトテンプレートは以下のいずれかに保存されます:
- ローカルの
./templates/ディレクトリ - ユーザーのホームディレクトリ:
~/.mcpt/templates/ - Homebrew のインストールパス(
/opt/homebrew/Cellar/mcp/v#.#.#/templates)
Homebrew 経由でインストールする場合、テンプレートは自動的にホームディレクトリにインストールされます。ただし、ソースインストールを使用する場合は、make install-templates を実行する必要があります。
サーバーエイリアス
MCP Tools では、サーバーコマンドをわかりやすいエイリアスで保存して再利用できます:
# Add a new server alias
mcp alias add myfs npx -y @modelcontextprotocol/server-filesystem ~/
# List all registered server aliases
mcp alias list
# Remove a server alias
mcp alias remove myfs
# Use an alias with any MCP command
mcp tools myfs
mcp call read_file --params '{"path":"README.md"}' myfs
サーバーエイリアスは $HOME/.mcpt/aliases.json に保存され、よく使用する MCP サーバーを長いコマンドを何度も入力することなく便利に扱う方法を提供します。
LLM アプリの設定管理
MCP Tools は、複数のアプリケーションにまたがる MCP サーバー設定を扱うための強力な設定管理システムを提供します:
🚧 これは現時点では macOS でのみ動作します。
# Scan for MCP server configurations across all supported applications
mcp configs scan
# List all configurations (alias for configs view --all)
mcp configs ls
# View specific configuration by alias
mcp configs view vscode
# Add or update a server in a configuration
mcp configs set vscode my-server npm run mcp-server
mcp configs set cursor my-api https://api.example.com/mcp --headers "Authorization=Bearer token"
# Add to multiple configurations at once
mcp configs set vscode,cursor,claude-desktop my-server npm run mcp-server
# Remove a server from a configuration
mcp configs remove vscode my-server
# Create an alias for a custom config file
mcp configs alias myapp ~/myapp/config.json
# Synchronize and merge configurations from multiple sources
mcp configs sync vscode cursor --output vscode --default interactive
# Convert a command line to MCP server JSON configuration format
mcp configs as-json mcp proxy start
# Output: {"command":"mcp","args":["proxy","start"]}
# Convert a URL to MCP server JSON configuration format
mcp configs as-json https://api.example.com/mcp --headers "Authorization=Bearer token"
# Output: {"url":"https://api.example.com/mcp","headers":{"Authorization":"Bearer token"}}
設定は $HOME/.mcpt/configs.json の中央レジストリを通じて管理され、以下の定義済みエイリアスがあります:
- VS Code および VS Code Insiders
- Windsurf
- Cursor
- Claude Desktop および Claude Code
このシステムは、サーバー設定をソースごとにグループ化した色付きの形式で自動的に表示し、コマンドラインまたは URL 情報、ヘッダー、環境変数を示します。
mcp configs scan コマンドは、以下の場所で MCP サーバー設定を探します:
- Visual Studio Code
- Visual Studio Code Insiders
- Windsurf
- Cursor
- Claude Desktop
出力例:
VS Code Insiders
GitHub (stdio):
docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
Claude Desktop
Proxy (stdio):
mcp proxy start
My Files (stdio):
npx -y @modelcontextprotocol/server-filesystem ~/
おまけ
公式の GitHub MCP Server を Windsurf、Cursor、VS Code に一度に追加します:
mcp configs set windsurf,cursor,vscode GitHub \
--env "GITHUB_PERSONAL_ACCESS_TOKEN=github_pat_xxx" \
docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
サーバーモード
MCP Tools はクライアントとサーバーの両方として動作でき、2 つのサーバーモードが利用可能です:
モックサーバーモード
モックサーバーモードは、完全なサーバーを実装することなくクライアントをテストするための、シミュレートされた MCP サーバーを作成します:
# Create a mock server with a simple tool
mcp mock tool hello_world "A simple greeting tool"
# Create a mock server with multiple entity types
mcp mock tool hello_world "A greeting tool" \
prompt welcome "A welcome prompt" "Hello {{name}}, welcome to {{location}}!" \
resource docs://readme "Documentation" "Mock MCP Server\nThis is a mock server"
モックサーバーの機能:
- 完全な初期化ハンドシェイク
- 標準化されたスキーマによるツール一覧
- シンプルな応答によるツール呼び出し
- リソースの一覧表示と読み取り
- 引数の置換を伴うプロンプトの一覧表示と取得
~/.mcpt/logs/mock.logへの詳細なリクエスト/レスポンスのログ記録
プロンプトテンプレートの使用
プロンプトの場合、{{二重中括弧}} 内の任意のテキストが自動的に引数として検出されます:
# Create a prompt with name and location arguments
mcp mock prompt greeting "Greeting template" "Hello {{name}}! Welcome to {{location}}."
クライアントがプロンプトを要求すると、これらの引数に値を提供でき、その値がレスポンス内で置換されます。
プロキシモード
プロキシモードでは、シェルスクリプトやインラインコマンドを MCP ツールとして登録できるため、コードを書かずに MCP の機能を簡単に拡張できます:
# Register a shell script as an MCP tool
mcp proxy tool add_operation "Adds a and b" "a:int,b:int" ./examples/add.sh
# Register an inline command as an MCP tool
mcp proxy tool add_operation "Adds a and b" "a:int,b:int" -e 'echo "total is $a + $b = $(($a+$b))"'
# Register an inline command as an MCP tool with optional parameter
mcpt proxy tool add_operation "Adds a and b with optional result msg" "a:int,b:int,[msg:string]" -e 'echo "$msg$a + $b = $(($a+$b))"'
# Unregister a tool
mcp proxy tool --unregister add_operation
# Start the proxy server
mcp proxy start
プロキシサーバーで mcp tools localhost:3000 を実行すると、登録されたツールとそのパラメータが表示されます:
add_operation(a:int, b:int)
Adds a and b
count_files(dir:str, [include:str[]])
Counts files in a directory with optional filters
この新しい形式では、各ツールがどのパラメータを受け付けるかが明確に示され、使用方法を理解しやすくなっています。配列は [] サフィックスで示され(例:str[])、型名は読みやすさのために短縮されています。
仕組み
- ツール名、説明、パラメータ指定を伴うシェルスクリプトまたはインラインコマンドを登録します
- MCP プロトコルを実装するプロキシサーバーを起動します
- ツールが呼び出されると、パラメータが環境変数としてスクリプト/コマンドに渡されます
- スクリプト/コマンドの出力がツールのレスポンスとして返されます
- スクリプトの出力が base64 エンコードされた PNG 画像(
data:image/png;base64,がプレフィックスとして付く)の場合、ImageContent オブジェクトとして返されます。
スクリプトとコマンドの例
数値の加算(add.sh):
#!/bin/bash
# Get values from environment variables
if [ -z "$a" ] || [ -z "$b" ]; then
echo "Error: Missing required parameters 'a' or 'b'"
exit 1
fi
# Perform the addition
result=$(($a + $b))
echo "The sum of $a and $b is $result"
QR コードの生成
この例では、qrencode のようなツールをインストールする必要があります。
# Register a tool to generate a QR code
mcp proxy tool qrcode "Generates a QR code" "text:string" \
-e 'echo -e "data:image/png;base64,$(qrencode -t png -o - "$text" | base64 -w 0)"'
インラインコマンドの例:
# Simple addition
mcp proxy tool add_op "Adds given numbers" "a:int,b:int" -e 'echo "total is $a + $b = $(($a+$b))"'
# Customized greeting
mcp proxy tool greet "Greets a user" "name:string,greeting:string,formal:bool" -e '
if [ "$formal" = "true" ]; then
title="Mr./Ms."
echo "${greeting:-Hello}, ${title} ${name}. How may I assist you today?"
else
echo "${greeting:-Hello}, ${name}! Nice to meet you!"
fi
'
# File operations
mcp proxy tool count_lines "Counts lines in a file" "file:string" -e "wc -l < \"$file\""
設定とログ
- ツールは
~/.mcpt/proxy_config.jsonに登録されます - プロキシサーバーはすべてのリクエストとレスポンスを
~/.mcpt/logs/proxy.logに記録します --unregisterを使用すると、設定からツールを削除できます
ガードモード
ガードモードでは、パターンマッチングに基づいて、特定のツール、プロンプト、リソースへのアクセスを制限できます。次のようなセキュリティ目的で役立ちます。
- 危険性のある操作(ファイルの書き込み、削除など)を制限する
- AI アシスタントやアプリケーションの機能を制限する
- 機密システムへの読み取り専用アクセスを提供する
- テストやデモ用のサンドボックス環境を作成する
Note: ガードモードは現在、STDIO トランスポート(コマンド実行)でのみ動作し、HTTP トランスポートでは動作しません。
# Allow only file reading operations, deny file modifications
mcp guard --allow 'tools:read_* --deny tools:write_*,create_*,delete_*' npx -y @modelcontextprotocol/server-filesystem ~
# Permit only a single specific tool
mcp guard --allow 'tools:search_files' npx -y @modelcontextprotocol/server-filesystem ~
# Restrict by both tool type and prompt type
mcp guard --allow 'tools:read_*,prompts:system_*' --deny tools:execute_* npx -y @modelcontextprotocol/server-filesystem ~
# Using with aliases
mcp guard --allow 'tools:read_*' fs # Where 'fs' is an alias for a filesystem server
動作の仕組み
ガードコマンドは、次のように動作します。
- クライアントと MCP サーバーの間に配置されるプロキシを作成します
tools/list、prompts/list、resources/listへのすべてのリクエストを傍受してフィルタリングします- 許可されたパターンに一致しないツール、プロンプト、リソースの呼び出しを防ぎます
- フィルタリングされたリソース、ツール、プロンプトへのリクエストをブロックします
- その他すべてのリクエストとレスポンスは変更せずに通過させます
パターンマッチング
パターンでは、ワイルドカードとして * を使うシンプルな glob 構文を使用します。
tools:read_*- "read_" で始まるすべてのツールに一致しますtools:*file*- 名前に "file" を含むすべてのツールに一致しますprompts:system_*- "system_" で始まるすべてのプロンプトに一致します
エンティティの種類ごとに、次を指定できます。
--allow 'pattern1,pattern2,...'- これらのパターンに一致するエンティティのみを許可します--deny 'pattern1,pattern2,...'- これらのパターンに一致するエンティティを除外します
許可パターンが指定されていない場合、拒否パターンに一致するものを除き、すべてのエンティティがデフォルトで許可されます。
アプリケーションとの統合
ガードコマンドを使用して、アプリケーション内の MCP 設定を保護できます。たとえば、ファイルシステムサーバーで読み取り操作のみを許可するには、次の設定を変更します。
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/fka/Desktop"
]
}
次のようにします。
"filesystem": {
"command": "mcp",
"args": [
"guard", "--deny", "tools:write_*,create_*,move_*,delete_*",
"npx", "-y", "@modelcontextprotocol/server-filesystem",
"/Users/fka/Desktop"
]
}
これにより、変更操作を防いでファイルシステムの読み取り専用ビューを提供します。
設定では、ガードコマンドとエイリアスを組み合わせて使うこともできます。
"filesystem": {
"command": "mcp",
"args": [
"guard", "--allow", "tools:read_*,list_*,search_*",
"fs" // Where 'fs' is an alias for the filesystem server
]
}
これにより、設定をさらに簡潔にし、保守しやすくできます。
ログ記録
- ガード操作は
~/.mcpt/logs/guard.logに記録されます - ログにはすべてのリクエスト、レスポンス、フィルタリングの判断が含まれます
tail -f ~/.mcpt/logs/guard.logを使用すると、リアルタイムで動作を監視できます
例
基本的な使い方
ファイルシステムサーバーのツールを一覧表示します。
mcp tools npx -y @modelcontextprotocol/server-filesystem ~
整形済みの JSON 出力でツールを呼び出します。
mcp call read_file --params '{"path":"README.md"}' --format pretty npx -y @modelcontextprotocol/server-filesystem ~
ガードモードを使用して、利用可能なツールをフィルタリングします。
# Only allow file search functionality
mcp guard --allow tools:search_files npx -y @modelcontextprotocol/server-filesystem ~
# Create a read-only environment
mcp guard --deny tools:write_*,delete_*,create_*,move_* npx -y @modelcontextprotocol/server-filesystem ~
ストリーミング可能な HTTP の使用方法
ローカルのストリーミング可能な HTTP サーバーを作成して実行します。
# Create a new MCP server with SSE transport (streamable HTTP not available in scaffolding)
mkdir my-sse-server && cd my-sse-server
mcp new tool:example_tool --transport=sse
# Install dependencies and build
npm install && npm run build
# Start the server (will run SSE transport)
npm start
別のターミナルで、ローカルサーバーに接続します。
# Connect to local SSE server (adjust URL based on your server's SSE endpoint)
mcp tools http://localhost:3000/sse
# Call a tool on the local server
mcp call example_tool --params '{"input": "test"}' http://localhost:3000/sse
# Use with different output formats
mcp tools --format pretty http://localhost:3000/sse
リモートのストリーミング可能な HTTP サーバーに接続します。
# Connect to a remote MCP server
mcp tools https://api.example.com/mcp
# Use SSE transport for legacy servers (auto-detected from /sse path)
mcp tools http://legacy-server.com/sse
# Example with authentication headers (when supported)
mcp tools https://authenticated-mcp-server.com
スクリプトとの統合
シンプルなシェルスクリプトでプロキシモードを使用します。
# 1. Create a simple shell script for addition
cat > add.sh << 'EOF'
#!/bin/bash
# Get values from environment variables
if [ -z "$a" ] || [ -z "$b" ]; then
echo "Error: Missing required parameters 'a' or 'b'"
exit 1
fi
result=$(($a + $b))
echo "The sum of $a and $b is $result"
EOF
# 2. Make it executable
chmod +x add.sh
# 3. Register it as an MCP tool
mcp proxy tool add_numbers "Adds two numbers" "a:int,b:int" ./add.sh
# 4. In one terminal, start the proxy server
mcp proxy start
# 5. In another terminal, you can call it as an MCP tool
mcp call add_numbers --params '{"a":5,"b":3}' --format pretty
デバッグ
プロキシまたはモックサーバーをデバッグするため、ログを監視します。
# For the mock server logs
tail -f ~/.mcpt/logs/mock.log
# For the proxy server logs
tail -f ~/.mcpt/logs/proxy.log
# To watch all logs in real-time (on macOS/Linux)
find ~/.mcpt/logs -name "*.log" -exec tail -f {} \;
貢献
皆さまからの貢献を歓迎します。プルリクエストの送信、問題の報告、プロジェクトへの貢献方法については、貢献ガイドラインをご覧ください。
ロードマップ
今後のリリースでは、以下の機能を予定しています。
- 認証:安全な認証メカニズムのサポート
ライセンス
このプロジェクトは MIT License の下でライセンスされています。
謝辞
ロゴをデザインしてくださった Fatih Taskiran に感謝します。
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。