Skip to main content
Glama
ChatGPT Orchestrator MCP Server

ChatGPT Orchestrator MCP Server

by vadimsey

ChatGPT Orchestrator MCP Server

以下のスキームのためのPythonによる最小限のremote MCP server:

ChatGPT -> MCP server -> main orchestrator -> helper agents

第一段階として、サーバーには1つのツールが含まれています:

  • run_orchestrator

  • 入力: goal: string

  • 出力: シンプルなJSON

内部には現在スタブが配置されています。後ほど、実際のメインエージェントの呼び出しに置き換えることができます。

なぜFastMCPなのか

FastMCPが選ばれた理由は、MCPツールを通常のPython関数として記述し、HTTP経由でremote MCP endpointを即座に起動できるためです。ChatGPTに接続するには、/mcp のようなパブリックなHTTPS endpointが必要です。

Related MCP server: native-agent-router

プロジェクト構造

.
├── .gitignore
├── server.py
├── requirements.txt
├── Procfile
├── render.yaml
└── README.md

ローカルでの起動

要件:

  • Python 3.11+

  • pip

1. 仮想環境の作成

PowerShell:

python -m venv .venv
.\.venv\Scripts\Activate.ps1

Windowsで python コマンドがMicrosoft Storeを開くか、バージョンを表示しない場合は以下を使用してください:

py -3.11 -m venv .venv
.\.venv\Scripts\Activate.ps1

macOS/Linux:

python3 -m venv .venv
source .venv/bin/activate

2. 依存関係のインストール

pip install -r requirements.txt

3. サーバーの起動

python server.py

ローカルのMCP endpoint:

http://localhost:8000/mcp

サーバーが稼働しているかの通常の確認:

http://localhost:8000/health

クライアントが末尾にスラッシュ付きのendpointを要求する場合は、以下を使用してください:

http://localhost:8000/mcp/

ローカルでの検証

python server.py を実行したままにします。2つ目のターミナルで以下を実行します:

Invoke-RestMethod http://localhost:8000/health

期待される応答:

{
  "status": "ok"
}

重要: ブラウザで http://localhost:8000/mcp を開いたり、MCPヘッダーなしで通常の curl を実行したりすると、エラーが表示されることがあります:

{
  "error": {
    "message": "Not Acceptable: Client must accept text/event-stream"
  }
}

これはMCP endpointとしては正常です。/health は通常のブラウザで確認し、/mcp はMCPクライアントで確認してください。

@'
import asyncio
from fastmcp import Client

async def main():
    async with Client("http://localhost:8000/mcp") as client:
        tools = await client.list_tools()
        print("TOOLS:")
        for tool in tools:
            print("-", tool.name)

        result = await client.call_tool(
            "run_orchestrator",
            {"goal": "Create an MVP launch plan"}
        )
        print("RESULT:")
        print(result)

asyncio.run(main())
'@ | python

期待される応答の意味: サーバーは run_orchestrator ツールを表示し、スタブがタスクを受け取ったというテキストを含むJSONを返します。

MCP Inspector経由でも確認できます:

npx @modelcontextprotocol/inspector

UIで transport に Streamable HTTP を選択し、URLを入力します:

http://localhost:8000/mcp

Renderへのデプロイ

GitHub経由のオプション

  1. 新しいGitHubリポジトリを作成します。

  2. これらのファイルをそこにアップロードします。

  3. Renderを開きます。

  4. New -> Web Service をクリックします。

  5. GitHubリポジトリを接続します。

  6. Renderは通常、自動的に render.yaml を読み取ります。

  7. 手動で設定する場合:

    • Runtime: Python

    • Build Command: pip install -r requirements.txt

    • Start Command: python server.py

  8. Deploy をクリックします。

デプロイ後、Renderは以下のようなURLを発行します:

https://chatgpt-orchestrator-mcp.onrender.com

Production MCP endpointは以下のようになります:

https://chatgpt-orchestrator-mcp.onrender.com/mcp

ブラウザで確認するためのProduction health endpoint:

https://chatgpt-orchestrator-mcp.onrender.com/health

このURLをChatGPTに入力する必要があります。

ChatGPTへの接続方法

  1. ブラウザでChatGPTを開きます。

  2. Settings に移動します。

  3. Apps & Connectors または Connectors を開きます。

  4. Developer Modeがオフの場合は有効にします:

    • Advanced settings

    • Developer mode

  5. Create または Create connector をクリックします。

  6. 以下を入力します:

    • Name: Orchestrator

    • Description: Runs my main orchestrator agent through MCP.

    • Connector URL: https://YOUR-RENDER-SERVICE.onrender.com/mcp

  7. 保存します。

  8. 新しいチャットでこのコネクタ/ツールを選択し、ChatGPTにオーケストレーターを呼び出すよう依頼します。

ChatGPTでのテストリクエスト例

Используй Orchestrator и вызови run_orchestrator с goal:
"Составь пошаговый план запуска MVP моего продукта"

ツールからの期待される応答は現在以下のようになります:

{
  "status": "ok",
  "message": "Stub orchestrator accepted the goal.",
  "goal": "Составь пошаговый план запуска MVP моего продукта",
  "next_step": "Replace call_real_orchestrator() in server.py with your real agent call."
}

スタブを実際のエージェントに置き換える場所

server.py を開き、以下の関数を探します:

def call_real_orchestrator(goal: str) -> dict[str, Any]:

現在はテスト用のJSONを返しています。後ほど、その本体を実際のメインエージェントの呼び出しに置き換えてください。

将来の置き換え例:

def call_real_orchestrator(goal: str) -> dict[str, Any]:
    result = my_main_agent.run(goal)
    return {
        "status": "ok",
        "goal": goal,
        "result": result,
    }

重要: 第一段階では、各サブエージェントごとに個別のMCPサーバーを作成しないでください。ChatGPTには run_orchestrator という1つのツールのみを見せ、内部のメインエージェントがどのサブエージェントを呼び出すかを判断するようにしてください。

最終的なURL

ローカル:

http://localhost:8000/mcp

Production URLテンプレート:

https://YOUR-RENDER-SERVICE.onrender.com/mcp

ChatGPT用URL:

https://YOUR-RENDER-SERVICE.onrender.com/mcp

役立つ公式ドキュメント

Related MCP Connectors

Related MCP Servers