Add validation and error signaling guidance to MCP tool XML docs (#1275)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
This commit is contained in:
Copilot 2026-02-17 19:45:48 -05:00 • committed by GitHub
commit ec4c732632
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,6 +14,13 @@ namespace ModelContextProtocol.Protocol;
/// and potentially self-correct in subsequent requests.
/// </para>
/// <para>
/// To return a validation or business-logic error from a tool method, either throw an <see cref="McpException"/>
/// (whose <see cref="Exception.Message"/> will be included in the error result), or declare the tool's return type
/// as <see cref="CallToolResult"/> so it can be returned directly with <see cref="IsError"/> set to <see langword="true"/>
/// and details in <see cref="Content"/>. Using <see cref="CallToolResult"/> as the return type gives the tool full control
/// over both success and error responses.
/// </para>
/// <para>
/// Protocol-level errors (such as unknown tool names, malformed requests that fail schema validation,
/// or server errors) should be reported as MCP protocol error responses using <see cref="McpErrorCode"/>.
/// </para>