Repository navigation
feat: add --protocol-era launch flag for ad-hoc servers - #2372
Conversation
An ad-hoc --server-url / command launch always negotiated the legacy era, because protocolEra was only settable per server in mcp.json. A wrapper that mints a short-lived bearer token therefore had to write that token to disk to exercise a server under auto or modern. --protocol-era <legacy|auto|modern> now feeds settings.protocolEra in all three clients through a shared parseProtocolEra coercer: - CLI/TUI overlay it in loadServerEntries alongside --header, onto an ad-hoc target and onto a --catalog/--config entry for that run. - Web stamps it on the in-memory ad-hoc entry, which the backend lifts into settings like headers; as with --header it is rejected alongside --catalog/--config, but unlike --header it applies to stdio too. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SZ4rrvH6xaCfrst75gJh7x Signed-off-by: cliffhall <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The CLI integration tests do not distinguish correctly wired protocol negotiation from the existing legacy default.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds a shared --protocol-era launch flag across Web, CLI, and TUI for ad-hoc server negotiation.
Changes:
- Adds shared validation and server-settings propagation.
- Wires the flag into all client launchers.
- Updates tests and documentation.
File summaries
| File | Description |
|---|---|
docs/mcp-server-configuration.md |
Documents shared flag behavior. |
core/mcp/node/servers.ts |
Merges protocol-era overrides into settings. |
core/mcp/node/index.ts |
Exports the parser. |
core/mcp/node/config.ts |
Validates protocol-era values. |
clients/web/src/test/integration/server/run-web.test.ts |
Tests web argument handling. |
clients/web/src/test/core/mcp/node/servers.test.ts |
Tests settings merging. |
clients/web/src/test/core/mcp/node/config.test.ts |
Tests parser validation. |
clients/web/server/run-web.ts |
Applies the flag to ad-hoc web entries. |
clients/tui/tui.tsx |
Adds TUI flag wiring. |
clients/tui/README.md |
Documents TUI usage. |
clients/launcher/README.md |
Documents web launcher behavior. |
clients/cli/src/cli.ts |
Adds CLI flag wiring. |
clients/cli/README.md |
Documents CLI usage. |
clients/cli/__tests__/programmatic-ergonomics.test.ts |
Adds CLI acceptance tests. |
Review details
- Files reviewed: 14/14 changed files
- Comments generated: 1
- Review effort level: Balanced
| headers: options.header as Record<string, string> | undefined, | ||
| // `--protocol-era` feeds `settings.protocolEra` the same way, so an ad-hoc | ||
| // launch can pick a non-legacy era without an mcp.json entry (#2208). | ||
| protocolEra: options.protocolEra, |
There was a problem hiding this comment.
Fixed in 70cd4f0 — agreed, both new cases passed with the wiring removed.
Added negotiates the modern era against a modern-only server to clients/cli/__tests__/programmatic-ergonomics.test.ts. It starts createTestServerHttp with modern: { legacy: "reject" }, then runs initialize twice against the same ad-hoc URL:
- without the flag → the default legacy handshake is rejected, so the CLI must fail;
- with
--protocol-era modern→ the CLI must succeed and reportprotocolVersion2026-07-28(MODERN_PROTOCOL_VERSION).
Mutation check: deleting protocolEra: options.protocolEra, from the serverOptions in cli.ts and rebuilding fails exactly this test (1 failed, 3 passed across the --protocol-era block); with it restored, all 4 pass. The legacy/auto cases stay as acceptance coverage for the parser.
…#2208) The legacy and auto e2e cases both connect to the legacy stdio fixture whether or not the flag reaches negotiation, since auto falls back. Run initialize against an HTTP test server that rejects the legacy handshake: the default must fail, and --protocol-era modern must connect and report the 2026-07-28 protocol version. Deleting the serverOptions assignment in cli.ts now fails this case (Copilot review, PR #2372). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SZ4rrvH6xaCfrst75gJh7x Signed-off-by: cliffhall <[email protected]>
|
Copilot review round 1 — 1 comment, fixed in 70cd4f0. No suppressed comments.
Requesting another review. |
|
Copilot review round 2 — 0 comments, "Approval recommended". No suppressed comments. Review closed: round 1's single finding (the CLI e2e cases could not tell working |
Closes #2208
What
A
--protocol-era <legacy|auto|modern>launch flag for all three clients, so an ad-hoc--server-url/ command launch can negotiate a non-legacy era without anmcp.jsonentry. That was the only way to setprotocolErabefore, which for a wrapper that mints a short-lived bearer token meant writing the token to disk on every launch.How
core/mcp/node/config.ts—parseProtocolEra, the shared Commander coercer. It reusesisProtocolEra, the guardmcp.jsonreads already go through, so the flag and the file accept exactly the same values.core/mcp/node/servers.ts—ServerLoadOptions.protocolEra.mergeSettingsnow overlays--protocol-eraalongside--header, onto both a file entry's settings and an ad-hoc target's. With neither flag an ad-hoc target still gets no settings node, so the legacy default is unchanged.loadServerEntries. Like--headerand--connect-timeout, it also overrides a--catalog/--configentry'sprotocolErafor that run.run-web.ts) — stampsprotocolEraon the in-memory ad-hoc entry, which/api/serversserves through the same normalize-and-lift path a catalog entry'sprotocolEraalready takes, so it lands insettings.protocolEraexactly as the ad-hocheadersland insettings.headers. Web keeps its existing stance on--header: the flag is rejected alongside--catalog/--config, and on its own with no ad-hoc target. Unlike--headerit is accepted for stdio, because the era is transport-agnostic.Tests
config.test.ts— accepts each era, rejects an unknown one and names the valid ones.servers.test.ts— overrides a diskprotocolErawhile preserving headers and timeouts; applies to an entry with no disk settings; combines with--headeron an ad-hoc URL; leaves an ad-hoc target with no flags at no settings.run-web.test.ts— seeded entry carries the era for HTTP and for stdio; absent flag leaves noprotocolEra; invalid value, missing ad-hoc target, and--catalog/--configcombinations are rejected.programmatic-ergonomics.test.ts(CLI e2e) —legacyandautoconnect to the stdio test server; an unknown era fails before connecting.Docs
docs/mcp-server-configuration.md(shared-flags table and the web-divergence note), plus the CLI, TUI and launcher READMEs.No UI change, so no screenshots.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SZ4rrvH6xaCfrst75gJh7x