bug: a request sent before initialize is answered with JSON-RPC error code 0 instead of -32600
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start with the minimal program in the issue: run a server over IOTransport, send tools/list before initialize, and confirm the response carries code: 0. Find where the 'invalid during session initialization' error is constructed and check which code it sets. Done when that path returns -32600 and the message text is unchanged, with a test that asserts the code.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Go
- Stars
- 5.2k
- Forks
- 568
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 40
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/go-sdk
-
Session-lifecycle bookkeeping logs at info, spamming multiple log lines per request on stateless streamable HTTPPossibly taken @anneheartrecord claimed this 43 days ago. OpenP3
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
modelcontextprotocol/go-sdk#1204 · 1 reaction ·
Maintainers usually reply within 1 day
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensionsPossibly taken @ajuijas claimed this 209 days ago. Openneeds investigation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
modelcontextprotocol/go-sdk#745 · 13 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
mcp: ReadResource caches the result of a multi round-trip retry and serves a retry request from the cachePossibly taken @vbcherepanov claimed this today. Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
modelcontextprotocol/go-sdk#1369 ·
Maintainers usually reply within 1 day
-
mcp: a response that has already arrived is discarded when the caller's context is cancelled during decoding, and notifications/cancelled is sent for the completed requestPossibly taken @vbcherepanov claimed this today. Open
Difficulty 3/5 Half a day Newbie friendliness 35/100
modelcontextprotocol/go-sdk#1368 ·
Maintainers usually reply within 1 day
-
mcp: client returns an input_required result that has only requestState instead of retryingPossibly taken @SergeevDmitry claimed this 1 day ago. Open
Difficulty 3/5 Half a day Newbie friendliness 62/100
modelcontextprotocol/go-sdk#1364 ·
Maintainers usually reply within 1 day
All issues in modelcontextprotocol/go-sdk
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-telemetry/opentelemetry-go-compile-instrumentation#1467 ·
Maintainers usually reply within 3 days
-
Python 3.15 supportPossibly taken @amnesiaof claimed this today. OpenL: python L: python:uv
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dependabot/dependabot-core#16524 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
duplication
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
openvibely/openvibely#1443 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 60/100
canonical/service-mesh#845 ·
Maintainers usually reply within 1 day