Skip to content

fix(mcp): a rejected argument logs as InvalidArguments with the fields that failed - #118

Open
Ooscaar wants to merge 1 commit into
developfrom
fix/mcp-invalid-arguments-telemetry
Open

Ooscaar wants to merge 1 commit into
developfrom
fix/mcp-invalid-arguments-telemetry

Conversation

@Ooscaar

@Ooscaar Ooscaar commented Nov 19, 2026

Copy link
Copy Markdown
Member

Problem

In Axiom zernio-mcp, a tool call FastMCP rejects for bad arguments logs as error_type=ValidationError, the same name as an SDK model rejecting an API response. Since FastMCP 4.2.1 the log line no longer names the failing field either, so finding which argument broke (the not_deleted and platform bugs fixed in #116) meant digging through old Railway deployments. On FastMCP 4.2.1 a rejected response logs as _ToolBodyError, a private FastMCP class, with no field either.

Fix

_error_fields walks the cause chain to the pydantic error:

  • FastMCP's argument ValidationError logs error_type: "InvalidArguments".
  • Anything else wrapping a pydantic error (a response an SDK model rejects) logs error_type: "ValidationError".
  • Both add invalid_fields, e.g. status:literal_error,limit:int_parsing: field paths and error types only, never values (errors(include_input=False)), since arguments can carry customer content.

Sentry is unchanged: argument errors stay expected failures, response rejections stay issues.

Validation

  • pytest tests/test_mcp_telemetry.py: 36 passed, 2 new (argument fields logged without the value; response rejection stays ValidationError with its field).
  • pytest tests -k mcp: 1715 passed, 5 skipped. ruff and mypy clean.

After deploy, ['zernio-mcp'] | where error_type == 'InvalidArguments' | summarize count() by tool, invalid_fields shows which arguments agents get wrong.

🤖 Generated with Claude Code

…s that failed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant