Skip to content

Conversation

@bokelley
Copy link
Contributor

Problem

After enabling FastMCP sessions () in PR #580, Test Agent MCP endpoint began failing with "Unknown error" while A2A continued working.

Root Cause Analysis

  1. FastMCP sessions require proper protocol flow: Session-based mode expects:

    • Initial handshake/discovery request
    • Session establishment
    • Tool calls with session ID included
  2. Current MCP clients don't implement session management: The ADCPClient and test scripts call tools directly without establishing sessions first

  3. Errors occur at protocol layer: The failure happens in FastMCP's HTTP transport layer before our tool code executes, which is why no errors appear in application logs

  4. get_http_headers() doesn't need sessions: This function works via context variables (contextvars) which FastMCP provides in both stateless and session-based modes

Solution

Revert to stateless_http=True (the previous working state) while keeping all context safety improvements from PRs #577, #578, and #580.

What This Fixes

  • ✅ Test Agent MCP now works (protocol compatibility restored)
  • ✅ Test Agent A2A continues working (no change needed)
  • ✅ Wonderstruck MCP/A2A continue working
  • ✅ Tenant detection from headers still works via get_http_headers()

What's Preserved

  • ✅ Context safety checks (context=None handling)
  • ✅ MinimalContext for unauthenticated A2A calls
  • ✅ Header access via get_http_headers(include_all=True)

Testing

  • All unit tests pass (846 passed)
  • All integration tests pass (174 passed)
  • Pre-commit hooks pass
  • Manual test: Run test-list-properties.ts after deployment

References

The session-based mode (stateless_http=False) introduced in PR #580
causes protocol compatibility issues with MCP clients, resulting in
'Unknown error' failures.

Analysis:
- FastMCP sessions require proper session establishment flow
- Current MCP clients don't implement session management
- Errors occur at protocol layer before our code executes
- get_http_headers() works via context vars regardless of session mode

Solution:
- Revert to stateless_http=True (previous working state)
- Keep all context safety fixes from PRs #577, #578, #580
- get_http_headers(include_all=True) still works for tenant detection

This maintains A2A functionality while fixing MCP protocol compatibility.
@bokelley bokelley closed this Oct 25, 2025
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.

2 participants