Era-aware connection model & capability gating (#1626) (#1697)
Some checks failed
Run install, format, lint, build, and test on every push / build (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish-github-container-registry (push) Has been cancelled

* Era-aware connection model & capability gating (#1626)

Make protocol era (SEP §7.8) a first-class, per-server connection dimension,
orthogonal to the transport type, and drive the SDK Client's versionNegotiation
from it.

Config
- Add `ServerProtocolEra` ("legacy" | "auto" | "modern"), `DEFAULT_PROTOCOL_ERA`
  (legacy, per the SDK's don't-auto-probe guidance), `MODERN_PROTOCOL_VERSION`,
  and `eraToVersionNegotiation()` in core/mcp/types.ts.
- Persist `protocolEra` on `StoredMCPServer` / `InspectorServerSettings`,
  round-tripping through serverList.ts (omitting the default on disk) and the
  `/api/servers` read + write validators.

InspectorClient / state
- Thread `versionNegotiation` through `InspectorClientOptions` (default legacy),
  replacing the hardcoded pin. After connect, read `getProtocolEra()` /
  `getDiscoverResult()` / `getNegotiatedProtocolVersion()`, expose them via
  getters, dispatch `protocolEraChange` / `discoverResultChange`, and clear on
  disconnect. `useInspectorClient` surfaces `protocolEra` / `discoverResult`.

Web UI
- ServerSettingsForm: a Protocol Era selector bound to the per-server setting.
- ConnectionInfoContent: era-aware — Era badge, Session ("Sessionless" on
  modern), and a Discovery section (supported versions + extensions) from the
  `server/discover` result.

CLI/TUI also map the mcp.json `protocolEra` into versionNegotiation so the field
applies uniformly. Version negotiation stays fully client-side; modern connect
works over the existing remote tunnel and disconnect is sessionless (the SDK
skips DELETE when there is no session id). Mcp-* header fidelity is left to the
History/Network card.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5

* Address @claude review: era docstrings, era validation, stdio session label, AGENTS.md rule

- Fix stale docstrings/comments in inspectorClient.ts, useInspectorClient.ts,
  inspectorClientEventTarget.ts, and ConnectionInfoContent.tsx: getProtocolEra()
  returns "legacy" (not undefined) on a plain legacy connect; it is undefined
  only when not connected.
- Validate protocolEra at the storedFieldsToInspectorSettings read boundary
  (new shared isProtocolEra guard) so a hand-edited mcp.json read directly by
  the CLI/TUI drops an unknown era instead of passing it to
  eraToVersionNegotiation. Keeps the exhaustive switch intact.
- ConnectionInfoContent: the Session row is HTTP-only — show "N/A (stdio)" for
  stdio instead of the misleading "Session-based".
- AGENTS.md: add a rule against unjustified `as unknown as` double casts, and
  drop the one such cast introduced in the serverList test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5

* Address re-review: dedupe isProtocolEra guard in remote server

Replace the local isProtocolEra in remote/node/server.ts with the shared guard
now exported from serverList.ts (already imported here), so the era literal set
lives in one place and can't drift.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cliff Hall 2026-07-16 23:39:29 -04:00 • committed by GitHub
commit e026051b47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,7 +11,9 @@ import {
} from "@mantine/core";
import type {
ClientCapabilities,
DiscoverResult,
InitializeResult,
ProtocolEra,
} from "@modelcontextprotocol/client";
import type { ServerType } from "@inspector/core/mcp/types.js";
import type { OAuthClientRegistrationKind } from "@inspector/core/auth/types.js";
@ -38,6 +40,18 @@ export interface ConnectionInfoContentProps {
initializeResult: InitializeResult;
clientCapabilities: ClientCapabilities;
transport: ServerType;
/**
* Protocol era negotiated with the server (SEP §7.8). `"modern"` connections
* are sessionless and learn capabilities from `server/discover`; `"legacy"`
* (or undefined, on a plain legacy connect) use the initialize handshake.
* (#1626)
*/
protocolEra?: ProtocolEra;
/**
* The `server/discover` result on a modern connection — supported versions,
* capabilities, and extensions learned up front. Undefined on legacy. (#1626)
*/
discoverResult?: DiscoverResult;
oauth?: OAuthDetails;
onClearOAuth?: () => void;
}
@ -97,6 +111,38 @@ function formatClientRegistrationKind(
}
}
// The SDK reports the era for every connected era, including a plain legacy
// connect (`"legacy"`); it's undefined only when not connected. Anything other
// than `"modern"` renders as the legacy era.
function isModernEra(era: ProtocolEra | undefined): boolean {
return era === "modern";
}
function formatEra(era: ProtocolEra | undefined): string {
return isModernEra(era) ? "Modern" : "Legacy";
}
// The session concept is HTTP-only: modern HTTP connections are sessionless (no
// `Mcp-Session-Id`, nothing to DELETE on disconnect) while a legacy HTTP
// connection may carry a server session. stdio has no HTTP session at all, so
// the row is not applicable there.
function formatSession(
era: ProtocolEra | undefined,
transport: ServerType,
): string {
if (transport === "stdio") return "N/A (stdio)";
return isModernEra(era) ? "Sessionless" : "Session-based";
}
// The `extensions` map the server advertised in its `server/discover`
// capabilities (SEP-2133). Render the extension identifiers, or an em dash when
// none were advertised.
function formatExtensions(discoverResult: DiscoverResult): string {
const extensions = discoverResult.capabilities.extensions;
const keys = extensions ? Object.keys(extensions) : [];
return keys.length > 0 ? keys.join(", ") : "—";
}
const SERVER_CAPABILITY_KEYS: CapabilityKey[] = [
"tools",
"resources",
@ -131,6 +177,8 @@ export function ConnectionInfoContent({
initializeResult,
clientCapabilities,
transport,
protocolEra,
discoverResult,
oauth,
onClearOAuth,
}: ConnectionInfoContentProps) {
@ -159,9 +207,37 @@ export function ConnectionInfoContent({
<Text size="sm">Transport</Text>
<Badge variant="outline">{transport}</Badge>
<Text size="sm">Era</Text>
<Badge
variant="outline"
color={isModernEra(protocolEra) ? "blue" : "gray"}
>
{formatEra(protocolEra)}
</Badge>
<Text size="sm">Session</Text>
<ValueText>{formatSession(protocolEra, transport)}</ValueText>
</SimpleGrid>
</Stack>
{discoverResult && (
<Stack gap="xs">
<SectionHeading>Discovery</SectionHeading>
<SimpleGrid cols={2}>
<Text size="sm">Supported versions</Text>
<ValueText>
{discoverResult.supportedVersions.length > 0
? discoverResult.supportedVersions.join(", ")
: "—"}
</ValueText>
<Text size="sm">Extensions</Text>
<ValueText>{formatExtensions(discoverResult)}</ValueText>
</SimpleGrid>
</Stack>
)}
<SimpleGrid cols={2}>
<Stack gap="xs">
<SectionHeading>Server Capabilities</SectionHeading>