Skip to content

bug(server): AdcpError raise path bypasses context-echo on MCP and A2A error envelopes #557

@bokelley

Description

@bokelley

Bug

The MCP and A2A error paths build the structured adcp_error envelope but never echo the request's context extension into the response. The success paths do echo it (inject_context in mcp_tools.py:2030), so any handler that raises AdcpError produces a response that violates the AdCP context-echo contract — buyers lose correlation IDs, idempotency hints, and other agent-to-agent state.

Repro

A handler calls raise AdcpError('PERMISSION_DENIED', message='nope'). The wire response carries structuredContent.adcp_error but no top-level context field, even though the request supplied one.

Affected paths

  • MCP: src/adcp/server/serve.py:1787-1804except ADCPError and the decisioning-AdcpError branch both call build_mcp_error_result(exc) without passing kwargs (the raw params).
  • A2A: src/adcp/server/a2a_server.py:237_send_adcp_error is invoked with (event_queue, context, exc) but not the parsed request params that carry the wire context extension.
  • Builders: src/adcp/server/translate.py:167 (build_mcp_error_result) and src/adcp/server/a2a_server.py:426 (_send_adcp_error) take exc only, with no surface to receive raw request params.

Symptom

Three storyboard runners fail on the AdcpError-raise path because the asserted echoed-context fields are missing from error responses.

Fix

  1. Plumb raw params into the error-result builders on both transports.
  2. After building the structured envelope, run inject_context(raw_params, envelope) so the context field is echoed at the same level the success path uses.
  3. Add tests covering both transports' error path with and without a request context field.

Plan to land as a single PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingclaude-triagedno-triageSkip the Claude triage bot — human or designated agent will handle this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions