improve error handling for tools and server methods (#311)

- Fix tool error handling to properly distinguish between protocol
errors and tool execution errors
- Return structured JSON-RPC errors directly for protocol-level issues
- Embed regular tool errors in CallToolResult as per MCP specification
- Improve server error responses for unknown prompts and tools
- Add comprehensive tests for both structured and regular error handling
This commit is contained in:
Shusaku Yasoda 2025-08-21 01:31:11 +09:00 • committed by GitHub
commit 719f68d0bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -311,6 +311,8 @@ const (
CodeResourceNotFound = -32002
// The error code if the method exists and was called properly, but the peer does not support it.
CodeUnsupportedMethod = -31001
// The error code for invalid parameters
CodeInvalidParams = -32602
)
// notifySessions calls Notify on all the sessions.