Skip to content

feat(client): add extra_headers to AgentConfig and --header to CLI#584

Closed
bokelley wants to merge 2 commits intomainfrom
claude/issue-583-extra-request-headers
Closed

feat(client): add extra_headers to AgentConfig and --header to CLI#584
bokelley wants to merge 2 commits intomainfrom
claude/issue-583-extra-request-headers

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

@bokelley bokelley commented May 5, 2026

Closes #583

Summary

Adds AgentConfig.extra_headers (dict[str, str] | None) so callers can pass routing and context headers — like x-adcp-tenant for multi-tenant platforms — alongside auth_token. Plumbed through both MCP and A2A transport layers. Auth always wins on conflict (with a logger.warning). The --header KEY=VALUE CLI flag (repeatable, -H alias) is persisted via --save-auth and honoured on subsequent invocations.

Before:

# No equivalent — required raw fastmcp.client transport
transport = StreamableHttpTransport(
    url="http://localhost:8000/mcp/",
    headers={"x-adcp-auth": token, "x-adcp-tenant": tenant_id},
)

After:

config = AgentConfig(
    id="verify",
    agent_uri="http://localhost:8000/mcp/",
    protocol=Protocol.MCP,
    auth_token=token,
    extra_headers={"x-adcp-tenant": tenant_id},
)
adcp myagent get_products --header x-adcp-tenant=acme
adcp --save-auth local http://localhost:8000/mcp mcp --header x-adcp-tenant=acme

What was tested

  • pytest tests/test_client.py tests/test_cli.py — all 97 passed (15 new tests added)
  • Full suite: 2355 passed, 22 skipped (1 pre-existing network flake: test_real_tls_handshake_still_validates_hostname hits example.com)
  • ruff check src/: all checks passed
  • mypy src/adcp/types/core.py src/adcp/config.py src/adcp/__main__.py: no new errors (pre-existing missing-stub errors are infrastructure-wide, not introduced here)

Known nits (not fixed, surfaced by pre-PR review)

  • extra_headers or None in handle_save_auth is redundant (harmless, parse_header_args already returns None for empty input)
  • MCP adapter uses auth_header (e.g. x-adcp-auth) for both token and bearer auth types; A2A uses Authorization for bearer. This asymmetry predates this PR. A conflict warning on MCP+bearer only fires if the user's extra_headers key matches auth_header (not "Authorization").
  • Warning messages between adapters differ slightly: MCP says "conflicts with auth_header", A2A says "conflicts with auth header".
  • No adapter-level test asserting extra_headers values reach the outgoing httpx.AsyncClient headers kwarg (future integration test opportunity).

Pre-PR review:

  • code-reviewer: approved after fix — two blockers resolved: null-byte added to injection guard, CRLF validation moved to parse_header_args so --save-auth path is protected before config write
  • dx-expert: approved — field name extra_headers matches webhooks.py convention; partition("=") correctly handles base64 values; CLI error messages actionable; --list-agents shows key names only (correct for security)

Triage-managed PR. This bot does not currently iterate on
review comments or PR conversation threads (only on the source
issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num>
    fix → push.
  • Or re-trigger: comment /triage execute on the source
    issue.

See adcp#3121
for context.

Session: https://claude.ai/code/session_01PACTmRta6eyqmZkaAwBpnF


Generated by Claude Code

claude added 2 commits May 5, 2026 12:06
Adds AgentConfig.extra_headers (dict[str, str] | None) so callers
can pass routing and context headers like x-adcp-tenant alongside
auth_token. Auth wins on conflict with a logged warning. The
--header KEY=VALUE CLI flag (repeatable, -H alias) is persisted via
--save-auth and honoured on load. Plumbed through both MCP and A2A
adapters.

Closes #583

https://claude.ai/code/session_01PACTmRta6eyqmZkaAwBpnF
…arse time

Both blockers from pre-PR review: extend CRLF guard to cover \x00
(matching webhooks._HEADER_FORBIDDEN_CHARS), and run the same check
inside parse_header_args so --save-auth cannot persist poisoned headers
to config.json before AgentConfig construction.

https://claude.ai/code/session_01PACTmRta6eyqmZkaAwBpnF
@gitguardian
Copy link
Copy Markdown

gitguardian Bot commented May 5, 2026

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
32486128 Triggered Bearer Token 765e48b tests/test_cli.py View secret
32486128 Triggered Bearer Token 765e48b tests/test_cli.py View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@bokelley
Copy link
Copy Markdown
Contributor Author

bokelley commented May 5, 2026

Superseded by #585 (merged in 66b7456). Closing as duplicate.

@bokelley bokelley closed this May 5, 2026
@bokelley
Copy link
Copy Markdown
Contributor Author

bokelley commented May 5, 2026

Acknowledged — noted that #585 landed and supersedes this draft. Nothing further needed on this PR.


Triaged by Claude Code. Session: https://claude.ai/code/session_01Lr5c2q1r21kjDiBaiar5Wy


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client/CLI lacks support for extra request headers (e.g. x-adcp-tenant)

2 participants