MCP TypeScript SDK (V2) / @modelcontextprotocol/client / client/probeClassifier
client/probeClassifier
Interfaces
ProbeClassifierContext
Defined in: packages/client/src/client/probeClassifier.ts:63
Properties
clientModernVersions
clientModernVersions: readonly
string[]
Defined in: packages/client/src/client/probeClassifier.ts:65
Modern-era versions this client can negotiate, in preference order (never empty).
environment
environment:
ProbeEnvironment
Defined in: packages/client/src/client/probeClassifier.ts:80
See ProbeEnvironment.
fallbackAvailable
fallbackAvailable:
boolean
Defined in: packages/client/src/client/probeClassifier.ts:78
Whether a legacy initialize fallback is possible — false for a modern-only client and for pin mode. Without a fallback, rows carrying modern evidence but no usable version overlap — a DiscoverResult with no overlapping version, or a -32022 whose data.supported lists only legacy revisions — yield a typed UnsupportedProtocolVersionError built from that evidence; the remaining rows that would have fallen back still classify as legacy, and the caller reports them as a typed negotiation error instead of starting an initialize handshake.
requestedVersion
requestedVersion:
string
Defined in: packages/client/src/client/probeClassifier.ts:67
The version the probe carried in its _meta envelope (used to synthesize data.requested on typed errors).
transportKind
transportKind:
ProbeTransportKind
Defined in: packages/client/src/client/probeClassifier.ts:82
See ProbeTransportKind.
Type Aliases
PriorDiscovery
PriorDiscovery = {
discover:DiscoverResult;kind:"modern"; } | {kind:"legacy"; }
Defined in: packages/client/src/client/probeClassifier.ts:109
A cached era verdict for connect({ prior }) — the persistable subset of the ProbeVerdict vocabulary ('modern' = speaks 2026-07-28+, 'legacy' = 2025-era initialize only). Freshness is the supplying host's responsibility: a stale modern verdict fails loudly at the first request, but a stale legacy verdict succeeds silently forever (an upgraded server still answers initialize) — date cached legacy verdicts in your own storage and stop supplying them past your policy horizon. Full recipe: the gateway guide (docs/advanced/gateway.md).
Union Members
Type Literal
{ discover: DiscoverResult; kind: "modern"; }
Adopt discover directly: zero round trips.
Type Literal
{ kind: "legacy"; }
Known-legacy server: skip the server/discover probe and run the plain legacy initialize handshake.
ProbeEnvironment
ProbeEnvironment =
"node"|"browser"
Defined in: packages/client/src/client/probeClassifier.ts:32
The runtime environment the probe executed in. Only consulted for the network-failure row: a browser CORS-preflight rejection is treated as a legacy signal, while in Node a network failure stays a typed connect error.
ProbeOutcome
ProbeOutcome = {
kind:"result";result:unknown; } | {code:number;data?:unknown;kind:"rpc-error";message:string; } | {body?:string;kind:"http-error";status:number;statusText?:string; } | {error:unknown;kind:"network-error"; } | {error:unknown;kind:"unusable-reply"; } | {error:Error;kind:"auth-required"; } | {kind:"closed"; } | {kind:"timeout";timeoutMs:number; }
Defined in: packages/client/src/client/probeClassifier.ts:47
A normalized probe outcome, produced by the connect-time wiring from the raw transport exchange.
Union Members
Type Literal
{ kind: "result"; result: unknown; }
Type Literal
{ code: number; data?: unknown; kind: "rpc-error"; message: string; }
Answered with a JSON-RPC error (any HTTP status, including 200-bodied errors and stdio in-band errors).
Type Literal
{ body?: string; kind: "http-error"; status: number; statusText?: string; }
The HTTP layer rejected the probe POST (non-2xx); body is the raw response text and statusText the HTTP reason phrase, when available.
Type Literal
{ error: unknown; kind: "network-error"; }
Type Literal
{ error: unknown; kind: "unusable-reply"; }
The probe was answered 2xx without a usable reply (body is not JSON, or an unaccepted media type); error is the transport's failure.
Type Literal
{ error: Error; kind: "auth-required"; }
The transport's auth flow challenged or failed during the probe send — an error stamped at a transport auth seam, or an UnauthorizedError (the foreign-transport contract). error propagates unchanged.
Type Literal
{ kind: "closed"; }
The transport reported close while the probe awaited its reply.
Type Literal
{ kind: "timeout"; timeoutMs: number; }
No response arrived within the probe timeout.
ProbeTransportKind
ProbeTransportKind =
"stdio"|"http"
Defined in: packages/client/src/client/probeClassifier.ts:41
The transport class the probe ran on. Consulted for the timeout and closed rows: a stdio probe that times out — or whose child exits, closing the connection — signals a legacy server, while an HTTP timeout or close stays a typed error. Anything that is not the stdio child-process transport is treated like HTTP.
ProbeVerdict
ProbeVerdict = {
discover:DiscoverResult;kind:"modern";version:string; } | {error:UnsupportedProtocolVersionError;kind:"corrective";version:string; } | {kind:"legacy"; } | {error:Error;kind:"error"; }
Defined in: packages/client/src/client/probeClassifier.ts:85
Union Members
Type Literal
{ discover: DiscoverResult; kind: "modern"; version: string; }
Definitive modern evidence: select version and continue without initialize.
Type Literal
{ error: UnsupportedProtocolVersionError; kind: "corrective"; version: string; }
-32022 with a mutual modern version: re-send the probe at version. Spec-mandated select-and-continue — the caller runs it exactly once and arms a loop guard on the second rejection, throwing error.
Type Literal
{ kind: "legacy"; }
Definitive legacy signal or unrecognized shape: perform the plain legacy initialize handshake (on the probed connection in the in-place modes; on the session child's fresh pipe on the sibling path).
Type Literal
{ error: Error; kind: "error"; }
Typed connect error — never converted to an era verdict.
Functions
classifyProbeOutcome()
classifyProbeOutcome(
outcome,context):ProbeVerdict
Defined in: packages/client/src/client/probeClassifier.ts:130
Classify a single probe outcome. Pure: no I/O, no state — loop-guard and retry state live in the caller.