Title: feat(a2a): agent-card public URL injection (X-Forwarded-Host aware) · Issue #616 · adcontextprotocol/adcp-client-python · GitHub
Open Graph Title: feat(a2a): agent-card public URL injection (X-Forwarded-Host aware) · Issue #616 · adcontextprotocol/adcp-client-python
X Title: feat(a2a): agent-card public URL injection (X-Forwarded-Host aware) · Issue #616 · adcontextprotocol/adcp-client-python
Description: Problem adcp.server.a2a_server._build_agent_card hardcodes http://localhost:{port}/ at server-init time. There's no hook for injecting a public URL. In production the bound socket is internal — the public URL comes from the load balancer...
Open Graph Description: Problem adcp.server.a2a_server._build_agent_card hardcodes http://localhost:{port}/ at server-init time. There's no hook for injecting a public URL. In production the bound socket is internal — the...
X Description: Problem adcp.server.a2a_server._build_agent_card hardcodes http://localhost:{port}/ at server-init time. There's no hook for injecting a public URL. In production the bound socket is internal —...
Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/616
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat(a2a): agent-card public URL injection (X-Forwarded-Host aware)","articleBody":"## Problem\n\n`adcp.server.a2a_server._build_agent_card` hardcodes `http://localhost:{port}/` at server-init time. There's no hook for injecting a public URL.\n\nIn production the bound socket is internal — the public URL comes from the load balancer's `X-Forwarded-Host` (or the request `Host`). Without intervention, the static localhost URL leaks into `/.well-known/agent-card.json`, and SDK clients that read the card to discover the JSON-RPC endpoint try to reach `http://localhost:8080/` from outside the container, failing every A2A request with `fetch failed`.\n\n## Workaround\n\nWe run a 190-LOC ASGI middleware (`AgentCardPublicUrlMiddleware`) that intercepts the `/.well-known/agent-card.json` response, parses the JSON body, rewrites the URL fields based on `X-Forwarded-Host`/`Host`/`X-Forwarded-Proto`, and sends the modified payload. Rewrites both top-level `url` and every `supportedInterfaces[].url`. Only rewrites loopback URLs so explicit configurations pass through.\n\nThis is brittle — buffer the response, parse JSON, mutate, re-encode, recompute `Content-Length`, forward. One bug in the buffering and discovery silently breaks.\n\n## Proposed SDK shape\n\nEither:\n\n**A) `serve(public_url=...)` kwarg** — explicit override, simplest. Adopters set it once at boot; framework uses it instead of the bound-socket URL when building the card.\n\n**B) Honour `X-Forwarded-Host` natively** — when an inbound request to `/.well-known/agent-card.json` carries `X-Forwarded-Host` (or `X-Forwarded-Proto`), the framework derives the public URL from those headers and uses them in the response. Matches HTTP-server convention; no new public API needed beyond a `trust_forwarded_headers=True` opt-in.\n\n**C) Both** — `public_url=` for static config, `X-Forwarded-Host` for dynamic deployments behind a reverse proxy.\n\n## Files\n\n- Our workaround: [core/middleware/agent_card_public_url.py](https://github.com/prebid/salesagent/blob/main/core/middleware/agent_card_public_url.py)\n- Local tracker: prebid/salesagent#103\n\n## Related\n\n- #612 (also open, just filed) — `/.well-known/agent.json` 0.3 alias 404. Solving that doesn't help with the public-URL leak; both need fixing.","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-05-10T12:18:07Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/616"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:462a692e-e4af-1428-193c-3c0c27ba7eb3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 89DE:213839:240E1C5:2E11B1F:6B01773E |
| html-safe-nonce | 6f08554a35c632c78b326e177e7075c61be5cf8e57fe1321f852367f6e69995e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OURFOjIxMzgzOToyNDBFMUM1OjJFMTFCMUY6NkIwMTc3M0UiLCJ2aXNpdG9yX2lkIjoiMjE4MDQyODIzMDc5ODk2NDU0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ef6707f3cd2af7d104e845dc8328816b76e5d6f396d7dd3dd836772fc0e38767 |
| hovercard-subject-tag | issue:4415583456 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/adcontextprotocol/adcp-client-python/616/issue_layout |
| twitter:image | https://opengraph.githubassets.com/38c2289abbabe1219f4051b2963cbb97c41d3ad71e4b351c0900486ac2a273ae/adcontextprotocol/adcp-client-python/issues/616 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/38c2289abbabe1219f4051b2963cbb97c41d3ad71e4b351c0900486ac2a273ae/adcontextprotocol/adcp-client-python/issues/616 |
| og:image:alt | Problem adcp.server.a2a_server._build_agent_card hardcodes http://localhost:{port}/ at server-init time. There's no hook for injecting a public URL. In production the bound socket is internal — the... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bokelley |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/adcontextprotocol/adcp-client-python git https://github.com/adcontextprotocol/adcp-client-python.git |
| octolytics-dimension-user_id | 221690821 |
| octolytics-dimension-user_login | adcontextprotocol |
| octolytics-dimension-repository_id | 1090305973 |
| octolytics-dimension-repository_nwo | adcontextprotocol/adcp-client-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1090305973 |
| octolytics-dimension-repository_network_root_nwo | adcontextprotocol/adcp-client-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width