Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors created by the SDK should be restricted to codes -32000 to -32099 #85

Open
jspahrsummers opened this issue Dec 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jspahrsummers
Copy link
Member

This is the "server error" portion of the JSON-RPC error space, "reserved for implementation-defined server-errors."

Since MCP clients and servers are both JSON-RPC servers, it feels appropriate for the SDK to stay within this error code range—leaving the remaining error codes available for custom application usage.

@jspahrsummers jspahrsummers added the bug Something isn't working label Dec 6, 2024
sumitesh9 pushed a commit to sumitesh9/typescript-sdk that referenced this issue Dec 22, 2024
The SDK's custom error codes were previously using arbitrary negative numbers
(-1, -2) which could conflict with application-specific error codes. This change:

- Updates ConnectionClosed from -1 to -32000
- Updates RequestTimeout from -2 to -32001
- Keeps standard JSON-RPC error codes unchanged
- Adds documentation explaining the server error range usage

This modification ensures compliance with the JSON-RPC 2.0 specification, which
reserves -32000 to -32099 for implementation-defined server errors. This change
allows applications to freely use other error code ranges without potential
conflicts with SDK-generated errors.

Issue: modelcontextprotocol#85
@sumitesh9
Copy link

PR for this issue - #103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants