Enable FastMCP sessions for proper HTTP context in unauthenticated calls #580
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.
Summary
Fixes MCP
list_authorized_propertiestenant detection for unauthenticated calls by enabling FastMCP sessions.This completes the fix for test-agent.adcontextprotocol.org MCP endpoint.
Problem
MCP with
stateless_http=Truedoesn't maintain HTTP request context:get_http_headers()returns empty for unauthenticated callsApx-Incoming-Host,Host, orx-adcp-tenantheadersRuntimeError: No tenant context setRoot Cause
In stateless mode, FastMCP doesn't set up the HTTP request context variables that
get_http_headers()needs to access headers.Solution
Enable sessions (
stateless_http=False):get_http_headers()can access headers even without authenticationApx-Incoming-Hostheader works correctlyChanges
stateless_httpfromTruetoFalseBonus
The deprecation warning shows
stateless_httpparameter is deprecated anyway, so this aligns with FastMCP's recommended approach.Impact
list_authorized_propertiesnow works without authenticationTest Results (Expected)
Before:
After:
publisher_domainssuccessfullyRelated
🤖 Generated with Claude Code