mcp-resource-subscribe-test

mcp-resource-subscribe-test

Minimal MCP server for testing client support for resources/subscribe and notifications/resources/updated, simulating an asynchronous status update.

Category
访问服务器

README

mcp-resource-subscriber

CLI probe for MCP resources/subscribe — connects to any MCP Streamable HTTP server, subscribes to a resource, receives the live update notification, and re-reads the updated content.


Install

# recommended (no install):
pnpm dlx mcp-resource-subscriber --url <mcp-server-url> --uri <resource-uri>

# fallback if pnpm is unavailable:
npx mcp-resource-subscriber --url <mcp-server-url> --uri <resource-uri>

# or install globally:
npm install -g mcp-resource-subscriber
mcp-resource-subscriber --url <mcp-server-url> --uri <resource-uri>

Note: A reference MCP test server used during compatibility verification is also included in this repository (Docker Compose). See the Lab Server section below.


CLI Usage

Against copilot-review-mcp

mcp-resource-subscriber \
  --url http://127.0.0.1:8080/mcp/copilot-review \
  --uri copilot-review://watch/<watch_id> \
  --timeout-ms 900000

copilot-review-mcp is the @scottlz0310/copilot-review-mcp server. Replace <watch_id> with the ID returned by start_copilot_review_watch.

Against the bundled test server

# Start the test server first:
docker compose up --build
# or: npm run dev

mcp-resource-subscriber --url http://127.0.0.1:8089/mcp

Note: test://review/status is the default resource URI and is only meaningful against the bundled test server. For any other MCP server, always pass --uri explicitly.

Options

  --url <url>         MCP server Streamable HTTP endpoint (required)
                      Env: MCP_PROBE_URL
  --uri <uri>         Resource URI to subscribe to
                      Default: test://review/status (bundled test server only)
                      Env: MCP_PROBE_URI
  --auth-token <tok>  Bearer token for Authorization header
                      Prefer MCP_PROBE_AUTH_TOKEN env var (flag is visible in
                      process lists and may be stored in shell history)
                      Env: MCP_PROBE_AUTH_TOKEN (recommended)
  --skip-resource-list-check
                      Skip resources/list and assume the URI exists.
                      Use for servers with dynamic resources not in list.
                      Env: MCP_PROBE_SKIP_LIST_CHECK=true
  --timeout-ms <ms>   Notification wait timeout in ms (default: 15000)
                      Env: MCP_PROBE_TIMEOUT_MS
  --version, -v       Print version and exit
  --help, -h          Print this help and exit

Structured output

Every run emits machine-parseable lines:

capabilities {"subscribe":true,"listChanged":true}
resource-found true
resource-uri <resource-uri>
server-url <url>
initial
<initial resource text>
route subscription
subscribed true
notification-received true
unsubscribed true
recommended_next_action READ_REVIEW_THREADS
error-code null
notification <resource-uri>
final
<updated resource text>
phase-summary route=subscription url=<url> uri=<uri>

Note: recommended_next_action is only emitted when the final resource text contains it (e.g., from copilot-review-mcp). It is omitted for the bundled test server.

On failure:

error-code SERVER_URL_UNKNOWN
phase-summary route=failed url=unknown error-code=SERVER_URL_UNKNOWN
error-code RESOURCE_NOT_FOUND
phase-summary route=timeout url=<url> uri=<uri> error-code=RESOURCE_NOT_FOUND
error-code NOTIFICATION_TIMEOUT
phase-summary route=timeout url=<url> uri=<uri> error-code=NOTIFICATION_TIMEOUT

Lab Server

Minimal MCP Streamable HTTP server for testing whether MCP clients correctly handle resources/subscribe and notifications/resources/updated.

This repository is meant to be a reproducible issue / compatibility lab for CLI AI agents such as Codex CLI, Gemini CLI, OpenCode, GitHub Copilot CLI, Claude Code, Goose, and Crush.

Purpose

The server exposes one fixed MCP resource:

test://review/status

Initial content:

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

After a client subscribes to the resource, the server waits for MCP_TEST_UPDATE_DELAY_SECONDS, changes the resource, and sends:

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

Updated content:

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

Why Resources/Subscribe Instead Of Tools/Call

tools/call is useful for explicit actions, but many agent workflows depend on context that changes after the original request. Polling every source is noisy and client-specific. MCP resource subscriptions give clients a protocol-level way to learn that a known context object changed and should be re-read.

Examples where subscription behavior matters:

  • Copilot review result
  • PR review thread
  • CI status
  • Codecov comment
  • GitHub issue discussion
  • local build/test result

This test server focuses on whether the client notices a resource update, re-runs resources/read, and reflects the new content in the agent loop / model context.

Start

docker compose up --build

MCP URL:

http://127.0.0.1:8089/mcp

For local development:

npm install
npm run dev

Configuration

Environment variable Default Description
MCP_TEST_PORT 8089 TCP port the server listens on
MCP_TEST_PATH /mcp Additional MCP endpoint path. The server always registers /mcp; this adds a second path (e.g. /mcp/subscribe-probe for gateway routing). Both paths share the same MCP handler.
MCP_TEST_UPDATE_DELAY_SECONDS 5 Seconds to wait before sending the resource update notification
MCP_TEST_INITIAL_STATUS pending Initial value of the status field in the resource
MCP_TEST_UPDATED_STATUS reviewed Value of status after the simulated update
MCP_TEST_SEND_LIST_CHANGED false Also send notifications/resources/list_changed after the update
MCP_TEST_LOG_LEVEL debug Log verbosity (debug / info / warn / error / silent)

If MCP_TEST_SEND_LIST_CHANGED=true, the server also sends notifications/resources/list_changed after the simulated update.

Expected Client Behavior

An ideal MCP client should follow this flow:

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

Server Capabilities

The initialize response advertises:

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

Implemented MCP Messages

  • initialize
  • resources/list
  • resources/read
  • resources/subscribe
  • resources/unsubscribe
  • notifications/resources/updated
  • notifications/resources/list_changed when MCP_TEST_SEND_LIST_CHANGED=true

No tools are implemented.

Logs

The server logs each important message so client behavior can be checked objectively:

[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

The key evidence for resource subscription support is:

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

Tests

npm test

The test suite verifies:

  • resources/list returns test://review/status
  • initial resources/read returns version 1
  • resources/subscribe triggers an internal update to version 2
  • notifications/resources/updated is received
  • updated resources/read returns version 2

Standalone Subscription Probe Client

The repository also includes a reusable MCP SDK client that exercises the full subscription flow against a running server:

npm run probe:subscribe -- --url http://127.0.0.1:8089/mcp

After npm run build, the same client can be run directly with Node:

node dist/src/client/cli.js --url http://127.0.0.1:8089/mcp

This client is separate from any AI client's native MCP surface. For Codex CLI, it demonstrates a reproducible agent-driven SDK workaround: if the agent has shell, Node.js, local dependency, and localhost network access, it can run this client to call resources/subscribe, receive notifications/resources/updated, and re-read the updated resource.

Verification Procedure

Use docs/verification-guide.md for a repeatable client verification procedure.

Record results in results/compatibility-matrix.md.

Skill Templates

Reusable Codex skill templates are tracked under docs/skills. The pr-review-subscribe template documents a PR review cycle that uses MCP resources/subscribe as the primary wait route and polling only as fallback.

Client Compatibility

See results/compatibility-matrix-v2.md for the current Round 2 compatibility matrix (tool + resource testing) across Codex CLI, Gemini CLI, OpenCode, GitHub Copilot CLI, Claude Code, Goose, and Crush.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选