Skip to content

Commit 09181c2

Browse files
authored
mcp: use correct ResourceNotFound code (#35)
1 parent 1478ba7 commit 09181c2

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

internal/jsonrpc2/wire.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var (
3434
// ErrUnknown should be used for all non coded errors.
3535
ErrUnknown = NewError(-32001, "JSON RPC unknown error")
3636
// ErrServerClosing is returned for calls that arrive while the server is closing.
37-
ErrServerClosing = NewError(-32002, "JSON RPC server is closing")
37+
ErrServerClosing = NewError(-32004, "JSON RPC server is closing")
3838
// ErrClientClosing is a dummy error returned for calls initiated while the client is closing.
3939
ErrClientClosing = NewError(-32003, "JSON RPC client is closing")
4040
)

mcp/shared.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,7 @@ func sessionMethod[S Session, P Params, R Result](f func(S, context.Context, P)
207207

208208
// Error codes
209209
const (
210-
// The error code to return when a resource isn't found.
211-
// See https://modelcontextprotocol.io/specification/2025-03-26/server/resources#error-handling
212-
// However, the code they chose is in the wrong space
213-
// (see https://github.com/modelcontextprotocol/modelcontextprotocol/issues/509).
214-
// so we pick a different one, arbitrarily for now (until they fix it).
215-
// The immediate problem is that jsonprc2 defines -32002 as "server closing".
216-
CodeResourceNotFound = -31002
210+
CodeResourceNotFound = -32002
217211
// The error code if the method exists and was called properly, but the peer does not support it.
218212
CodeUnsupportedMethod = -31001
219213
)

0 commit comments

Comments
 (0)