bug: a request sent before initialize is answered with JSON-RPC error code 0 instead of -32600
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
Hướng nghiên cứu
Bắt đầu với chương trình tối giản trong issue: chạy một server trên IOTransport, gửi tools/list trước initialize và xác nhận phản hồi có code: 0. Tìm nơi lỗi 'invalid during session initialization' được tạo ra và kiểm tra mã nó đặt. Hoàn thành khi đường đi này trả về -32600 và nội dung thông báo không thay đổi, kèm một test khẳng định mã đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Go
- Star
- 5.3k
- Fork
- 606
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 75
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/go-sdk
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensionsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởneeds investigation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/go-sdk#745 · 13 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mcp: ClientSession.CallTool omits Mcp-Param-* headers unless the tool is in the ListTools cache, so a call without a prior tools/list is rejectedCó thể đã có người làm @sundarshahi đã nhận hôm nay. Đang mở
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 35/100
modelcontextprotocol/go-sdk#1481 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 32/100
modelcontextprotocol/go-sdk#1480 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mcp: LoggingHandler drops records logged at custom slog levelsCó thể đã có người làm @kaankucukx đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
modelcontextprotocol/go-sdk#1445 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mcp: Client.Connect falls back to initialize after a 401 on server/discover, running the authorization flow twiceCó thể đã có người làm @kerthans đã nhận 11 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
modelcontextprotocol/go-sdk#1423 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/go-sdk
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 2 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
kagent-dev/kagent#3462 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
netrc credential source accepts a password with an embedded CR/LF that every other source rejectsĐang mởagent-butler-finding bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
jordansmall/spindrift#6268 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 7 ngày