Skip to content

feat(server): carry structured input-validation details in tool error results - #3422

Closed
Lubaoshuai wants to merge 1 commit into
modelcontextprotocol:mainfrom
Lubaoshuai:fix/structured-input-validation-errors
Closed

feat(server): carry structured input-validation details in tool error results#3422
Lubaoshuai wants to merge 1 commit into
modelcontextprotocol:mainfrom
Lubaoshuai:fix/structured-input-validation-errors

Conversation

@Lubaoshuai

Copy link
Copy Markdown

Issue

Fixes #3351 (as realized on the current v2 server; the issue's snippet predates the mcpserver refactor).

Summary

When MCPServer rejects arguments against a tool's input schema, the CallToolResult flattened pydantic's ValidationError into a single text line, so clients had to regex prose to tell a wrong type from a missing required field — with message wording that varies per validator keyword and is not a stable contract.

For that specific failure mode, the error result now also carries machine-readable details in structured_content:

{
  "type": "input_validation",
  "errors": [
    {"path": "x", "type": "int_parsing", "message": "..."}
  ]
}
  • The text content the model reads is unchanged (backward compatible).
  • The rejected values are never echoed back, matching the existing field-names-only logging policy.
  • Safe with respect to output-schema validation: clients only revalidate structured_content of successful results (Client.call_toolvalidate_tool_result is gated on not result.is_error).

Testing

  • pytest tests/server/mcpserver/test_server.py — 168 passed, including two new tests: one asserting the structured details (path/type/message, and that rejected values are not echoed), one asserting deliberate ToolErrors still carry no structured content (backward compat).
  • ruff check / ruff format --check on both touched files — clean.

… results

When MCPServer rejects arguments against a tool's input schema, the
CallToolResult flattened pydantic's ValidationError into a single text
line, so clients had to regex prose to tell a wrong type from a missing
required field (modelcontextprotocol#3351).

Attach structured_content to that specific error result: a stable
input_validation code plus per-error path/type/message. The rejected
values stay out of the payload, the text content the model reads is
unchanged, and clients only revalidate structured content of successful
results, so no output-schema check is affected.
@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Aug 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3351.

If a maintainer assigns you to #3351, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take.

You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way.

CONTRIBUTING.md has the full reasoning, but in short:

  • We're a small team with very little capacity to review community PRs right now.
  • Many recent PRs are AI-generated with little human review, and reviewing one carefully still costs a maintainer as much time as it ever did. A well-described issue is usually more useful to us than the code.

Maintainers: reopen, remove missing-issue-link, or add bypass-issue-check to override.

@github-actions github-actions Bot closed this Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server.call_tool()'s input-validation error result discards jsonschema.ValidationError's structured fields, leaving only free-text prose

1 participant