Fix every MCP tool call failing: drop fastmcp 3.x include= kwarg#14
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every tool call to the deployed AgentMCP server returns a generic
{"error": "internal error", "correlation_id": ...}. CloudWatch (/ecs/AgentMCP) shows the real cause: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 theauthorizationheader by default. Theinclude=kwarg used to recover it only exists in fastmcp 3.x, butpyproject.tomlpinsfastmcp==2.12.4, which is what CI (buildspec.ymlregenerates the lock frompyprojecton each build) installs and deploys. Local dev drifted to fastmcp 3.2.4 whereinclude=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-authorizationx-inmydata-*headers are not stripped byget_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.pypasses.get_http_headers/include=.buildspec.ymlpre-build before the image is built.Deployment path
Merge into
Development, then mergeDevelopment→Productionto trigger the ECS build/deploy.🤖 Generated with Claude Code