Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

HTTP client fails connect when the server acknowledges notifications/initialized with an empty 200

未关闭
#598 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@koic 已经在做这个了。

开始于 2026年10月13日。

  • #599 来自 @dtjldamien —— 已关闭,未合并
  • #600 来自 @koic —— 未关闭

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
20/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
ruby

调研方向

Read MCP::Client::HTTP#send_request and resolve_response_body, which the issue identifies as the failing path. Check the existing tests for the notifications/initialized response and the linked pull requests #599 and #600 to see the work already underway. Done means a notification acknowledged with a bodyless 2xx no longer raises, while a request with the same response still raises unsupported_media_type.

由索引模型根据 Issue 内容生成。

描述

bug

Observed behavior

With mcp 1.7.0 (and 0.15.0), MCP::Client#connect with the legacy initialize handshake over Streamable HTTP fails against servers that acknowledge notifications/initialized with 200 OK, an empty body and no Content-Type, instead of 202 Accepted:

MCP::Client::RequestHandlerError: Unsupported Content-Type: nil. Expected application/json or text/event-stream.
error_type: :unsupported_media_type

The initialize request succeeds. The error comes from the following notifications/initialized POST: send_request passes the response to resolve_response_body, which returns early only for 202 and raises for any other response without a JSON or SSE content type.

For example, Freshservice's hosted MCP server (Freshworks, https://<account>.freshservice.com/mcp) responds this way:

POST /mcp  {"jsonrpc":"2.0","method":"notifications/initialized"}

HTTP/1.1 200 OK
Content-Length: 0

I ran each SDK's client against the same Freshservice server, with the same OAuth token, on 2026-10-13:

Client notifications/initialized response Result
TypeScript SDK 1.32.1 (StreamableHTTPClientTransport) 200, no Content-Type Connects, listTools returns 40 tools
Python SDK 2.3.0 (streamable_http_client) 200, no Content-Type Connects, list_tools returns 40 tools
Ruby SDK main (7735046) 200, no Content-Type Unsupported Content-Type: nil

Expected behavior

The spec says the server MUST return 202 Accepted with no body when it accepts a notification (Transports, Sending Messages to the Server), so the server is out of spec here. Still, a notification awaits no response, and both reference SDKs accept any 2xx for it:

In both, a request answered the same way is still an error: TypeScript throws StreamableHTTPError and Python returns a JSON-RPC error, each with "Unexpected content type".

I'd expect connect to succeed when a notification is acknowledged with a 2xx and no body. Requests should keep raising unsupported_media_type for the same response.

Reproduction

require "mcp"
require "webmock"
include WebMock::API
WebMock.enable!

url = "https://example.com/mcp"
stub_request(:post, url)
  .with { |req| JSON.parse(req.body)["method"] == "initialize" }
  .to_return(
    status: 200,
    headers: { "Content-Type" => "application/json" },
    body: { jsonrpc: "2.0", id: "1", result: { protocolVersion: "2025-11-25", capabilities: {}, serverInfo: { name: "s", version: "1" } } }.to_json,
  )
stub_request(:post, url)
  .with { |req| JSON.parse(req.body)["method"] == "notifications/initialized" }
  .to_return(status: 200, body: "")

MCP::Client.new(transport: MCP::Client::HTTP.new(url: url)).connect(mode: :legacy)
# => MCP::Client::RequestHandlerError: Unsupported Content-Type: nil. ...

Fix: #599. It returns nil instead of raising in that branch when the message is a notification and the status is 2xx, matching the behaviour above.

主要语言
Ruby
星标
924
派生
136
平均合并
1 天 6 小时
30 天内合并 PR
35

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

modelcontextprotocol/ruby-sdk 的其他 Issue

查看 modelcontextprotocol/ruby-sdk 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。