Align error handling documentation with SEP-1303#967
Merged
stephentoub merged 2 commits intomainfrom Nov 17, 2025
Merged
Conversation
- Updated McpErrorCode.InvalidParams documentation to clarify it's for protocol-level errors (malformed requests, unknown primitives) - Updated CallToolResult documentation to distinguish between tool execution errors and protocol errors - Updated McpProtocolException documentation to emphasize it's only for protocol-level errors - Added test to verify input validation errors are returned as tool execution errors (IsError=true) - Implementation already correctly handles input validation as tool execution errors per SEP-1303 Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Review and implement ModelContextProtocol changes
Align error handling documentation with SEP-1303
Nov 15, 2025
stephentoub
approved these changes
Nov 16, 2025
Contributor
stephentoub
left a comment
There was a problem hiding this comment.
@halter73 / @mikekistler, should we expose an option or switch somewhere to allow propagating details of arbitrary exceptions out of tools?
Contributor
I think we can defer that until there is clear signal from users that it is needed. |
eiriktsarpalis
approved these changes
Nov 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.