MCP-Gateway
MCPゲートウェイ
英語 |简体中文
ライセンス
このプロジェクトは、GNU General Public License v3.0 に基づいてライセンスされています。詳細については、 LICENSEファイルを参照してください。
Related MCP server: Maya MCP
プロジェクト概要
MCP GatewayはPythonで構築されたアプリケーションです。複数のバックエンドMCPサーバー(通信プロトコルがStdioまたはSSEのどちらであっても)に接続し、それらの機能を集約する中央ゲートウェイとして機能します。最終的には、これらの集約された機能を、統合されたSSEエンドポイント( /sse )を介して上流のMCPクライアントに公開します。
主な利点:
簡素化されたクライアント構成: MCP クライアントは、MCP ゲートウェイの単一のアドレスに接続するだけですべてのバックエンド サービスの機能にアクセスできるため、各バックエンド サーバーを個別に構成する必要がなくなります。
**機能の集約とオーケストレーション:**さまざまなソースからの多様な機能を備えた MCP ツールを集約し、特定のタスク ドメインに重点を置いた、より強力でカスタマイズされたエージェントを構築するための基盤を提供します。
プロジェクトファイルの構造
.
├── config.json # Core configuration file: Defines the backend MCP servers to connect to and manage.
├── main.py # Program entry point: Parses command-line arguments, sets up logging, and starts the web server.
├── bridge_app.py # Starlette application core: Handles forwarding of MCP requests and SSE connection management.
├── client_manager.py # Client manager: Responsible for establishing and maintaining connection sessions with backend MCP servers.
├── capability_registry.py # Capability registry: Dynamically discovers, registers, and manages capabilities provided by all backend MCP servers.
├── config_loader.py # Configuration loader: Responsible for loading and strictly validating the format and content of the `config.json` file.
├── errors.py # Custom exceptions: Defines project-specific error types, such as configuration errors and backend server errors.
├── rich_handler.py # Rich logging handler: Provides beautified, structured console log output.
├── servers/ # Contains built-in/example backend MCP server scripts.
│ ├── bash_server.py # <-- Built-in Bash command execution tool (Linux/macOS/WSL)
│ ├── cmd_server.py # <-- Built-in Windows CMD command execution tool (Windows Only)
│ ├── powershell_server.py # <-- Built-in Windows PowerShell command execution tool (Windows Only)
│ └── wmi_server.py # <-- Built-in Windows WMI query tool (Windows Only)
└── logs/ # Log directory: Stores runtime log files (created automatically).組み込みMCPサーバー
このプロジェクトには、追加の構成なしで直接使用し、 config.jsonで有効にできる 4 つのバックエンド MCP サーバー ツールが付属しています。
Bash コマンド実行ツール (
bash_server.py) : Linux、macOS、または WSL 環境で Bash コマンドを実行します。Windows CMD コマンド実行ツール (
cmd_server.py) : Windows 環境で CMD コマンドを実行します。Windows PowerShell コマンド実行ツール (
powershell_server.py) : Windows 環境で PowerShell コマンドを実行します。Windows WMI クエリ ツール (
wmi_server.py) : Windows 環境で WMI クエリを実行します。
Linux 環境で次のエラーが発生した場合:
error: Distribution `pywin32==310 @ registry+https://pypi.org/simple` can't be installed because it doesn't have a source distribution or wheel for the current platform>
wmiモジュールをアンインストールしてください:uv remove wmi
インストールとセットアップ
このプロジェクトはPythonで書かれています。環境と依存関係の管理にはuv使用をお勧めします。
クローンリポジトリ
git clone https://github.com/trtyr/MCP-Gateway.git cd MCP-Gateway仮想環境の作成と有効化
# Create virtual environment uv venv # Activate virtual environment # Linux/macOS source .venv/bin/activate # Windows (Command Prompt/PowerShell) .venv\Scripts\activate依存関係をインストールする
# Install all required dependencies based on pyproject.toml uv sync
これらの手順を完了すると、プロジェクトを実行する準備が整います。
クイックスタート
プロジェクトヘルプを取得する
使用可能なすべての起動オプションを表示するには、 -hまたは--help引数を使用できます。
# Windows
uv run python .\main.py -h
# Linux/macOS
uv run python ./main.py -h出力は次のようになります。
usage: main.py [-h] [--host HOST] [--port PORT] [--log-level {debug,info,warning,error,critical}]
Start MCP_Bridge_Server v3.0.0
options:
-h, --help show this help message and exit
--host HOST Host address (default: 0.0.0.0)
--port PORT Port (default: 9000)
--log-level {debug,info,warning,error,critical}
Set file logging level (default: info)プロジェクトを開始する
uv run python main.pyでサーバーを起動します。host、 host 、 log-level portできます。
# Listen on all network interfaces on port 9000, set log level to debug
uv run python .\main.py --host 0.0.0.0 --port 9000 --log-level debug起動すると、以下の画像のように、サーバーの状態、接続情報、読み込まれたツールを示す、美しく整えられたコンソール出力が表示されます。

