fix: unblock the MCP session, and authenticate to the AI gateway with OIDC

Two things, both discovered by instrumenting the failure rather than trusting
the message it printed.

The MCP session never failed on protocol. macOS resolves any `.local` name
through mDNS first and takes a flat ~5.0s doing it, which sits exactly on
httpx's 5s default connect timeout; fastmcp reported the resulting
ConnectTimeout only as "Failed to initialize server session". Earlier tests
used `curl --resolve`, which bypasses DNS entirely and made it look like DNS
had been eliminated. Settings.http_timeout (60s) now covers the shared client,
the client fastmcp builds, and MCPToolset's init_timeout. list-products,
get-product and create-product now enumerate over the real gateway.

Inference used a static "unused" api_key against a gateway whose
openid-connect plugin requires audience ["llm-proxy"]. The model call now
carries a token exchanged for llm-proxy-audience, so it is attributable to the
same (agent, end user) pair as every tool call.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Stéphane Tailland
2026-08-28 11:01:18 +02:00
parent 4fd6e21a40
commit 0bc06512f5
6 changed files with 59 additions and 6 deletions
+15
View File
@@ -53,3 +53,18 @@ blockers. This file only covers what is specific to this agent.
- **A2A calls return answers, not data.** Expose narrow decision-shaped skills,
never a generic `query`.
- Deliverables in English.
## Running it against the lab from macOS
macOS resolves every `.local` name through mDNS before falling back to
`/etc/hosts`, and that costs a **flat ~5.0s per hostname** — `dscacheutil -q host
-a name catalog-dev.sttlab.local` shows it, and so does `curl -w
%{time_namelookup}`. httpx's default connect timeout is 5s, so the very first
request to each host lands on the boundary and fails intermittently. fastmcp
reports that as `Failed to initialize server session` and swallows the cause,
which is why it read as an MCP protocol problem for a long time. `curl --resolve`
hides it completely — do not use `--resolve` to "prove" DNS is fine.
`Settings.http_timeout` (60s) is the fix, applied to the shared httpx2 client,
to the client fastmcp builds, and to `MCPToolset(init_timeout=...)`. In the
cluster these names resolve instantly and the timeout never binds.