The best error message you can return from an MCP tool isn't a stack trace—it's a corrective hint telling the agent what to try next
Look at how most developers write error handling inside an MCP tool:
pythonif not is_valid_date(start_date): raise ValueError("Invalid date")
When the MCP server serializes that into {"isError": true, "content": [{"text": "ValueError: Invalid date"}]}, the LLM has no idea what format you wanted. Half the time it tries "11-27-2026", then "Nov 27, 2026", burning 3 turns and $0.15 in tokens before giving up.
Treat MCP Errors Like Compiler Diagnostics for LLMs
Return actionable corrective hints directly inside the isError: true payload:
- Bad:
"404 User not found" - Good:
"User 'j.doe' not found. Did you pass a username instead of a UUID? Call search_users(query='j.doe') first to resolve the user_id."
A 1-sentence corrective hint turns a dead-end 3-retry failure into a 1-turn self-healing recovery.