Skip to content

Support custom request headers in server config (TOML) #82

Description

@alDuncanson

Summary

Handler can attach custom headers to requests only programmatically (AuthCredentials.custom_headers); there's no way to set arbitrary per-server headers from the config TOML (or CLI/TUI). Add a [servers.<name>.headers] table so users can attach static custom headers to every request to a server.

Motivation

Many A2A servers key behavior off custom request headers that aren't auth credentials — e.g. a per-user memory scope (X-Remy-User), tenant ids, feature flags, or trace ids. Today setting one requires code; config-level support makes it usable straight from the CLI/TUI.

Concretely: I gave an A2A agent (Remy, on Cloud Run) per-user long-term memory keyed off an X-Remy-User header, and wanted to set it per-server in Handler config rather than editing code.

Proposed config

[servers.remy]
url = "http://localhost:8080/a2a-local"

[servers.remy.headers]
X-Remy-User = "alice"
X-Trace-Id  = "abc123"

These merge into the outgoing request headers for both agent-card fetch and message send. Precedence: auth headers (from [servers.<name>.auth]) win on conflict — or document whichever you choose. Consider supporting env:VAR value resolution to match the auth config's env pattern.

Implementation notes

  • Extend ServerDefinition (+ TOML parsing) in src/a2a_handler/servers.py with an optional headers: dict[str, str].
  • Apply them where auth headers are set on the httpx client (src/a2a_handler/service.py, around _apply_auth_headers / http_client.headers.update).
  • Surface them (read/edit) in the TUI Headers tab.

Related

Complements #81 (native GCP/Cloud Run auth): headers cover non-credential app-level context; #81 covers verified identity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions