Skip to content

feat: add --protocol-era launch flag for ad-hoc servers - #2372

Merged
cliffhall merged 3 commits into
v2/mainfrom
v2/feat/2208-protocol-era-flag
Sep 14, 2026
Merged

cliffhall merged 3 commits into
v2/mainfrom
v2/feat/2208-protocol-era-flag

Conversation

@cliffhall

Copy link
Copy Markdown
Member

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 an mcp.json entry. That was the only way to set protocolEra before, which for a wrapper that mints a short-lived bearer token meant writing the token to disk on every launch.

mcp-inspector --transport http --server-url "$URL" \
  --header "Authorization: Bearer $TOKEN" --protocol-era modern

How

  • core/mcp/node/config.ts — parseProtocolEra, the shared Commander coercer. It reuses isProtocolEra, the guard mcp.json reads already go through, so the flag and the file accept exactly the same values.
  • core/mcp/node/servers.ts — ServerLoadOptions.protocolEra. mergeSettings now overlays --protocol-era alongside --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.
  • CLI / TUI — declare the flag and pass it to loadServerEntries. Like --header and --connect-timeout, it also overrides a --catalog/--config entry's protocolEra for that run.
  • Web (run-web.ts) — stamps protocolEra on the in-memory ad-hoc entry, which /api/servers serves through the same normalize-and-lift path a catalog entry's protocolEra already takes, so it lands in settings.protocolEra exactly as the ad-hoc headers land in settings.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 --header it 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 disk protocolEra while preserving headers and timeouts; applies to an entry with no disk settings; combines with --header on 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 no protocolEra; invalid value, missing ad-hoc target, and --catalog/--config combinations are rejected.
  • programmatic-ergonomics.test.ts (CLI e2e) — legacy and auto connect 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

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]>
@cliffhall cliffhall added the v2 Issues and PRs for v2 label Sep 14, 2026
@cliffhall
cliffhall requested a balanced review from Copilot September 14, 2026 04:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread clients/cli/src/cli.ts
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,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 report protocolVersion 2026-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]>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review round 1 — 1 comment, fixed in 70cd4f0. No suppressed comments.

  • clients/cli/src/cli.ts — the CLI e2e cases don't distinguish working wiring from the legacy default. ✅ Fixed. Added a discriminating case against a modern-only HTTP fixture (modern: { legacy: "reject" }): initialize fails without the flag and succeeds with --protocol-era modern, reporting 2026-07-28. Mutation-checked: removing the serverOptions.protocolEra assignment fails exactly that test (1 failed / 3 passed); restored, all 4 pass.

Requesting another review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The flag is consistently validated, propagated, documented, and covered by discriminating integration tests.

Review details
  • Files reviewed: 14/14 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

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 --protocol-era wiring from the legacy default) was fixed in 70cd4f0 with a mutation-checked, modern-only-server test, and round 2 surfaced nothing further. Next: merge v2/main in (trial merge is conflict-free), re-run the gate, push, and merge on green CI.

@cliffhall
cliffhall merged commit 634b243 into v2/main Sep 14, 2026
4 checks passed
@cliffhall
cliffhall deleted the v2/feat/2208-protocol-era-flag branch September 14, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants