Align error handling documentation with SEP-1303 #967
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updates documentation to reflect SEP-1303, which clarifies that input validation errors should be returned as tool execution errors (
IsError=true) rather than protocol errors, enabling language models to see error details and self-correct.Changes
McpErrorCode.InvalidParams: Clarified usage is limited to malformed requests (schema violations) and unknown primitives (tool/prompt/resource names). Explicitly excludes input validation errors.CallToolResult.IsError: Enhanced remarks to specify tool execution errors include input validation (wrong format, out of range), API failures, and business logic errors. Added examples of model self-correction scenarios.McpProtocolException: Strengthened language to emphasize protocol-level scope only, not tool execution failures.Test coverage: Added
Can_Handle_Call_Tool_Requests_With_InputValidationExceptionto verifyArgumentException(representing input validation) converts to tool execution error.Implementation Note
The SDK already implements SEP-1303 correctly. The error handler in
McpServerImpl.cs(lines 585-598) catches all exceptions exceptOperationCanceledExceptionandMcpProtocolException, converting them toCallToolResultwithIsError=true. This ensures JSON deserialization failures and parameter validation errors reach the model as actionable feedback.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.