Skip to content

fix(server): populate RequestMetadata.request_context on the A2A path (MCP parity) #1008

Description

@numarasSigmaSoftware

RequestMetadata carries a request_context field documented as the way a context_factory reads request-scoped state set by middleware. The MCP path populates it; the A2A path does not, so a context_factory on A2A cannot see the incoming request at all.

# adcp/server/serve.py — MCP path populates it
2516:                request_context=request_context,

# adcp/server/a2a_server.py — A2A path omits it
381:        meta = RequestMetadata(
382:            tool_name=skill_name,
383:            transport="a2a",
384:            request_id=request.task_id,
385:        )
386:        ctx = self._context_factory(meta)

Verified against 6.6.0 and v7.0.0-rc (the module is byte-identical between the two): a factory receiving meta sees request_context is None on every A2A request.

Impact. Any header-derived context is unreachable through the documented seam on A2A — deployment-specific auth headers, tenant hints, and test-mode headers alike. The available workaround is a ContextVar populated by an outer ASGI middleware and read inside the factory. That does work on A2A today (dispatch runs in the same asyncio task as the middleware, as auth.py:1449-1456 notes), but it is fragile by the SDK's own caveat there: it breaks if A2A ever grows a decoupled dispatch task. Adopters shouldn't have to depend on that coupling when the field already exists.

Proposed change. Thread the Starlette Request (or the ServerCallContext carrying it) into RequestMetadata at a2a_server.py:381-385, matching the MCP path.

Unrelated docs nit, same area: the docstring at a2a_server.py:1022-1028 states that PushNotificationConfigStore "does not pass a ServerCallContext" to set_info/get_info/delete_info and recommends a ContextVar workaround. Against the installed a2a-sdk==1.0.1 all three methods do take context: ServerCallContext, so the workaround is unnecessary and the advice misleads adopters into weaker scoping than the ABC supports.

Happy to open the PR for both.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions