Add validation and error signaling guidance to MCP tool XML docs#1275
Open
Add validation and error signaling guidance to MCP tool XML docs#1275
Conversation
…tion Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Provide guidance on MCP Tools validation
Add validation and error signaling guidance to MCP tool XML docs
Feb 15, 2026
stephentoub
reviewed
Feb 15, 2026
| /// The tool method is responsible for validating its own input arguments (e.g., checking required fields, value ranges, string lengths, or | ||
| /// any other business rules). Data annotations such as <c>RequiredAttribute</c> and | ||
| /// <c>MaxLengthAttribute</c> on parameter types influence the generated JSON schema exposed | ||
| /// to clients, but they are not enforced at runtime by the SDK. Validation should be performed explicitly within the tool method. |
Contributor
There was a problem hiding this comment.
@jeffhandley / @eiriktsarpalis / @halter73 , do you think the current state of data annotation support is correct, or should the product src actually be validating the annotations?
stephentoub
approved these changes
Feb 15, 2026
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
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.
McpServerToolAttributeXML docs to add explicit validation and error signaling guidanceMcpServerToolXML docs to add matching validation and error signaling guidanceMcpExceptionXML docs to clarify its role in tool validation error signalingTool.DescriptionXML docs to emphasize the importance of good descriptions for input validationCallToolResultXML docs to add guidance on how to signal validation failuresOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.