[BUG] MCP tool call errors are shown as `undefined` to user and model
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other:
- Claude CLI version: 0.2.107 (Claude Code)
- Operating System: Linux
- Terminal: Ghostty
Bug Description
When the model calls a tool and the tool errors, two kinda weird things happen:
Weirdness 1: the error reporting seems a little odd - first the raw tool response is shown, and then it says the error is undefined:
● Let me get all available methods for the wolfi object:
Error calling tool {
content: [
{
type: 'text',
text: 'method not selected: "wolfi"; use select_methods first'
}
],
isError: true
}
● dagger:call_method (MCP)(method: "wolfi", args: {})…
⎿ Error: Error calling tool call_method: undefined
It took me a while to realize the content above the scary red text was the actually relevant info and not for the previous call. The undefined seems like a bug.
Weirdness 2: the model also only sees undefined. Here the model calls a select_methods tool, and it errors, but the model just ignores it and doesn't realize the method wasn't actually selected.
● dagger:list_methods (MCP)()…
⎿ [
{
"name": "DaggerDev.bench",
"returns": "DaggerDevBench!"
},
… +148 lines (ctrl+r to expand)
"name": "wolfi",
"returns": "Wolfi!"
}
]
Error calling tool {
content: [
{
type: 'text',
text: 'unknown methods: [withPackage withExec]; use list_methods first'
}
],
isError: true
}
● dagger:select_methods (MCP)(methods: ["wolfi","withPackage","withExec"])…
⎿ Error: Error calling tool select_methods: undefined
Error calling tool {
content: [
{
type: 'text',
text: 'method not selected: "wolfi"; use select_methods first'
}
],
isError: true
}
● dagger:call_method (MCP)(method: "wolfi")…
⎿ Error: Error calling tool call_method: undefined
I interrogated the model a bit, without dropping any hints (I think) and it seems like it really only saw undefined:
> can you show me exactly what you saw from the failed select_methods tool call?
● Here's exactly what I saw from the failed select_methods tool call:
<function_results>
<error>Error calling tool select_methods: undefined</error>
</function_results>
The error message was simply "undefined" with no additional context or specific error details that would help diagnose the problem.
(Of course this is likely hallucinated but the odds of it omitting that info seems low if it did see it.)
Steps to Reproduce
(Sorry, hoping this is enough.)
- Configure an MCP server that has a tool you can make fail
- Prompt the model to make the doomed tool call and show you the response
> /mcp
⎿ MCP Server Status
• dagger: connected
> call select_methods with banana and show me the exact response you see
● I'll call the select_methods method with "banana" and show you the exact response.
Error calling tool {
content: [
{
type: 'text',
text: 'unknown methods: [banana]; use list_methods first'
}
],
isError: true
}
● dagger:select_methods (MCP)(methods: ["banana"])…
⎿ Error: Error calling tool select_methods: undefined
● The response shows an error: "Error calling tool select_methods: undefined"
Expected Behavior
I would expect the error to show up like this:
● dagger:call_method (MCP)(method: "wolfi")…
⎿ Error: Error calling tool call_method: method not selected: "wolfi"; use select_methods first
...and of course for the model to see the same message.
Actual Behavior
Raw response is printed for the user, and then the error message undefined is shown to the user + model.
Additional Context
n/a
Have you found a fix to this? been having issues getting any tools to work myself
This happens to me intermittently as well.
Fixed in 1.0.4
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.