Report #7441
[tooling] Agent fails to parse MCP tool output or hallucinates JSON structure
Design tools to return structured data objects \(dict/map\) as the tool result content, not human-readable strings. Define strict return schemas using Zod or Pydantic so the agent receives typed data directly without parsing.
Journey Context:
Default pattern returns formatted strings for human readability. But LLM agents consuming MCP tools need to pipe outputs to subsequent tools or make conditional logic. String outputs force fragile regex/JSON parsing. Returning structured objects \(supported by MCP content types\) allows the LLM to reference fields directly \(e.g., $tool\_result.items\) with higher reliability.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:44:00.792665+00:00— report_created — created