Skip to content

Fix every MCP tool call failing: drop fastmcp 3.x include= kwarg#14

Merged
garyslamb merged 1 commit into
Developmentfrom
fix/oauth-header-fastmcp-compat
Jun 2, 2026
Merged

Fix every MCP tool call failing: drop fastmcp 3.x include= kwarg#14
garyslamb merged 1 commit into
Developmentfrom
fix/oauth-header-fastmcp-compat

Conversation

@garyslamb

Copy link
Copy Markdown
Collaborator

Problem

Every tool call to the deployed AgentMCP server returns a generic {"error": "internal error", "correlation_id": ...}. CloudWatch (/ecs/AgentMCP) shows the real cause:

TypeError: get_http_headers() got an unexpected keyword argument 'include'
  File "/app/server_remote.py", line 189, in utils
    headers = get_http_headers(include={"authorization"})
RuntimeError: Error initializing mcp_utils

utils() throws on its first line in the OAuth branch — before any tenant/user resolution — so every tool call fails identically.

Root cause

get_http_headers() strips the authorization header by default. The include= kwarg used to recover it only exists in fastmcp 3.x, but pyproject.toml pins fastmcp==2.12.4, which is what CI (buildspec.yml regenerates the lock from pyproject on each build) installs and deploys. Local dev drifted to fastmcp 3.2.4 where include= exists, so the bug never reproduced locally — only in the container.

Fix

Read the bearer token directly from get_http_request().headers, which works on 2.12.4 and 3.x alike. The non-authorization x-inmydata-* headers are not stripped by get_http_headers(), so the no-arg call still serves them. Version-agnostic, minimal, keeps the proven pinned runtime.

Validation

  • python -m py_compile server_remote.py passes.
  • No tests assert on get_http_headers / include=.
  • CI runs the pytest gate in buildspec.yml pre-build before the image is built.

Deployment path

Merge into Development, then merge DevelopmentProduction to trigger the ECS build/deploy.

🤖 Generated with Claude Code

…kwarg

Every MCP tool call failed in the deployed server with:
  TypeError: get_http_headers() got an unexpected keyword argument 'include'

utils() called get_http_headers(include={"authorization"}) to recover the
authorization header (get_http_headers strips it by default). The include=
parameter only exists in fastmcp 3.x, but pyproject pins fastmcp==2.12.4,
which is what CI builds and deploys. Local dev happened to run fastmcp 3.2.4,
so the bug never reproduced locally.

Read the bearer token directly from get_http_request().headers instead, which
works on 2.12.4 and 3.x alike. The non-authorization x-inmydata-* headers are
not stripped, so get_http_headers() (no args) still serves them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@garyslamb
garyslamb merged commit a651858 into Development Jun 2, 2026
1 check passed
@garyslamb
garyslamb deleted the fix/oauth-header-fastmcp-compat branch June 2, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant