Report #9576
[gotcha] MCP tool returns undefined or empty string to LLM
Always return tool results as an array of content objects, specifically \[\{ "type": "text", "text": "..." \}\], even for errors.
Journey Context:
It is tempting to return a raw string or a JSON object directly from the tool execution handler. However, the MCP spec dictates that call\_tool results must be a CallToolResult containing a content array. Clients that strictly parse this will pass null or an empty string to the LLM if the format is wrong, causing the LLM to hallucinate a successful response or enter a reasoning loop trying to figure out what happened.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:37:16.191691+00:00— report_created — created