That’s a very useful observation and it clarifies the issue further.
Since the agent card URLs do include the prefix when you access the server directly (without a proxy), the Agent Server is using MOUNT_PREFIX to construct URLs correctly. The problem is that something in the proxy setup overrides or bypasses this mechanism.
The most likely cause: your Traefik configuration is stripping the path prefix before forwarding the request to the server.
If you’re using Traefik’s stripPrefix middleware (JUST THINKING ABOUT A POSSIBILITY):
middlewares:
strip-agent-server:
stripPrefix:
prefixes:
- "/api/agent-server"
Then here’s what happens:
Client request: GET /api/agent-server/.well-known/agent-card.json
↓
Traefik strips: GET /.well-known/agent-card.json ← prefix removed
↓
Server receives: /.well-known/agent-card.json
Server sees no prefix in the request path,
so it generates URLs WITHOUT the prefix
When you hit the server directly (no proxy), the request arrives at /api/agent-server/.well-known/agent-card.json — the server sees the full path including the prefix it mounted via MOUNT_PREFIX, so it generates correct URLs.
The fix: Since MOUNT_PREFIX makes the server expect and serve routes under /api/agent-server/..., you should not strip the prefix in Traefik. Pass the full path through:
http:
routers:
agent-server:
rule: "PathPrefix(`/api/agent-server`)"
service: agent-server
# No stripPrefix middleware
services:
agent-server:
loadBalancer:
servers:
- url: "http://agent-server:8000"
This way the request arrives at the server with the full path intact, MOUNT_PREFIX matches it, and the generated agent card URLs will include the prefix – just like when you access the server directly.
TL;DR: MOUNT_PREFIX handles both routing and URL generation, but only when it sees the prefix in the incoming request path. If the proxy strips it, the server falls back to prefix-less URL generation. Remove stripPrefix from your Traefik config and let MOUNT_PREFIX handle everything.