Bug or Hallucination in MCP tool use

Resolved 💬 3 comments Opened Aug 28, 2025 by JamesKiddSmyth Closed Sep 1, 2025

I've seen OAI's GPT models hallucinate non-existent function calls, but I've never developed against the Claude MCP API. So I don't have a sense for how easy it is for Claude to generate bad responses in the tooling. But, I'm seeing something like the following in Claude Code, and actually it breaks the session, b/c it continues to send this malformed tool_use input in the history, and the API continues to choke on its own vomit.

{
  "model": "claude-sonnet-4-20250514",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "Can you check the git status?"
    },
    {
      "role": "assistant",
      "content": [
        {
          "type": "text",
          "text": "I'll check the git status for you."
        },
        {
          "type": "tool_use",
          "id": "toolu_01J7K9mXyZ3nF4pQR8vS2aBC",
          "name": "execute_command",
          "input": "git status"  // ❌ THIS IS THE PROBLEM - should be {"command": "git status"}
        }
      ]
    }
  ],
  "tools": [
    {
      "name": "execute_command",
      "description": "Execute a shell command",
      "input_schema": {
        "type": "object",
        "properties": {
          "command": {
            "type": "string",
            "description": "The command to execute"
          }
        },
        "required": ["command"]
      }
    }
  ]
}

400 response from API:


{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "messages.1.content.1.tool_use.input: Input should be a valid dictionary"
  }
}

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