import { JSONRPCErrorResponseSchema, JSONRPCNotificationSchema, JSONRPCRequestSchema, JSONRPCResultResponseSchema, OAuthClientInformationFull, OAuthErrorResponse, OAuthMetadata, OAuthProtectedResourceMetadata, OAuthTokenRevocationRequest, OAuthTokens, RequestIdSchema, ResultSchema } from "@modelcontextprotocol/core/internal"; import * as z from "zod/v4"; //#region ../core-internal/src/types/types.d.ts type Primitive = string | number | boolean | bigint | null | undefined; type Flatten = T$1 extends Primitive ? T$1 : T$1 extends Array ? Array> : T$1 extends Set ? Set> : T$1 extends Map ? Map, Flatten> : T$1 extends object ? { [K in keyof T$1]: Flatten } : T$1; type Infer = Flatten>; /** * Wire-only members hidden from the public types. * * `resultType` is the protocol-revision-2026-07-28 wire discrimination field * on results. It is consumed by the SDK's protocol layer (and stripped before * results reach consumers), so the public result types do not declare it. * The wire schemas continue to model it internally. */ type WireOnlyResultKey = 'resultType'; /** * Removes wire-only members from a (possibly union) schema-inferred type * while preserving every other declared member, optionality, and the loose * index signature. */ type StripWireOnly = T$1 extends unknown ? { [K in keyof T$1 as K extends WireOnlyResultKey ? never : K]: T$1[K] } : never; type Result$1 = StripWireOnly>; type RequestId = Infer; type JSONRPCRequest = Infer; type JSONRPCNotification = Infer; type JSONRPCErrorResponse = Infer; type JSONRPCResultResponse = Omit, 'result'> & { result: Result$1; }; type JSONRPCMessage = JSONRPCRequest | JSONRPCNotification | JSONRPCResultResponse | JSONRPCErrorResponse; /** * Information about a validated access token, provided to request handlers. */ interface AuthInfo { /** * The access token. */ token: string; /** * The client ID associated with this token. */ clientId: string; /** * Scopes associated with this token. */ scopes: string[]; /** * When the token expires (in seconds since epoch). */ expiresAt?: number; /** * The RFC 8707 resource server identifier for which this token is valid. * If set, this MUST match the MCP server's resource identifier (minus hash fragment). */ resource?: URL; /** * Additional data associated with the token. * This field should be used for any additional data that needs to be attached to the auth info. */ extra?: Record; } /** * Protocol-era classification of an inbound message. * * Populated by transports that classify messages at the edge (e.g. an HTTP * entry distinguishing 2025-era from 2026-era traffic). The wire era itself * is connection state (the negotiated protocol version held by the * `Client`/`Server` instance); the protocol layer validates a classified * message against that instance era at dispatch — a mismatch is treated as * an entry/routing error, never a per-message era switch. Unclassified * traffic is dispatched on the instance era unchanged. */ interface MessageClassification { /** * The wire era the message was classified into: `legacy` for the * 2025-11-25 family of revisions, `modern` for 2026-07-28 and later. */ era: 'legacy' | 'modern'; /** * The exact protocol revision, when the classifier derived one. */ revision?: string; } /** * Extra information about a message. */ interface MessageExtraInfo { /** * The original HTTP request. */ request?: globalThis.Request; /** * Protocol-era classification of the message, when the transport * classified it at the edge. Validated by the protocol layer against the * instance's negotiated era at dispatch (the edge→instance handoff * check); it does not select the era itself. */ classification?: MessageClassification; /** * The authentication information. */ authInfo?: AuthInfo; /** * Callback to close the SSE stream for this request, triggering client reconnection. * Only available when using {@linkcode @modelcontextprotocol/node!streamableHttp.NodeStreamableHTTPServerTransport | NodeStreamableHTTPServerTransport} with eventStore configured. */ closeSSEStream?: () => void; /** * Callback to close the standalone GET SSE stream, triggering client reconnection. * Only available when using {@linkcode @modelcontextprotocol/node!streamableHttp.NodeStreamableHTTPServerTransport | NodeStreamableHTTPServerTransport} with eventStore configured. */ closeStandaloneSSEStream?: () => void; } //#endregion //#region ../core-internal/src/shared/transport.d.ts type FetchLike = (url: string | URL, init?: RequestInit) => Promise; /** * Options for sending a JSON-RPC message. */ type TransportSendOptions = { /** * If present, `relatedRequestId` is used to indicate to the transport which incoming request to associate this outgoing message with. */ relatedRequestId?: RequestId | undefined; /** * The resumption token used to continue long-running requests that were interrupted. * * This allows clients to reconnect and continue from where they left off, if supported by the transport. */ resumptionToken?: string | undefined; /** * A callback that is invoked when the resumption token changes, if supported by the transport. * * This allows clients to persist the latest token for potential reconnection. */ onresumptiontoken?: ((token: string) => void) | undefined; /** * An abort signal for THIS outbound message's underlying request, when the * transport sends one outbound message per underlying request (the * Streamable HTTP transport's POST-per-request model). Aborting it cancels * the underlying request (and its SSE response stream) without closing the * transport. Transports that share a single channel (stdio, in-memory) * ignore it. */ requestSignal?: AbortSignal | undefined; /** * Fired by transports that open a per-request stream (the Streamable HTTP * transport's POST-per-request SSE response) when that stream ends or * errors for any reason OTHER than a deliberate `requestSignal` abort — * i.e. the server closed the stream, the network dropped it, or * reconnection was exhausted. Transports that share a single channel * (stdio, in-memory) ignore it. */ onRequestStreamEnd?: (() => void) | undefined; /** * Additional HTTP headers to send with THIS outbound message, when the * transport sends one outbound message per underlying HTTP request (the * Streamable HTTP transport's POST-per-request model). Transports that * share a single channel (stdio, in-memory) ignore it. * * The Client uses this to attach SEP-2243 `Mcp-Param-{Name}` headers to a * `tools/call` request on a 2026-07-28 connection. Values are sent * verbatim — encode anything that is not a safe RFC 9110 field value * before passing it here. */ headers?: Readonly> | undefined; }; /** * Describes the minimal contract for an MCP transport that a client or server can communicate over. */ interface Transport { /** * Starts processing messages on the transport, including any connection steps that might need to be taken. * * This method should only be called after callbacks are installed, or else messages may be lost. * * NOTE: This method should not be called explicitly when using {@linkcode @modelcontextprotocol/client!client/client.Client | Client} or {@linkcode @modelcontextprotocol/server!server/server.Server | Server} classes, as they will implicitly call {@linkcode Transport.start | start()}. */ start(): Promise; /** * Sends a JSON-RPC message (request or response). * * If present, `relatedRequestId` is used to indicate to the transport which incoming request to associate this outgoing message with. */ send(message: JSONRPCMessage, options?: TransportSendOptions): Promise; /** * Closes the connection. */ close(): Promise; /** * `true` when this transport opens one underlying request per outbound * JSON-RPC request (the Streamable HTTP POST-per-request model) and * therefore honors {@linkcode TransportSendOptions.requestSignal}. The * 2026-07-28 spec makes closing that per-request stream the cancellation * signal — the protocol layer aborts `requestSignal` instead of POSTing * `notifications/cancelled` when this flag is set on a 2026-era * connection. Transports that share a single channel (stdio, in-memory) * leave it `undefined`. */ readonly hasPerRequestStream?: boolean; /** * Callback for when the connection is closed for any reason. * * This should be invoked when {@linkcode Transport.close | close()} is called as well. */ onclose?: (() => void) | undefined; /** * Callback for when an error occurs. * * Note that errors are not necessarily fatal; they are used for reporting any kind of exceptional condition out of band. */ onerror?: ((error: Error) => void) | undefined; /** * Callback for when a message (request or response) is received over the connection. * * Includes the {@linkcode MessageExtraInfo.request | request} and {@linkcode MessageExtraInfo.authInfo | authInfo} if the transport is authenticated. * * The {@linkcode MessageExtraInfo.request | request} can be used to get the original request information (headers, etc.) */ onmessage?: ((message: T$1, extra?: MessageExtraInfo) => void) | undefined; /** * The session ID generated for this connection. */ sessionId?: string | undefined; /** * Sets the protocol version used for the connection (called when the initialize response is received). */ setProtocolVersion?: ((version: string) => void) | undefined; /** * Sets the supported protocol versions for header validation (called during connect). * This allows the server to pass its supported versions to the transport. */ setSupportedProtocolVersions?: ((versions: string[]) => void) | undefined; } //#endregion export { JSONRPCMessage as a, OAuthErrorResponse as c, OAuthTokenRevocationRequest as d, OAuthTokens as f, AuthInfo as i, OAuthMetadata as l, Transport as n, MessageExtraInfo as o, TransportSendOptions as r, OAuthClientInformationFull as s, FetchLike as t, OAuthProtectedResourceMetadata as u }; //# sourceMappingURL=index-Lq7iBORO.d.cts.map