fix(client): add extra_headers escape hatch for multi-tenant servers#585
Merged
fix(client): add extra_headers escape hatch for multi-tenant servers#585
Conversation
AgentConfig only exposed a single auth header, so SDK callers couldn't attach the additional routing headers some servers require (e.g. x-adcp-tenant on multi-tenant MCP). Adds a transport-layer extra_headers dict on AgentConfig, plumbed through both MCP and A2A adapters, with a matching CLI -H/--header flag and ~/.adcp/config.json field. Validates against CR/LF/NUL injection and rejects collisions with the configured auth_header / standard Authorization. Documents the field as a transport escape hatch — protocol-level fields belong in RequestContext.metadata, not arbitrary headers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 5, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
AgentConfigonly exposed a single auth header, so SDK callers couldn't attach the additional routing headers some servers require (e.g.x-adcp-tenanton multi-tenant MCP servers like salesagent). Adds a transport-layerextra_headersdict onAgentConfig, plumbed through both MCP and A2A adapters, with a matching CLI-H/--headerflag and~/.adcp/config.jsonfield.Changes
AgentConfig.extra_headers: dict[str, str](validated against CR/LF/NUL injection; rejects collisions with the configuredauth_headerand standardAuthorization)extra_headersinto the headers dict for bothstreamable_httpandssetransportshttpx.AsyncClient.headers(covers both agent-card discovery and RPC sends)-H KEY=VALUE(repeatable). With--save-authit persists into the saved config; at runtime it merges over saved-config headers (CLI wins on conflict).--list-agentsshows persisted header keys (not values).RequestContext.metadataor the request envelope.Reviewer feedback applied
Spawned
code-reviewer,ad-tech-protocol-expert, anddx-expertbefore opening. Convergent fixes incorporated:auth_headervalue on collisionmerge_headershelper extracted for testability)Reviewer divergence (deliberately not adopted):
x-adcp-*prefix would block the actual user flow (x-adcp-tenantis what salesagent reads); the right fix is for salesagent to rename to a vendor-namespaced prefix, not for the SDK to refuse the request. Documented the namespace concern in the docstring.:as a separator (curl-style) deferred — keep one canonical form for now.Test plan
ruff checkcleanmypy src/adcp/cleanparse_header_argsparsing,merge_headersprecedence, MCPstreamable_http+ssepass-through, A2A httpx-client pass-through, and saved-config persistenceUsage
🤖 Generated with Claude Code