Skip to main content
Glama
scottlz0310

mcp-resource-subscribe-test

by scottlz0310

mcp-resource-subscribe-test

MCPクライアントが resources/subscribe および notifications/resources/updated を正しく処理できるかをテストするための、最小限のMCP Streamable HTTPサーバーです。

このリポジトリは、Codex CLI、Gemini CLI、OpenCode、GitHub Copilot CLI、Claude Code、Goose、CrushなどのCLI AIエージェントにおける再現可能な問題報告や互換性検証のためのラボとして機能します。

目的

このサーバーは、1つの固定されたMCPリソースを公開します:

test://review/status

初期コンテンツ:

status: pending
version: 1
message: Waiting for simulated review result.

クライアントがリソースを購読した後、サーバーは MCP_TEST_UPDATE_DELAY_SECONDS だけ待機し、リソースを変更して以下を送信します:

{
  "method": "notifications/resources/updated",
  "params": {
    "uri": "test://review/status"
  }
}

更新後のコンテンツ:

status: reviewed
version: 2
message: Simulated review result is now available.

Related MCP server: SkyStage MCP Test Server

なぜ tools/call ではなく resources/subscribe なのか

tools/call は明示的なアクションには有用ですが、多くのエージェントワークフローは、元のリクエスト後に変化するコンテキストに依存しています。すべてのソースをポーリングするのはノイズが多く、クライアント固有の処理が必要です。MCPリソースの購読機能は、既知のコンテキストオブジェクトが変更され、再読み込みが必要であることをクライアントが知るためのプロトコルレベルの方法を提供します。

購読の動作が重要となる例:

  • Copilotのレビュー結果

  • PRレビューのスレッド

  • CIステータス

  • Codecovのコメント

  • GitHubのIssue議論

  • ローカルのビルド/テスト結果

このテストサーバーは、クライアントがリソースの更新に気づき、resources/read を再実行し、新しいコンテンツをエージェントループやモデルのコンテキストに反映させるかどうかに焦点を当てています。

開始方法

docker compose up --build

MCP URL:

http://127.0.0.1:8089/mcp

ローカル開発用:

npm install
npm run dev

設定

環境変数

デフォルト値

MCP_TEST_PORT

8089

MCP_TEST_UPDATE_DELAY_SECONDS

5

MCP_TEST_INITIAL_STATUS

pending

MCP_TEST_UPDATED_STATUS

reviewed

MCP_TEST_SEND_LIST_CHANGED

false

MCP_TEST_LOG_LEVEL

debug

MCP_TEST_SEND_LIST_CHANGED=true の場合、サーバーはシミュレートされた更新後に notifications/resources/list_changed も送信します。

期待されるクライアントの動作

理想的なMCPクライアントは、以下のフローに従う必要があります:

initialize
  ↓
resources/list
  ↓
resources/read test://review/status
  ↓
resources/subscribe test://review/status
  ↓
receive notifications/resources/updated
  ↓
resources/read test://review/status again
  ↓
reflect updated status: reviewed in agent context

サーバーの機能

初期化レスポンスで以下を通知します:

{
  "resources": {
    "subscribe": true,
    "listChanged": true
  }
}

実装されているMCPメッセージ

  • initialize

  • resources/list

  • resources/read

  • resources/subscribe

  • resources/unsubscribe

  • notifications/resources/updated

  • notifications/resources/list_changed (MCP_TEST_SEND_LIST_CHANGED=true の場合)

ツールは実装されていません。

ログ

サーバーは重要なメッセージをすべてログに記録するため、クライアントの動作を客観的に確認できます:

[initialize] client connected
[resources/list] requested
[resources/read] uri=test://review/status version=1
[resources/subscribe] uri=test://review/status
[resource/update] uri=test://review/status version=2
[notification/send] notifications/resources/updated uri=test://review/status
[resources/read] uri=test://review/status version=2
[resources/unsubscribe] uri=test://review/status

リソース購読サポートの重要な証拠は以下の通りです:

resources/subscribe was received
notification was sent
resources/read was received again after the notification

テスト

npm test

テストスイートは以下を検証します:

  • resources/list が test://review/status を返すこと

  • 初回の resources/read がバージョン1を返すこと

  • resources/subscribe がバージョン2への内部更新をトリガーすること

  • notifications/resources/updated が受信されること

  • 更新後の resources/read がバージョン2を返すこと

クライアント互換性ノート

Codex CLI

  • MCP接続:

  • resources/list を呼び出しますか?

  • resources/read を呼び出しますか?

  • resources/subscribe を呼び出しますか?

  • notifications/resources/updated を受信しますか?

  • 更新後にリソースを再読み込みしますか?

  • メモ:

Gemini CLI

  • MCP接続:

  • resources/list を呼び出しますか?

  • resources/read を呼び出しますか?

  • resources/subscribe を呼び出しますか?

  • notifications/resources/updated を受信しますか?

  • 更新後にリソースを再読み込みしますか?

  • メモ:

OpenCode

  • MCP接続:

  • resources/list を呼び出しますか?

  • resources/read を呼び出しますか?

  • resources/subscribe を呼び出しますか?

  • notifications/resources/updated を受信しますか?

  • 更新後にリソースを再読み込みしますか?

  • メモ:

GitHub Copilot CLI

  • MCP接続:

  • resources/list を呼び出しますか?

  • resources/read を呼び出しますか?

  • resources/subscribe を呼び出しますか?

  • notifications/resources/updated を受信しますか?

  • 更新後にリソースを再読み込みしますか?

  • メモ:

Claude Code

  • MCP接続:

  • resources/list を呼び出しますか?

  • resources/read を呼び出しますか?

  • resources/subscribe を呼び出しますか?

  • notifications/resources/updated を受信しますか?

  • 更新後にリソースを再読み込みしますか?

  • メモ:

Goose

  • MCP接続:

  • resources/list を呼び出しますか?

  • resources/read を呼び出しますか?

  • resources/subscribe を呼び出しますか?

  • notifications/resources/updated を受信しますか?

  • 更新後にリソースを再読み込みしますか?

  • メモ:

Crush

  • MCP接続:

  • resources/list を呼び出しますか?

  • resources/read を呼び出しますか?

  • resources/subscribe を呼び出しますか?

  • notifications/resources/updated を受信しますか?

  • 更新後にリソースを再読み込みしますか?

  • メモ:

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Minimal MCP server for testing SkyStage's self-auth auto-detection feature. It includes tools like ping, echo, server_info, and read_secret, and uses a mock OAuth provider for login.
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Educational MCP server demonstrating the 2026-07-28 stateless protocol with raw Starlette, no SDK, featuring tools, request state handles, MRTR elicitation, and subscriptions.
    MIT