bug: a request sent before initialize is answered with JSON-RPC error code 0 instead of -32600
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Issue にある最小限のプログラムから始めます。IOTransport 上でサーバーを起動し、initialize より前に tools/list を送信して、レスポンスに code: 0 が含まれることを確認してください。'invalid during session initialization' エラーが生成されている箇所を見つけ、そこで設定されているコードを確認します。この経路が -32600 を返し、メッセージのテキストが変わっておらず、そのコードを検証するテストがあれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
A request sent before initialize is answered with a JSON-RPC error whose code is 0. 0 is not a JSON-RPC 2.0 error code; the spec requires -32600 (Invalid Request) for a request that cannot be served.
Version
github.com/modelcontextprotocol/go-sdk v1.8.0 (also observed on main).
Reproduction
Run a server over a raw stdio transport (IOTransport) and, before sending initialize, send:
{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}
Observed response:
{"jsonrpc":"2.0","id":1,"error":{"code":0,"message":"method \"tools/list\" is invalid during session initialization"}}
Expected response (JSON-RPC 2.0):
{"jsonrpc":"2.0","id":1,"error":{"code":-32600,"message":"method \"tools/list\" is invalid during session initialization"}}
The message text is correct; only the code is wrong.
Minimal program
srv := mcp.NewServer(&mcp.Implementation{Name: "t", Version: "0"}, nil)
c2s, serverIn := io.Pipe()
serverOut, cFromS := io.Pipe()
go func() { _ = srv.Run(ctx, &mcp.IOTransport{Reader: c2s, Writer: cFromS}) }()
fmt.Fprintln(serverIn, `{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}`)
// read the first line of serverOut
Notes
pingis correctly allowed beforeinitialize.0is especially awkward for clients: it is indistinguishable from "no code set" and is not one of the standard codes (-32700,-32600,-32601,-32602,-32603).
Impact
Consumers must wrap the transport to rewrite code: 0 to -32600 before forwarding to clients. We do exactly that in ai-rulez (internal/mcp GuardLifecycle) and would like to delete the workaround once the SDK answers with -32600 itself.
- 主要言語
- Go
- スター
- 5.2k
- フォーク
- 594
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 63
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/go-sdk のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
modelcontextprotocol/go-sdk#1444 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Session-lifecycle bookkeeping logs at info, spamming multiple log lines per request on stateless streamable HTTP対応中かも @anneheartrecord が 59 日前に担当しました。 オープンP3
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
modelcontextprotocol/go-sdk#1204 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensions対応中かも @ajuijas が 224 日前に担当しました。 オープンneeds investigation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelcontextprotocol/go-sdk#745 · コメント 13 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
mcp: notifications and interrupted calls lose ErrConnectionClosed対応中かも @Jackmeson1 が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 30/100
modelcontextprotocol/go-sdk#1448 ·
メンテナーはふだん 1 日以内に返信
-
mcp: LoggingHandler drops records logged at custom slog levels対応中かも @kaankucukx が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
modelcontextprotocol/go-sdk#1445 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/go-sdk の issue をすべて見る
似ている issue
-
fix(handlers): explicitly set Content-Type header in static Index handler対応中かも @kage-zero が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
Quick Open: restore dependency-directory exclusions in filesystem fallback対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
eugenioenko/ttt#1206 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
open-policy-agent/opa#9426 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
rorkai/App-Store-Connect-CLI#3192 ·
メンテナーはふだん 1 日以内に返信
-
t:urlDecodeUni does not map U+3002 and U+FF61 to a dot, unlike ModSecurity対応中かも @fzipi が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信