MCPクライアント接続
MCP Gateway を起動した後、MCP 互換クライアント (Cline、Cursor、Claude Desktop、カスタム クライアントなど) を使用して、Gateway によって提供される SSE エンドポイントに接続できます。
デフォルトのアドレスはhttp://<Server_IP_Address>:9000/sse (デフォルト ポートを使用している場合) です。
例(ChatWise Connect を使用):
SSE接続タイプを選択します。ゲートウェイの SSE URL を入力します (例:
http://127.0.0.1:9000/sse)。Connectをクリックします。

接続が成功すると、ゲートウェイを介して集約されたすべてのバックエンド MCP ツールがクライアントに表示されます。

ログ
ランタイムログは、プロジェクトのルートディレクトリのlogsフォルダに自動的に保存されます。ログファイル名にはタイムスタンプとログレベルが含まれるため、問題を簡単に追跡できます。
logs/
├── log_20240801_103000_INFO.log
└── log_20240801_110000_DEBUG.log
...
設定ファイル ( config.json )
コア設定ファイルconfig.jsonプロジェクトのルートディレクトリにあります。このファイルには、MCP Gateway が接続して管理する必要があるバックエンド MCP サーバーが定義されています。
各エントリはバックエンドサーバーを表します。キーはバックエンドサーバーに割り当てた一意の名前(この名前はバックエンドサーバーの機能のプレフィックスとして使用されます)で、値はサーバーの設定を含むオブジェクトです。
次の 2 種類のバックエンド サーバー接続がサポートされています。
stdio: 標準入出力 (stdin/stdout) を介して、ローカルで開始された MCP サーバー プロセスと通信します。sse: Server-Sent Events (SSE) プロトコルを介して、リモートまたはローカルで実行されている MCP サーバーと通信します。
stdioタイプの設定
ライフサイクルをゲートウェイによって管理する必要があるローカル MCP サーバー プロセスに適しています。
構成フィールド:
type(必須):"stdio"である必要があります。command(必須): サーバープロセスを起動するために使用される実行可能コマンド (例:python、uv、node、またはスクリプト/実行可能ファイルへの絶対パス)。args(必須):commandに渡される引数のリスト (文字列のリスト)。env(オプション): 子プロセスに設定する環境変数の辞書 (Dict[str, str])。省略された場合、子プロセスはゲートウェイの環境を継承します。
例:
{
"powershell": {
"type": "stdio",
"command": "python",
"args": ["servers/powershell_server.py"]
},
"my_custom_tool": {
"type": "stdio",
"command": "/path/to/my/custom_mcp_server",
"args": ["--port", "ignored_for_stdio", "--some-flag"],
"env": {
"API_KEY": "your_secret_key"
}
}
}動作原理: MCPゲートウェイは起動時に、指定されたcommandとargs (およびオプションのenv )を使用して子プロセスを起動します。ゲートウェイは、この子プロセスの標準入出力を介してバックエンドのMCPサーバーと通信します。ゲートウェイがシャットダウンする際、これらの子プロセスを終了させようとします。
SSEタイプの構成
すでに実行中の MCP サーバー (ローカルまたはリモート) に接続する場合や、接続前にゲートウェイがローカル SSE サーバー プロセスを開始する必要がある場合に適しています。
構成フィールド:
type(必須):"sse"にする必要があります。url(必須): バックエンド MCP サーバーの SSE エンドポイント URL (完全な HTTP/HTTPS アドレス)。command(オプション): 指定すると、ゲートウェイは起動時にこのコマンドを実行してローカル SSE サーバーを起動します。args(オプション、commandが指定されている場合のみ):commandに渡される引数のリスト。env(オプション、commandが指定されている場合のみ): ローカルで起動された子プロセスに設定する環境変数。
例1: すでに実行中のリモートSSEサーバーに接続する
{
"remote_search_service": {
"type": "sse",
"url": "https://mcp.example.com/search/sse"
}
}例2: ゲートウェイはローカルSSEサーバーを起動し、接続します
{
"local_sse_server": {
"type": "sse",
"url": "http://127.0.0.1:8080/sse",
"command": "uv",
"args": ["run", "python", "servers/my_local_sse_app.py", "--port", "8080"],
"env": { "MODE": "production" }
}
}仕組み:
指定された
urlのみ: ゲートウェイは指定されたurlに直接接続しようとします。url、command、argsが指定されている場合:ゲートウェイはまずcommandとargsを使用してローカルプロセスを起動します(このプロセスはurlに対応するアドレスとポートをリッスンすると想定されます)。その後、urlへの接続を試行する前に、少しの間(client_manager.pyで定義されているLOCAL_SSE_STARTUP_DELAY)、待機します。ゲートウェイがシャットダウンすると、このローカルプロセスの終了が試行されます。
構成追加の例
サードパーティの MCP サーバーをconfig.jsonに追加する方法の例を次に示します。
Stdio の例: Playwright MCP
Playwright の MCP サーバー ( @playwright/mcp ) を統合するとします。
起動方法を理解する:Playwright MCPは通常、
npx @playwright/mcp@latestを使用して起動されます。これは、npxを介して実行されるNode.jsパッケージです。config.jsonを設定します:{ // ... other server configurations ... "playwright": { "type": "stdio", "command": "npx", "args": ["@playwright/mcp@latest"] } // ... other server configurations ... }ここで、
commandはnpxであり、argsは Playwright MCP パッケージの名前とバージョンが含まれます。ゲートウェイを再起動します
config.json保存し、MCP ゲートウェイを再起動します。
起動すると、コンソール ログとクライアントにplaywright/... (例: playwright/browse ) という名前のツールが表示されます。



SSE の例: ENScan_GO (ローカル開始)
./enscan --mcpで起動でき、 http://localhost:8080で SSE サービスを提供する Go プログラムである ENScan_GO を統合するとします。
実行可能ファイルを取得する: ENScan_GO 実行可能ファイル (例:
enscan-v1.2.1-windows-amd64.exe) をダウンロードし、アクセス可能な場所 (例:servers/ディレクトリまたはシステム PATH) に配置します。config.jsonを設定します:{ // ... other server configurations ... "enscan": { "type": "sse", "url": "http://127.0.0.1:8080/sse", // Address ENScan_GO listens on // Note: Ensure path separators are correct on Windows, or use an absolute path "command": "servers/enscan-v1.2.1-windows-amd64.exe", // Path to the executable "args": ["--mcp"] // Startup arguments } // ... other server configurations ... }ここでは、
type``sseとして指定し、リッスンするurlを提供し、commandとargsを使用して、このローカル SSE サーバーを起動する方法をゲートウェイに指示します。ゲートウェイを再起動します
config.json保存し、MCP ゲートウェイを再起動します。
ゲートウェイはまずENScan_GOプロセスを起動し、次にhttp://127.0.0.1:8080/sseに接続します。起動後、 enscan/...という名前のツールが表示されます。

Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
Related MCP Connectors
MCP Server for an Agent Task Marketplace
Self-hosted MCP gateway: turn any API, database or MCP server into AI connectors — no code.
Related MCP Servers
- MIT
- AlicenseNot gradedqualityDmaintenanceModel Context Protocol (MCP) server implementation for Autodesk Maya98MIT
- -
- AlicenseBqualityBmaintenanceMCP server that enables AI agents to perform comprehensive web audits using Google Lighthouse with 13+ tools for performance, accessibility, SEO, and security analysis.111,18667MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/trtyr/MCP-Gateway'
If you have feedback or need assistance with the MCP directory API, please join our Discord server