[BUG] Claude Code with Bedrock fails to function if an MCP is added that has a tool property called `max_tokens`

Resolved 💬 2 comments Opened Jul 11, 2025 by deconduino Closed Aug 5, 2025

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [X] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.44
  • Operating System: All
  • Terminal: <!-- e.g. iTerm2, Terminal App -->

Bug Description

Claude Code with Bedrock fails to function if an MCP is added that has a tool property called max_tokens

Steps to Reproduce

  1. Add an MCP that has a tool property called max_tokens
  2. Start Claude Code in Bedrock mode
  3. Make any request

Expected Behavior

Claude Code functions as normal

Actual Behavior

All requests fail with a 400 error

Additional Context

The actual issue is with AWS Bedrock API where if max_tokens appears nested in an API request anywhere before the top level max_tokens which is part of the schema, the schema validation fails and the request is rejected. This has been reported to AWS as a bug, but a quick fix is possible within Claude Code itself.

The quick fix is to ensure the max_tokens parameter is sent at the top of the payload when using Bedrock APIs before the tools payload.

Examples

The request below will fail:

{
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "What time is it?"
                }
            ]
        }
    ],
    "tools": [
        {
            "name": "mcp_test",
            "description": " Test Tool.",
            "input_schema": {
                "type": "object",
                "properties": {
                    "max_tokens": {
                        "description": "Maximum number of tokens in the response",
                        "type": "number"
                    }
                }
            }
        }
    ],
    "max_tokens": 8000
}

This will succeed:

{
   "max_tokens": 8000, 
   "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "What time is it?"
                }
            ]
        }
    ],
    "tools": [
        {
            "name": "mcp_test",
            "description": " Test Tool.",
            "input_schema": {
                "type": "object",
                "properties": {
                    "max_tokens": {
                        "description": "Maximum number of tokens in the response",
                        "type": "number"
                    }
                }
            }
        }
    ]
}

View original on GitHub ↗

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