Skip to content

[Bug] 联网搜索 MCP:notifications/initialized 响应缺 Content-Type,导致 rmcp 客户端握手失败 #38

Open

Description

@yu347358

问题

web_search_prime MCP 服务器在 notifications/initialized 这一步返回的响应缺少 Content-Type,
导致使用 rmcp(MCP 官方 Rust SDK)的客户端在握手阶段直接 fatal,服务完全不可用。

复现

U="https://open.bigmodel.cn/api/mcp/web_search_prime/mcp"
KEY="<你的_API_KEY>"

# 1) initialize —— 这一步是正常的
SID=$(curl -sS -D - -X POST "$U" \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"probe","version":"1"}}}' \
  | grep -i 'mcp-session-id' | sed 's/.*: //' | tr -d '\r\n')

# 2) 发 initialized 通知 —— 问题在这里
curl -sS -D - -X POST "$U" \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: $SID" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}'

实际响应:

HTTP/1.1 200 OK
Content-Length: 0
Connection: keep-alive
Alt-Svc: h3=":443"; ma=3600
Strict-Transport-Security: max-age=31536000; includeSubDomains

                            ← 到这里就结束了:没有 Content-Type

期望行为

MCP 规范(Streamable HTTP transport)规定:JSON-RPC 通知的响应应为 202 Accepted,且不带 body。

影响

使用 rmcp 的客户端会在这一步直接致命,整条链路断掉:

ERROR rmcp::transport::worker: worker quit with fatal:
Unexpected content type: Some("missing-content-type; body: "),
when send initialized notification

服务端其余部分是正常的(已逐段验证)

步骤 结果
initialize ✅ 正确返回 Content-Type: text/event-stream + 正确的 serverInfo
tools/list ✅ 正确返回 web_search_prime 工具定义
tools/call ✅ 真的返回搜索结果(标题 / 链接 / 摘要)

⇒ 只有 initialized 通知这一步的响应头不合规,服务就完全没法用。
其余全部正常,说明这是个很小的兼容问题。

环境

  • 客户端:Codex CLI 0.155.1(内置 rmcp 3.2.0)
  • 服务端:https://open.bigmodel.cn/api/mcp/web_search_prime/mcp
  • 平台:Windows 11 + Git Bash

相关上游背景

"服务端回 200 而非 202" 这类兼容问题,rmcp 侧有两次修复:

PR 状态 内容
modelcontextprotocol/rust-sdk#849 已合并(2026-05-14) 接受 "200 + 空 body"
modelcontextprotocol/rust-sdk#1063 仍 OPEN(2026-07-27 至今) "fix: don't fail a notification POST on response shape"

rmcp 3.2.0 含 #849,不含 #1063。

⇒ 但服务端修更划算: 把通知的响应改成 202 Accepted(或至少补上 Content-Type),
一行改动就能兼容所有客户端,不必等任何一方升级 SDK。
考虑到还有 mark3labs/mcp-go#740 这类同类问题,
按规范返回 202 也能少踩一个坑。

附带一处文档不一致

文档里工具名写作 webSearchPrime(驼峰),
而 tools/list 实际返回的是 web_search_prime(下划线)。

按文档去配工具白名单会匹配不上,建议同步一下。


如需该次请求的服务端日志 ID 便于定位,我可以在评论中补充。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions