Skip to content

Conversation

@bokelley
Copy link
Contributor

Summary

Completes the fix for test-agent.adcontextprotocol.org by enabling MCP list_authorized_properties to work without authentication.

This is the second part of the fix - PR #577 fixed A2A, this fixes MCP.

Problem

When list_authorized_properties is called via MCP without an auth token:

  • context parameter is None
  • get_principal_from_context() had early return when context=None → returned (None, None)
  • Tool couldn't detect tenant from headers → "No tenant context set" error

Solution

Remove the early return in get_principal_from_context() when context=None:

  • get_http_headers() uses FastMCP context variables internally, works without context object
  • Tenant can be detected from headers (Apx-Incoming-Host, Host, x-adcp-tenant)
  • Returns (None, tenant_context) for unauthenticated public discovery calls

Changes

src/core/main.py:

  • Removed early return if not context: return (None, None)
  • Added comment explaining get_http_headers() works via context vars
  • Allows unauthenticated calls to detect tenant from HTTP headers

Impact

  • ✅ MCP list_authorized_properties now works without authentication
  • ✅ Tenant properly detected from virtual host headers
  • ✅ Matches A2A behavior (both protocols support unauthenticated discovery)
  • ✅ Completes test-agent.adcontextprotocol.org fix

Test Results (Expected)

Before:

After (both PRs):

  • ✅ Test Agent A2A: Returns publisher_domains ✅ VERIFIED
  • ✅ Test Agent MCP: Returns publisher_domains ⏳ PENDING DEPLOYMENT

Related

🤖 Generated with Claude Code

Allow get_principal_from_context() to work even when context=None by removing
early return. The function can still detect tenant via get_http_headers() which
uses FastMCP context variables internally.

This fixes MCP calls to list_authorized_properties without authentication,
matching the A2A behavior fixed in the previous commit.

Before: context=None → early return (None, None) → tenant detection failed
After: context=None → try get_http_headers() → detect tenant from Apx-Incoming-Host

Impact:
- MCP list_authorized_properties now works without auth token
- Tenant detected from HTTP headers (Apx-Incoming-Host, Host, x-adcp-tenant)
- Matches A2A behavior (both protocols now support unauthenticated discovery)

Testing: Will verify with test-agent.adcontextprotocol.org MCP endpoint
@bokelley bokelley merged commit b21672b into main Oct 24, 2025
8 checks passed
bokelley added a commit that referenced this pull request Oct 24, 2025
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.
EmmaLouise2018 pushed a commit that referenced this pull request Oct 24, 2025
…578)

Allow get_principal_from_context() to work even when context=None by removing
early return. The function can still detect tenant via get_http_headers() which
uses FastMCP context variables internally.

This fixes MCP calls to list_authorized_properties without authentication,
matching the A2A behavior fixed in the previous commit.

Before: context=None → early return (None, None) → tenant detection failed
After: context=None → try get_http_headers() → detect tenant from Apx-Incoming-Host

Impact:
- MCP list_authorized_properties now works without auth token
- Tenant detected from HTTP headers (Apx-Incoming-Host, Host, x-adcp-tenant)
- Matches A2A behavior (both protocols now support unauthenticated discovery)

Testing: Will verify with test-agent.adcontextprotocol.org MCP endpoint
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
…dcontextprotocol#578)

Allow get_principal_from_context() to work even when context=None by removing
early return. The function can still detect tenant via get_http_headers() which
uses FastMCP context variables internally.

This fixes MCP calls to list_authorized_properties without authentication,
matching the A2A behavior fixed in the previous commit.

Before: context=None → early return (None, None) → tenant detection failed
After: context=None → try get_http_headers() → detect tenant from Apx-Incoming-Host

Impact:
- MCP list_authorized_properties now works without auth token
- Tenant detected from HTTP headers (Apx-Incoming-Host, Host, x-adcp-tenant)
- Matches A2A behavior (both protocols now support unauthenticated discovery)

Testing: Will verify with test-agent.adcontextprotocol.org MCP endpoint
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