# Spike results — Spring Boot bump + MCP Streamable HTTP ↔ TS SDK

Run 2026-09-09 (global build step 0b, [`../contracts.md §0`](../contracts.md)). Throwaway code
in `scratchpad/spike/` (not committed). **Verdict: GO.** The transport seam works; the version
picture changed since `architecture.md §9` was written and is corrected below.

## What was tested

| Task | Result |
|---|---|
| 1. Spring Boot bump + Spring AI MCP starter compiles/boots on JDK 21 | ✅ `spring-boot-starter-parent 3.5.13` + `spring-ai-bom 1.1.8` + `spring-ai-starter-mcp-server-webmvc`, `--release 21`, boots clean (`Registered tools: 1`, Tomcat 8081) |
| 2. Trivial MCP server, one tool, Streamable HTTP at `/mcp` | ✅ `@Tool`-annotated method + `MethodToolCallbackProvider`; `spring.ai.mcp.server.protocol=STREAMABLE`, `streamable-http.mcp-endpoint=/mcp` |
| 3. TS `@modelcontextprotocol/sdk` client calls it | ✅ `@modelcontextprotocol/sdk@1.30.0`, `StreamableHTTPClientTransport` → `connect` + `tools/list` (`[ping]`) + `tools/call ping` (`{"reply":"pong","echo":…}`) all succeed |
| 4. Attach a fresh per-request header pair (the DPoP hook) | ✅ TS transport `fetch` option — wrap `fetch`, inject `Authorization: DPoP …` + `DPoP: … jti=<uuid> bsha=<sha256(body)>` per call. Server-side servlet filter confirms it **receives** them on every request (POST initialize, POST initialized, GET stream, POST tools/list, POST tools/call), each with a unique `jti` |

## Version coordinates — pin these (supersede `architecture.md §9`)

> These pins are for **our fake PDS only** — the fastest way to stand up a demo bank. They are
> **not** a product constraint on real providers: MCP is a wire protocol (JSON-RPC over
> Streamable HTTP), so a real PDS can expose it via the MCP Java SDK directly, a sidecar/gateway
> in front of an unchanged legacy app, or any other stack. Our actual ask of a PDS — verify our
> JWT + DPoP in a request filter — has no Spring AI dependency at all.

| Component | Use | Not |
|---|---|---|
| `spring-boot-starter-parent` | **`3.5.13`** (latest 3.5.x at spike time; 3.5.x is the line Spring AI 1.1.x targets) | ~~3.3.x / 3.4.x~~ — too old for Spring AI 1.1; **not** 4.x |
| `spring-ai-bom` | **`1.1.8`** (imported `<dependencyManagement>`) | **not** `2.0.x` — Spring AI 2.0 pulls **Spring Boot 4.1**, a major migration the POC doesn't need |
| `spring-ai-starter-mcp-server-webmvc` | version from the BOM (`1.1.8`) | |
| MCP Java SDK (transitive) | `io.modelcontextprotocol.sdk:mcp-core` / `mcp-spring-webmvc` **`0.18.3`** — its own POM says *"Web MVC implementation for the SSE and Streamable Http Server transports"* | |
| TS client | `@modelcontextprotocol/sdk` **`1.30.0`** | |
| JDK | **21** target compiles fine (spike host ran JDK 25); Raul's WSL2 box has 21 | |
| Maven | spike used 3.8.7 with no issue; `architecture.md §12.0` still recommends 3.9.x | |

## Protocol shape — this is the important correction

Both sides' **latest is `2025-11-25`**, and that is what they negotiate:
`@modelcontextprotocol/sdk@1.30.0` has `LATEST_PROTOCOL_VERSION = '2025-11-25'`; the MCP Java
SDK 0.18.3 server implements `2025-11-25` (and accepts `2025-06-18`). Neither implements the
newest **`2026-07-28`** revision yet — a client that asks for `2026-07-28` is **gracefully
downgraded**: the server logs *"unsupported protocol version: 2026-07-28, so the server will
suggest the 2025-11-25 version instead"* and returns `2025-11-25` in the `initialize` result.

So the POC runs the **session-scoped Streamable HTTP shape** (`2025-11-25`), *not* the
sessionless `2026-07-28` shape the spec's main transport page now describes. Concretely:

| Observed | Consequence for the PDS isolated filter ([`spec.md §9`](spec.md)) |
|---|---|
| Server issues `Mcp-Session-Id` on `initialize`; client echoes it on every later request | The filter runs per HTTP request and is stateless w.r.t. MCP sessions — fine — but must **not** reject a request for carrying / not carrying `Mcp-Session-Id` |
| There is a real **`GET /mcp`** — it opens the SSE event stream, session-bound | ✏️ `spec.md §9` said "`GET /mcp` = discovery handshake, `permitAll`". **Wrong.** `GET /mcp` is the SSE stream and it carries our `Authorization`/`DPoP` headers too — authenticate it like the POSTs (or, if we adopt `protocol=STATELESS`, there is no GET stream — see below) |
| The **first** POST (`initialize`) arrives with **no** `MCP-Protocol-Version` header and no session id | The filter must tolerate the first POST lacking `MCP-Protocol-Version`; don't hard-require that header |
| `tools/list` requires an established session (`initialize` first) | The stub's `/discover` proxy must do `initialize` → `tools/list`, not a bare `tools/list` (already stated in [`../contracts.md §5.2`](../contracts.md)) |

### Option to simplify: `protocol=STATELESS`

Spring AI also exposes `spring.ai.mcp.server.protocol=STATELESS`. Not tested in the spike, but
worth a 1-hour evaluation at **build step 4**: stateless mode drops the session id and the GET
stream (closer to the `2026-07-28` shape), which makes the isolated filter's job simpler — every
request is an independent authenticated POST, nothing to special-case. Only adopt it if
`tools/list` + `tools/call` still work from the TS client without a session (they should).

## Per-request auth hook — confirmed pattern for the Outil Local

TS side ([`../outil-local/spec.md §4.3`](../outil-local/spec.md)):

```js
const transport = new StreamableHTTPClientTransport(new URL(PROVIDER_API_ENDPOINT), {
  fetch: async (url, init = {}) => {
    const body = typeof init.body === "string" ? init.body : "";
    const proof = await buildDpopProof({ htu: url, htm: init.method ?? "GET", body });
    const headers = new Headers(init.headers);
    headers.set("Authorization", `DPoP ${AGENT_DELEGATION_TOKEN}`);
    headers.set("DPoP", proof);
    return fetch(url, { ...init, headers });
  },
});
```

The `fetch` option wraps **every** transport request (POSTs and the GET stream), so a fresh
proof per call is straightforward. `requestInit.headers` also exists but is static — use `fetch`.

## Follow-ups (not blockers)

- `spec.md §9`: fix the `GET /mcp` handling per the table above; evaluate `STATELESS` at step 4.
- `contracts.md §2`: note the negotiated protocol is `2025-11-25` and `Mcp-Session-Id` may be
  present; `htu` canonicalisation unchanged.
- Nimbus Ed25519 verification (the other `spec.md §9` spike caveat) is unrelated to transport —
  verify separately when building the filter.
- Watch for a future Spring AI release that implements MCP `2026-07-28`; adopting it later is a
  version bump, not a redesign (the negotiation downgrade already proves the fallback path).
