fix(mcp): ignore discover probe in resource list tests (#4179)

mcp-go sends server/discover before the legacy handshake, and the
pagination tests were counting that probe as a resources/list page.
main
lyingbug 2026-10-12 14:53:16 +08:00 committed by GitHub
parent c2edec192b
commit 089711f92c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 2 deletions

View File

@ -20,13 +20,21 @@ type resourceListTransport struct {
func (t *resourceListTransport) SendRequest(
ctx context.Context, request transport.JSONRPCRequest,
) (*transport.JSONRPCResponse, error) {
if request.Method == "initialize" {
switch request.Method {
case "server/discover":
// mcp-go probes the stateless protocol before the legacy handshake.
// These tests count only resources/list pages on the handshake path.
return &transport.JSONRPCResponse{Error: &sdkmcp.JSONRPCErrorDetails{
Code: -32601, Message: "Method not found",
}}, nil
case "initialize":
return &transport.JSONRPCResponse{Result: json.RawMessage(`{
"protocolVersion":"2025-06-18", "capabilities":{"resources":{}},
"serverInfo":{"name":"resources-test","version":"1"}
}`)}, nil
default:
return t.send(ctx, request)
}
return t.send(ctx, request)
}
func (*resourceListTransport) SendNotification(context.Context, sdkmcp.JSONRPCNotification) error {