This is the documentation for the v2 beta — looking for the v1 documentation?
Skip to content

MCP TypeScript SDK (V2) / @modelcontextprotocol/client / client/client

client/client

Classes

Client

Defined in: packages/client/src/client/client.ts:503

An MCP client on top of a pluggable transport.

The client will automatically begin the initialization flow with the server when connect is called.

To handle server-initiated requests (sampling, elicitation, roots), call setRequestHandler. The client must declare the corresponding capability for the handler to be accepted. For sampling/createMessage and elicitation/create, the handler is automatically wrapped with schema validation for both the incoming request and the returned result.

Note: the roots/list and sampling/createMessage handler surfaces (and the corresponding roots and sampling capabilities) are deprecated as of protocol version 2026-07-28 (SEP-2577). They remain functional during the deprecation window (at least twelve months). Migrate sampling to calling LLM provider APIs directly, and roots to passing paths via tool parameters, resource URIs, or configuration.

Example

Handling a sampling request

ts
client.setRequestHandler('sampling/createMessage', async request => {
    const lastMessage = request.params.messages.at(-1);
    console.log('Sampling request:', lastMessage);

    // In production, send messages to your LLM here
    return {
        model: 'my-model',
        role: 'assistant' as const,
        content: {
            type: 'text' as const,
            text: 'Response from the model'
        }
    };
});

Extends

Constructors

Constructor

new Client(_clientInfo, options?): Client

Defined in: packages/client/src/client/client.ts:605

Initializes this client with the given name and version information.

Parameters
_clientInfo
description?

string = ...

An optional human-readable description of what this implementation does.

This can be used by clients or servers to provide context about their purpose and capabilities. For example, a server might describe the types of resources or tools it provides, while a client might describe its intended use case.

icons?

object[] = ...

Optional set of sized icons that the client can display in a user interface.

Clients that support rendering icons MUST support at least the following MIME types:

  • image/png - PNG images (safe, universal compatibility)
  • image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility)

Clients that support rendering icons SHOULD also support:

  • image/svg+xml - SVG images (scalable but requires security precautions)
  • image/webp - WebP images (modern, efficient format)
name

string = ...

Intended for programmatic or logical use, but used as a display name in past specs or fallback

title?

string = ...

Intended for UI and end-user contexts — optimized to be human-readable and easily understood, even by those unfamiliar with domain-specific terminology.

If not provided, the name should be used for display (except for Tool, where annotations.title should be given precedence over using name, if present).

version

string = ...

websiteUrl?

string = ...

An optional URL of the website for this implementation.

options?

ClientOptions

Returns

Client

Overrides

Protocol.constructor

Properties

_negotiatedProtocolVersion?

protected optional _negotiatedProtocolVersion?: string

Defined in: packages/core-internal/src/shared/protocol.ts:574

The protocol version negotiated for the current connection (undefined before negotiation completes), which determines the wire era this instance speaks. Set by the SDK's negotiation and initialize paths (Client.connect, Server._oninitialize).

Inherited from

Protocol._negotiatedProtocolVersion

_supportedProtocolVersions

protected _supportedProtocolVersions: string[]

Defined in: packages/core-internal/src/shared/protocol.ts:582

Inherited from

Protocol._supportedProtocolVersions

fallbackNotificationHandler?

optional fallbackNotificationHandler?: (notification) => Promise<void>

Defined in: packages/core-internal/src/shared/protocol.ts:606

A handler to invoke for any notification types that do not have their own handler installed.

Parameters
notification
method

string = ...

params?

{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; } = ...

params._meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See MCP specification for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

params._meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

Returns

Promise<void>

Inherited from

Protocol.fallbackNotificationHandler

fallbackRequestHandler?

optional fallbackRequestHandler?: (request, ctx) => Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

Defined in: packages/core-internal/src/shared/protocol.ts:601

A handler to invoke for any request types that do not have their own handler installed.

Parameters
request
id

string | number = RequestIdSchema

jsonrpc

"2.0" = ...

method

string = ...

params?

{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; } = ...

params._meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

params._meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

ctx

BaseContext

Returns

Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

Inherited from

Protocol.fallbackRequestHandler

onclose?

optional onclose?: () => void

Defined in: packages/core-internal/src/shared/protocol.ts:589

Callback for when the connection is closed for any reason.

This is invoked when close() is called as well.

Returns

void

Inherited from

Protocol.onclose

onerror?

optional onerror?: (error) => void

Defined in: packages/core-internal/src/shared/protocol.ts:596

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.

Parameters
error

Error

Returns

void

Inherited from

Protocol.onerror

Accessors

autoOpenedSubscription
Get Signature

get autoOpenedSubscription(): McpSubscription | undefined

Defined in: packages/client/src/client/client.ts:2074

The subscription auto-opened by ClientOptions.listChanged on a modern connection — the listen filter is the intersection of the configured sub-options and the server-advertised listChanged capabilities. undefined on a legacy connection, before connect, or when that intersection is empty (auto-open skipped). Exposed so the consumer can close() it.

Returns

McpSubscription | undefined

transport
Get Signature

get transport(): Transport | undefined

Defined in: packages/core-internal/src/shared/protocol.ts:1217

Returns

Transport | undefined

Inherited from

Protocol.transport

Methods

_getRequestHandler()

protected _getRequestHandler(method): ((request, ctx) => Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>) | undefined

Defined in: packages/core-internal/src/shared/protocol.ts:721

Protected accessor for a registered request handler. Used by role classes that dispatch synthesized requests through the same stored handler chain (e.g. the Client fulfilling an embedded multi-round-trip input request).

Parameters
method

string

Returns

((request, ctx) => Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>) | undefined

Inherited from

Protocol._getRequestHandler

_onclose()

protected _onclose(): void

Defined in: packages/client/src/client/client.ts:2204

Settle every live per-listen state machine on a transport-initiated close (the server dropping the connection on stdio/InMemory) before Protocol's _onclose tears the transport down. The base _responseHandlers settlement does not reach _listenState (listen ids are never registered there), so without this override a remote close would leave an in-flight listen() / open McpSubscription hanging.

Returns

void

Overrides

Protocol._onclose

_onnotification()

protected _onnotification(raw, extra?): void

Defined in: packages/client/src/client/client.ts:2090

Transport-level demux for subscriptions/listen notifications, before any decoding/era-gating/handler dispatch. Consumes the leading notifications/subscriptions/acknowledged referencing a live subscription id (resolves the ack waiter) and an inbound notifications/cancelled referencing a live string-typed subscription id (server-side teardown on stdio). Change notifications carrying a subscription id pass through to the existing registered handlers via super. An unmatched ack/cancelled is NOT consumed: it reaches setNotificationHandler / fallbackNotificationHandler instead of being silently swallowed.

Parameters
raw
jsonrpc

"2.0" = ...

method

string = ...

params?

{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; } = ...

params._meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See MCP specification for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

params._meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

extra?

MessageExtraInfo

Returns

void

Overrides

Protocol._onnotification

_onresponse()

protected _onresponse(response): void

Defined in: packages/client/src/client/client.ts:2163

Transport-level demux for subscriptions/listen responses. A JSON-RPC ERROR for the listen id is the server's pre-ack capacity/params rejection; a JSON-RPC RESULT for the listen id is the spec's SubscriptionsListenResult — the server's GRACEFUL-close signal (sent on shutdown). A string-id response that matches a live _listenState entry is consumed here (Protocol's _responseHandlers map is keyed by NUMBER and never holds a listen id, so passing a string-id response through would surface as "unknown message ID" via onerror).

Parameters
response

JSONRPCResponse

Returns

void

Overrides

Protocol._onresponse

_outboundMetaEnvelope()

protected _outboundMetaEnvelope(): Readonly<Record<string, unknown>> | undefined

Defined in: packages/client/src/client/client.ts:673

Per-request _meta envelope auto-emission (protocol revision 2026-07-28): on a connection that negotiated a modern era — auto-negotiated or pinned — every outgoing request and notification automatically carries the reserved protocol-version / client-info / client-capabilities _meta keys (the same envelope the connect-time server/discover probe sends). User-supplied _meta keys take precedence over the auto-attached ones.

Legacy-era connections return undefined: the envelope seam is a no-op and outbound traffic is byte-identical to a 2025 client (the legacy 'auto' fallback included).

Returns

Readonly<Record<string, unknown>> | undefined

Overrides

Protocol._outboundMetaEnvelope

_requestWithSchema()

protected _requestWithSchema<T>(request, resultSchema, options?): Promise<InferOutput<T>>

Defined in: packages/core-internal/src/shared/protocol.ts:1345

Sends a request and waits for a response, using the provided schema for validation instead of the era registry's method-keyed entry.

This is the internal implementation used by SDK methods whose result schema cannot be expressed as a method-keyed registry entry — the one surviving case is server.createMessage, whose result schema depends on the REQUEST params (tools vs no tools) — and by callers passing explicit compatibility schemas. Spec methods are still era-gated here: an explicit schema never smuggles a deleted method onto the wire.

Type Parameters
T

T extends StandardSchemaV1<unknown, unknown>

Parameters
request
method

string = ...

params?

{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; } = ...

params._meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

params._meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

resultSchema

T

options?

RequestOptions

Returns

Promise<InferOutput<T>>

Inherited from

Protocol._requestWithSchema

_resolveNonCompleteResult()

protected _resolveNonCompleteResult<T>(decoded, flow): Promise<unknown>

Defined in: packages/client/src/client/client.ts:694

Wires the multi-round-trip auto-fulfilment engine (protocol revision 2026-07-28) into the response funnel: an input_required answer is fulfilled through the registered elicitation/sampling/roots handlers and the original request retried via flow.retry, up to inputRequired.maxRounds rounds. With auto-fulfilment disabled the response surfaces as a typed error steering to manual mode.

Type Parameters
T

T extends StandardSchemaV1<unknown, unknown>

Parameters
decoded
inputRequests

Record<string, unknown>

kind

"input_required"

requestState?

string

flow

NonCompleteResultFlow<T>

Returns

Promise<unknown>

Overrides

Protocol._resolveNonCompleteResult

_shouldDropInbound()

protected _shouldDropInbound(message): "drop" | undefined

Defined in: packages/client/src/client/client.ts:650

Era-keyed direction enforcement for inbound traffic on channels whose transport does not classify (e.g. stdio): the 2026-07-28 era has no server→client JSON-RPC request channel — server-to-client interactions are carried in-band in input_required results — and on stdio the client must never write JSON-RPC responses. An inbound request arriving on a connection that negotiated a modern era is therefore dropped (surfaced via onerror) rather than answered. Connections on a legacy era — and all responses and notifications — keep today's dispatch path.

Parameters
message

{ id: string | number; jsonrpc: "2.0"; method: string; params?: {[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }; } | { jsonrpc: "2.0"; method: string; params?: {[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }; }

Returns

"drop" | undefined

Overrides

Protocol._shouldDropInbound

_wireCodec()

protected _wireCodec(): WireCodec

Defined in: packages/core-internal/src/shared/protocol.ts:1297

Protected accessor for the instance's negotiated wire codec, for role classes (Client/Server/McpServer) routing era-dependent behavior through the codec's function-only surface — samplingResultVariant, outboundEnvelope, projectCallToolResult — instead of branching on the protocol version themselves.

Returns

WireCodec

Inherited from

Protocol._wireCodec

_wrapHandler()

protected _wrapHandler(method, handler): (request, ctx) => Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

Defined in: packages/client/src/client/client.ts:789

Enforces client-side validation for elicitation/create and sampling/createMessage regardless of how the handler was registered.

Parameters
method

string

handler

(request, ctx) => Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

Returns

(request, ctx) => Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

Overrides

Protocol._wrapHandler

assertCanSetRequestHandler()

assertCanSetRequestHandler(method): void

Defined in: packages/core-internal/src/shared/protocol.ts:1765

Asserts that a request handler has not already been set for the given method, in preparation for a new one being automatically installed.

Parameters
method

string

Returns

void

Inherited from

Protocol.assertCanSetRequestHandler

assertCapability()

protected assertCapability(capability, method): void

Defined in: packages/client/src/client/client.ts:920

Parameters
capability

"tools" | "experimental" | "tasks" | "extensions" | "logging" | "completions" | "prompts" | "resources"

method

string

Returns

void

assertCapabilityForMethod()

protected assertCapabilityForMethod(method): void

Defined in: packages/client/src/client/client.ts:1339

A method to check if a capability is supported by the remote side, for the given method to be called.

This should be implemented by subclasses.

Parameters
method

string

Returns

void

Overrides

Protocol.assertCapabilityForMethod

assertNotificationCapability()

protected assertNotificationCapability(method): void

Defined in: packages/client/src/client/client.ts:1410

A method to check if a notification is supported by the local side, for the given method to be sent.

This should be implemented by subclasses.

Parameters
method

string

Returns

void

Overrides

Protocol.assertNotificationCapability

assertRequestHandlerCapability()

protected assertRequestHandlerCapability(method): void

Defined in: packages/client/src/client/client.ts:1441

A method to check if a request handler is supported by the local side, for the given method to be handled.

This should be implemented by subclasses.

Parameters
method

string

Returns

void

Overrides

Protocol.assertRequestHandlerCapability

buildContext()

protected buildContext(ctx, _transportInfo?): BaseContext

Defined in: packages/client/src/client/client.ts:636

Builds the context object for request handlers. Subclasses must override to return the appropriate context type (e.g., ServerContext adds HTTP request info).

Parameters
ctx

BaseContext

_transportInfo?

MessageExtraInfo

Returns

BaseContext

Overrides

Protocol.buildContext

callTool()

callTool(params, options?): Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; content: ({ _meta?: {[key: string]: unknown; }; annotations?: { audience?: ("user" | "assistant")[]; lastModified?: string; priority?: number; }; text: string; type: "text"; } | { _meta?: {[key: string]: unknown; }; annotations?: { audience?: ("user" | "assistant")[]; lastModified?: string; priority?: number; }; data: string; mimeType: string; type: "image"; } | { _meta?: {[key: string]: unknown; }; annotations?: { audience?: ("user" | "assistant")[]; lastModified?: string; priority?: number; }; data: string; mimeType: string; type: "audio"; } | { _meta?: {[key: string]: unknown; }; annotations?: { audience?: ("user" | "assistant")[]; lastModified?: string; priority?: number; }; resource: { _meta?: {[key: string]: unknown; }; mimeType?: string; text: string; uri: string; } | { _meta?: {[key: string]: unknown; }; blob: string; mimeType?: string; uri: string; }; type: "resource"; } | { _meta?: {[key: string]: unknown; }; annotations?: { audience?: ("user" | "assistant")[]; lastModified?: string; priority?: number; }; description?: string; icons?: object[]; mimeType?: string; name: string; size?: number; title?: string; type: "resource_link"; uri: string; })[]; isError?: boolean; structuredContent?: unknown; }>

Defined in: packages/client/src/client/client.ts:2256

Calls a tool on the connected server and returns the result. Automatically validates structured output if the tool has an outputSchema.

Tool results have two error surfaces: result.isError for tool-level failures (the tool ran but reported a problem), and thrown ProtocolError for protocol-level failures or SdkError for SDK-level issues (timeouts, missing capabilities).

Parameters
params
_meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

_meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

arguments?

{[key: string]: unknown; } = ...

Arguments to pass to the tool.

name

string = ...

The name of the tool to call.

task?

{ ttl?: number; } = ...

If specified, the caller is requesting task-augmented execution for this request. The request will return a CreateTaskResult immediately, and the actual result can be retrieved later via tasks/result.

Task augmentation is subject to capability negotiation - receivers MUST declare support for task augmentation of specific request types in their capabilities.

task.ttl?

number = ...

options?

CallToolRequestOptions

Returns

Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; content: ({ _meta?: {[key: string]: unknown; }; annotations?: { audience?: ("user" | "assistant")[]; lastModified?: string; priority?: number; }; text: string; type: "text"; } | { _meta?: {[key: string]: unknown; }; annotations?: { audience?: ("user" | "assistant")[]; lastModified?: string; priority?: number; }; data: string; mimeType: string; type: "image"; } | { _meta?: {[key: string]: unknown; }; annotations?: { audience?: ("user" | "assistant")[]; lastModified?: string; priority?: number; }; data: string; mimeType: string; type: "audio"; } | { _meta?: {[key: string]: unknown; }; annotations?: { audience?: ("user" | "assistant")[]; lastModified?: string; priority?: number; }; resource: { _meta?: {[key: string]: unknown; }; mimeType?: string; text: string; uri: string; } | { _meta?: {[key: string]: unknown; }; blob: string; mimeType?: string; uri: string; }; type: "resource"; } | { _meta?: {[key: string]: unknown; }; annotations?: { audience?: ("user" | "assistant")[]; lastModified?: string; priority?: number; }; description?: string; icons?: object[]; mimeType?: string; name: string; size?: number; title?: string; type: "resource_link"; uri: string; })[]; isError?: boolean; structuredContent?: unknown; }>

Examples

Basic usage

ts
const result = await client.callTool({
    name: 'calculate-bmi',
    arguments: { weightKg: 70, heightM: 1.75 }
});

// Tool-level errors are returned in the result, not thrown
if (result.isError) {
    console.error('Tool error:', result.content);
    return;
}

console.log(result.content);

Structured output

ts
const result = await client.callTool({
    name: 'calculate-bmi',
    arguments: { weightKg: 70, heightM: 1.75 }
});

// Machine-readable output for the client application. SEP-2106: structuredContent is
// `unknown` (any JSON value). Check for presence with `!== undefined` and narrow before use.
if (result.structuredContent !== undefined) {
    const sc: unknown = result.structuredContent; // e.g. { bmi: 22.86 }
    if (typeof sc === 'object' && sc !== null && 'bmi' in sc) {
        console.log(sc.bmi);
    }
}
close()

close(): Promise<void>

Defined in: packages/client/src/client/client.ts:591

Closes the connection.

Returns

Promise<void>

Overrides

Protocol.close

complete()

complete(params, options?): Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; completion: {[key: string]: unknown; hasMore?: boolean; total?: number; values: string[]; }; }>

Defined in: packages/client/src/client/client.ts:1499

Requests argument autocompletion suggestions from the server for a prompt or resource.

Parameters
params
_meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

_meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

argument

{ name: string; value: string; } = ...

The argument's information

argument.name

string = ...

The name of the argument

argument.value

string = ...

The value of the argument to use for completion matching.

context?

{ arguments?: {[key: string]: string; }; } = ...

context.arguments?

{[key: string]: string; } = ...

Previously-resolved variables in a URI template or prompt.

ref

{ type: "ref/resource"; uri: string; } | { name: string; type: "ref/prompt"; } = ...

options?

RequestOptions

Returns

Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; completion: {[key: string]: unknown; hasMore?: boolean; total?: number; values: string[]; }; }>

connect()

connect(transport, options?): Promise<void>

Defined in: packages/client/src/client/client.ts:955

Connects to a server via the given transport and performs the MCP initialization handshake.

Parameters
transport

Transport

options?

ConnectOptions

Returns

Promise<void>

Examples

Basic usage (stdio)

ts
const client = new Client({ name: 'my-client', version: '1.0.0' });
const transport = new StdioClientTransport({ command: 'my-mcp-server' });
await client.connect(transport);

Streamable HTTP with SSE fallback

ts
const baseUrl = new URL(url);

try {
    // Try modern Streamable HTTP transport first
    const client = new Client({ name: 'my-client', version: '1.0.0' });
    const transport = new StreamableHTTPClientTransport(baseUrl);
    await client.connect(transport);
    return { client, transport };
} catch {
    // Fall back to legacy SSE transport
    const client = new Client({ name: 'my-client', version: '1.0.0' });
    const transport = new SSEClientTransport(baseUrl);
    await client.connect(transport);
    return { client, transport };
}
Overrides

Protocol.connect

discover()

discover(options?): Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; capabilities: { completions?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; experimental?: {[key: string]: object; }; extensions?: {[key: string]: object; }; logging?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; prompts?: { listChanged?: boolean; }; resources?: { listChanged?: boolean; subscribe?: boolean; }; tasks?: {[key: string]: unknown; cancel?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; list?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; requests?: {[key: string]: unknown; tools?: {[key: string]: unknown; call?: {[key: ...]: ...; }; }; }; }; tools?: { listChanged?: boolean; }; }; instructions?: string; serverInfo: { description?: string; icons?: object[]; name: string; title?: string; version: string; websiteUrl?: string; }; supportedVersions: string[]; }>

Defined in: packages/client/src/client/client.ts:1492

Send server/discover (2026-07-28+) and record the result for getDiscoverResult.

Parameters
options?

RequestOptions

Returns

Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; capabilities: { completions?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; experimental?: {[key: string]: object; }; extensions?: {[key: string]: object; }; logging?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; prompts?: { listChanged?: boolean; }; resources?: { listChanged?: boolean; subscribe?: boolean; }; tasks?: {[key: string]: unknown; cancel?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; list?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; requests?: {[key: string]: unknown; tools?: {[key: string]: unknown; call?: {[key: ...]: ...; }; }; }; }; tools?: { listChanged?: boolean; }; }; instructions?: string; serverInfo: { description?: string; icons?: object[]; name: string; title?: string; version: string; websiteUrl?: string; }; supportedVersions: string[]; }>

getDiscoverResult()

getDiscoverResult(): {[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; capabilities: { completions?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; experimental?: {[key: string]: object; }; extensions?: {[key: string]: object; }; logging?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; prompts?: { listChanged?: boolean; }; resources?: { listChanged?: boolean; subscribe?: boolean; }; tasks?: {[key: string]: unknown; cancel?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; list?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; requests?: {[key: string]: unknown; tools?: {[key: string]: unknown; call?: {[key: ...]: ...; }; }; }; }; tools?: { listChanged?: boolean; }; }; instructions?: string; serverInfo: { description?: string; icons?: object[]; name: string; title?: string; version: string; websiteUrl?: string; }; supportedVersions: string[]; } | undefined

Defined in: packages/client/src/client/client.ts:1335

The DiscoverResult from the last 'auto'/pinned probe, discover call, or connect({ prior }) that adopted a modern verdict (a legacy verdict leaves this undefined — there is no DiscoverResult on that path). Persistable via JSON.stringify; wrap as { kind: 'modern', discover } and feed to ConnectOptionsprior.

Returns
Type Literal

{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; capabilities: { completions?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; experimental?: {[key: string]: object; }; extensions?: {[key: string]: object; }; logging?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; prompts?: { listChanged?: boolean; }; resources?: { listChanged?: boolean; subscribe?: boolean; }; tasks?: {[key: string]: unknown; cancel?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; list?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; requests?: {[key: string]: unknown; tools?: {[key: string]: unknown; call?: {[key: ...]: ...; }; }; }; }; tools?: { listChanged?: boolean; }; }; instructions?: string; serverInfo: { description?: string; icons?: object[]; name: string; title?: string; version: string; websiteUrl?: string; }; supportedVersions: string[]; }

Index Signature

[key: string]: unknown

_meta?

optional _meta?: object

See MCP specification for notes on _meta usage.

Index Signature

[key: string]: unknown

optional io.modelcontextprotocol/related-task?: object

If specified, this request is related to the provided task.

taskId: string

_meta.progressToken?

optional progressToken?: string | number

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

capabilities

capabilities: object = ServerCapabilitiesSchema

The capabilities of the server.

capabilities.completions?

optional completions?: object

Present if the server supports sending completions to the client.

Index Signature

[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null

capabilities.experimental?

optional experimental?: object

Experimental, non-standard capabilities that the server supports.

Index Signature

[key: string]: object

capabilities.extensions?

optional extensions?: object

Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).

Index Signature

[key: string]: object

capabilities.logging?

optional logging?: object

Present if the server supports sending log messages to the client.

Index Signature

[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null

Deprecated

Deprecated as of protocol version 2026-07-28 (SEP-2577); remains in the specification for at least twelve months. Migrate to stderr logging (STDIO servers) or OpenTelemetry.

capabilities.prompts?

optional prompts?: object

Present if the server offers any prompt templates.

capabilities.prompts.listChanged?

optional listChanged?: boolean

Whether this server supports issuing notifications for changes to the prompt list.

capabilities.resources?

optional resources?: object

Present if the server offers any resources to read.

capabilities.resources.listChanged?

optional listChanged?: boolean

Whether this server supports issuing notifications for changes to the resource list.

capabilities.resources.subscribe?

optional subscribe?: boolean

Whether this server supports clients subscribing to resource updates.

capabilities.tasks?

optional tasks?: object

Present if the server supports task creation.

Index Signature

[key: string]: unknown

Deprecated

2025-11-25 wire vocabulary with no SDK runtime; parsed for interoperability only — servers built on this SDK never advertise it.

capabilities.tasks.cancel?

optional cancel?: object

Present if the server supports cancelling tasks.

Index Signature

[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null

capabilities.tasks.list?

optional list?: object

Present if the server supports listing tasks.

Index Signature

[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null

capabilities.tasks.requests?

optional requests?: object

Capabilities for task creation on specific request types.

Index Signature

[key: string]: unknown

capabilities.tasks.requests.tools?

optional tools?: object

Task support for tool requests.

Index Signature

[key: string]: unknown

capabilities.tasks.requests.tools.call?

optional call?: object

Index Signature

[key: ...]: ...

capabilities.tools?

optional tools?: object

Present if the server offers any tools to call.

capabilities.tools.listChanged?

optional listChanged?: boolean

Whether this server supports issuing notifications for changes to the tool list.

instructions?

optional instructions?: string

Instructions describing how to use the server and its features.

This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.

serverInfo

serverInfo: object = ImplementationSchema

Information about the server software implementation.

serverInfo.description?

optional description?: string

An optional human-readable description of what this implementation does.

This can be used by clients or servers to provide context about their purpose and capabilities. For example, a server might describe the types of resources or tools it provides, while a client might describe its intended use case.

serverInfo.icons?

optional icons?: object[]

Optional set of sized icons that the client can display in a user interface.

Clients that support rendering icons MUST support at least the following MIME types:

  • image/png - PNG images (safe, universal compatibility)
  • image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility)

Clients that support rendering icons SHOULD also support:

  • image/svg+xml - SVG images (scalable but requires security precautions)
  • image/webp - WebP images (modern, efficient format)
serverInfo.name

name: string

Intended for programmatic or logical use, but used as a display name in past specs or fallback

serverInfo.title?

optional title?: string

Intended for UI and end-user contexts — optimized to be human-readable and easily understood, even by those unfamiliar with domain-specific terminology.

If not provided, the name should be used for display (except for Tool, where annotations.title should be given precedence over using name, if present).

serverInfo.version

version: string

serverInfo.websiteUrl?

optional websiteUrl?: string

An optional URL of the website for this implementation.

supportedVersions

supportedVersions: string[]

MCP protocol versions this server supports. The client should choose a version from this list for use in subsequent requests.


undefined

getInstructions()

getInstructions(): string | undefined

Defined in: packages/client/src/client/client.ts:1323

After initialization has completed, this may be populated with information about the server's instructions.

Returns

string | undefined

getNegotiatedProtocolVersion()

getNegotiatedProtocolVersion(): string | undefined

Defined in: packages/client/src/client/client.ts:1303

After initialization has completed, this will be populated with the protocol version negotiated during the initialize handshake. When manually reconstructing a transport for reconnection, pass this value to the new transport so it continues sending the required mcp-protocol-version header.

Returns

string | undefined

getPrompt()

getPrompt(params, options?): Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; description?: string; messages: object[]; }>

Defined in: packages/client/src/client/client.ts:1515

Retrieves a prompt by name from the server, passing the given arguments for template substitution.

Parameters
params
_meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

_meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

arguments?

{[key: string]: string; } = ...

Arguments to use for templating the prompt.

name

string = ...

The name of the prompt or prompt template.

options?

RequestOptions

Returns

Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; description?: string; messages: object[]; }>

getProtocolEra()

getProtocolEra(): ProtocolEra | undefined

Defined in: packages/client/src/client/client.ts:1314

After initialization has completed, this returns the protocol era of the connection: 'modern' when the connection negotiated a 2026-07-28+ revision (via server/discover), 'legacy' for the 2025-era initialize handshake, or undefined before the connection is established.

Returns

ProtocolEra | undefined

getServerCapabilities()

getServerCapabilities(): { completions?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; experimental?: {[key: string]: object; }; extensions?: {[key: string]: object; }; logging?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; prompts?: { listChanged?: boolean; }; resources?: { listChanged?: boolean; subscribe?: boolean; }; tasks?: {[key: string]: unknown; cancel?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; list?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; requests?: {[key: string]: unknown; tools?: {[key: string]: unknown; call?: {[key: string]: ... | ... | ... | ... | ... | ... | ...; }; }; }; }; tools?: { listChanged?: boolean; }; } | undefined

Defined in: packages/client/src/client/client.ts:1273

After initialization has completed, this will be populated with the server's reported capabilities.

Returns
Type Literal

{ completions?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; experimental?: {[key: string]: object; }; extensions?: {[key: string]: object; }; logging?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; prompts?: { listChanged?: boolean; }; resources?: { listChanged?: boolean; subscribe?: boolean; }; tasks?: {[key: string]: unknown; cancel?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; list?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; requests?: {[key: string]: unknown; tools?: {[key: string]: unknown; call?: {[key: string]: ... | ... | ... | ... | ... | ... | ...; }; }; }; }; tools?: { listChanged?: boolean; }; }

completions?

optional completions?: object

Present if the server supports sending completions to the client.

Index Signature

[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null

experimental?

optional experimental?: object

Experimental, non-standard capabilities that the server supports.

Index Signature

[key: string]: object

extensions?

optional extensions?: object

Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).

Index Signature

[key: string]: object

logging?

optional logging?: object

Present if the server supports sending log messages to the client.

Index Signature

[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null

Deprecated

Deprecated as of protocol version 2026-07-28 (SEP-2577); remains in the specification for at least twelve months. Migrate to stderr logging (STDIO servers) or OpenTelemetry.

prompts?

optional prompts?: object

Present if the server offers any prompt templates.

prompts.listChanged?

optional listChanged?: boolean

Whether this server supports issuing notifications for changes to the prompt list.

resources?

optional resources?: object

Present if the server offers any resources to read.

resources.listChanged?

optional listChanged?: boolean

Whether this server supports issuing notifications for changes to the resource list.

resources.subscribe?

optional subscribe?: boolean

Whether this server supports clients subscribing to resource updates.

tasks?

optional tasks?: object

Present if the server supports task creation.

Index Signature

[key: string]: unknown

Deprecated

2025-11-25 wire vocabulary with no SDK runtime; parsed for interoperability only — servers built on this SDK never advertise it.

tasks.cancel?

optional cancel?: object

Present if the server supports cancelling tasks.

Index Signature

[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null

tasks.list?

optional list?: object

Present if the server supports listing tasks.

Index Signature

[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null

tasks.requests?

optional requests?: object

Capabilities for task creation on specific request types.

Index Signature

[key: string]: unknown

tasks.requests.tools?

optional tools?: object

Task support for tool requests.

Index Signature

[key: string]: unknown

tasks.requests.tools.call?

optional call?: object

Index Signature

[key: string]: ... | ... | ... | ... | ... | ... | ...

tools?

optional tools?: object

Present if the server offers any tools to call.

tools.listChanged?

optional listChanged?: boolean

Whether this server supports issuing notifications for changes to the tool list.


undefined

getServerVersion()

getServerVersion(): { description?: string; icons?: object[]; name: string; title?: string; version: string; websiteUrl?: string; } | undefined

Defined in: packages/client/src/client/client.ts:1280

After initialization has completed, this will be populated with information about the server's name and version.

Returns
Type Literal

{ description?: string; icons?: object[]; name: string; title?: string; version: string; websiteUrl?: string; }

description?

optional description?: string

An optional human-readable description of what this implementation does.

This can be used by clients or servers to provide context about their purpose and capabilities. For example, a server might describe the types of resources or tools it provides, while a client might describe its intended use case.

icons?

optional icons?: object[]

Optional set of sized icons that the client can display in a user interface.

Clients that support rendering icons MUST support at least the following MIME types:

  • image/png - PNG images (safe, universal compatibility)
  • image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility)

Clients that support rendering icons SHOULD also support:

  • image/svg+xml - SVG images (scalable but requires security precautions)
  • image/webp - WebP images (modern, efficient format)
name

name: string

Intended for programmatic or logical use, but used as a display name in past specs or fallback

title?

optional title?: string

Intended for UI and end-user contexts — optimized to be human-readable and easily understood, even by those unfamiliar with domain-specific terminology.

If not provided, the name should be used for display (except for Tool, where annotations.title should be given precedence over using name, if present).

version

version: string

websiteUrl?

optional websiteUrl?: string

An optional URL of the website for this implementation.


undefined

listen()

listen(filter, options?): Promise<McpSubscription>

Defined in: packages/client/src/client/client.ts:1888

Opens a subscriptions/listen stream (protocol revision 2026-07-28).

Resolves once the server's notifications/subscriptions/acknowledged arrives (the standard request timeout applies to this ack phase). Change notifications delivered on the stream are dispatched to the existing setNotificationHandler registrations — the same handlers the 2025-era unsolicited notifications fire on a legacy connection — so listen() is era-transparent for consumers that already register those.

close() tears the subscription down by aborting the listen request's requestSignal (closes the SSE stream where the transport honors it) AND sending notifications/cancelled referencing the listen request id — both, unconditionally, so any spec-compliant server on any transport sees the cancel. No automatic re-listen — call listen() again to re-establish.

On a 2025-era connection this throws a typed SdkErrorCode.MethodNotSupportedByProtocolVersion steering to resources/subscribe and ClientOptions.listChanged (the legacy unsolicited delivery model still applies there); no transparent shim.

Parameters
filter
promptsListChanged?

boolean = ...

If true, receive notifications/prompts/list_changed.

resourcesListChanged?

boolean = ...

If true, receive notifications/resources/list_changed.

resourceSubscriptions?

string[] = ...

Subscribe to notifications/resources/updated for these resource URIs. Replaces the former resources/subscribe RPC on the 2026-07-28 revision.

toolsListChanged?

boolean = ...

If true, receive notifications/tools/list_changed.

options?

RequestOptions

Returns

Promise<McpSubscription>

listPrompts()

listPrompts(params?, options?): Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; nextCursor?: string; prompts: object[]; }>

Defined in: packages/client/src/client/client.ts:1545

Lists available prompts.

Called without a cursor (the common case), this walks every page and returns the complete aggregated list with no nextCursor; the aggregate is also written to the ResponseCacheStore. Pass an explicit { cursor } to fetch a single page and walk pagination yourself — the per-page path returns the server's raw page (with nextCursor for the next call) and does not write the response cache. The auto-aggregate path is capped by ClientOptions.listMaxPages (default 64); the per-page path is not.

Returns an empty list if the server does not advertise prompts capability (or throws if ClientOptions.enforceStrictCapabilities is enabled).

Parameters
params?
_meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

_meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

cursor?

string = ...

An opaque token representing the current pagination position. If provided, the server should return results starting after this cursor.

options?

CacheableRequestOptions

Returns

Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; nextCursor?: string; prompts: object[]; }>

Example
ts
// No cursor → all pages aggregated for you.
const { prompts } = await client.listPrompts();
console.log(
    'Available prompts:',
    prompts.map(p => p.name)
);
listResources()

listResources(params?, options?): Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; nextCursor?: string; resources: object[]; }>

Defined in: packages/client/src/client/client.ts:1585

Lists available resources.

Called without a cursor (the common case), this walks every page and returns the complete aggregated list with no nextCursor; the aggregate is also written to the ResponseCacheStore. Pass an explicit { cursor } to fetch a single page and walk pagination yourself — the per-page path returns the server's raw page (with nextCursor for the next call) and does not write the response cache. The auto-aggregate path is capped by ClientOptions.listMaxPages (default 64); the per-page path is not.

Returns an empty list if the server does not advertise resources capability (or throws if ClientOptions.enforceStrictCapabilities is enabled).

Parameters
params?
_meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

_meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

cursor?

string = ...

An opaque token representing the current pagination position. If provided, the server should return results starting after this cursor.

options?

CacheableRequestOptions

Returns

Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; nextCursor?: string; resources: object[]; }>

Example
ts
// No cursor → all pages aggregated for you.
const { resources } = await client.listResources();
console.log(
    'Available resources:',
    resources.map(r => r.name)
);
listResourceTemplates()

listResourceTemplates(params?, options?): Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; nextCursor?: string; resourceTemplates: object[]; }>

Defined in: packages/client/src/client/client.ts:1613

Lists available resource URI templates for dynamic resources.

Called without a cursor, this walks every page and returns the complete aggregated list with no nextCursor; the aggregate is also written to the ResponseCacheStore. Pass an explicit { cursor } to fetch a single page — see listResources() for the per-page contract.

Returns an empty list if the server does not advertise resources capability (or throws if ClientOptions.enforceStrictCapabilities is enabled).

Parameters
params?
_meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

_meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

cursor?

string = ...

An opaque token representing the current pagination position. If provided, the server should return results starting after this cursor.

options?

CacheableRequestOptions

Returns

Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; nextCursor?: string; resourceTemplates: object[]; }>

listTools()

listTools(params?, options?): Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; nextCursor?: string; tools: object[]; }>

Defined in: packages/client/src/client/client.ts:2440

Lists available tools.

Called without a cursor (the common case), this walks every page and returns the complete aggregated list with no nextCursor; the aggregate is also written to the ResponseCacheStore (the source for callTool()'s output-schema validation and SEP-2243 Mcp-Param-* header mirroring). Pass an explicit { cursor } to fetch a single page and walk pagination yourself — the per-page path returns the server's raw page (with nextCursor for the next call) and does not write the response cache. The auto-aggregate path is capped by ClientOptions.listMaxPages (default 64); the per-page path is not.

Returns an empty list if the server does not advertise tools capability (or throws if ClientOptions.enforceStrictCapabilities is enabled).

Parameters
params?
_meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

_meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

cursor?

string = ...

An opaque token representing the current pagination position. If provided, the server should return results starting after this cursor.

options?

CacheableRequestOptions

Returns

Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; nextCursor?: string; tools: object[]; }>

Example
ts
// No cursor → all pages aggregated for you.
const { tools } = await client.listTools();
console.log(
    'Available tools:',
    tools.map(t => t.name)
);
notification()

notification(notification, options?): Promise<void>

Defined in: packages/core-internal/src/shared/protocol.ts:1582

Emits a notification, which is a one-way message that does not expect a response.

Parameters
notification
method

string = ...

params?

{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; } = ...

params._meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See MCP specification for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

params._meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

options?

NotificationOptions

Returns

Promise<void>

Inherited from

Protocol.notification

ping()

ping(options?): Promise<{ _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

Defined in: packages/client/src/client/client.ts:1484

Parameters
options?

RequestOptions

Returns

Promise<{ _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

readResource()

readResource(params, options?): Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; contents: ({ _meta?: {[key: string]: unknown; }; mimeType?: string; text: string; uri: string; } | { _meta?: {[key: string]: unknown; }; blob: string; mimeType?: string; uri: string; })[]; }>

Defined in: packages/client/src/client/client.ts:1826

Reads the contents of a resource by URI.

Honours the result's ttlMs/cacheScope (SEP-2549): a still-fresh cached body for the same uri is returned without a round trip (cacheMode: 'use', the default). The cache key is {method, uri} partitioned by the resolved scope — 'private' (the default when the server omits the field) is stored under this client's ClientOptions.cachePartition, so a shared store cannot serve one principal's resource body to another. Unlike the list verbs, a result whose resolved TTL is ≤0 is not stored (resources/read has no derived index and the URI keyspace is unbounded).

Parameters
params
_meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

_meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

uri

string = ...

The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.

Format

uri

options?

CacheableRequestOptions

Returns

Promise<{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; contents: ({ _meta?: {[key: string]: unknown; }; mimeType?: string; text: string; uri: string; } | { _meta?: {[key: string]: unknown; }; blob: string; mimeType?: string; uri: string; })[]; }>

registerCapabilities()

registerCapabilities(capabilities): void

Defined in: packages/client/src/client/client.ts:762

Registers new capabilities. This can only be called before connecting to a transport.

The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).

Parameters
capabilities
elicitation?

{[key: string]: string | number | boolean | {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; form?: {[key: string]: string | number | boolean | {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; applyDefaults?: boolean; }; url?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; } = ...

Present if the client supports eliciting user input.

elicitation.form?

{[key: string]: string | number | boolean | {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; applyDefaults?: boolean; } = ...

elicitation.form.applyDefaults?

boolean = ...

elicitation.url?

{[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; } = ...

experimental?

{[key: string]: object; } = ...

Experimental, non-standard capabilities that the client supports.

extensions?

{[key: string]: object; } = ...

Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).

roots?

{ listChanged?: boolean; } = ...

Present if the client supports listing roots.

Deprecated

Deprecated as of protocol version 2026-07-28 (SEP-2577); remains in the specification for at least twelve months. Migrate to passing paths via tool parameters, resource URIs, or configuration.

roots.listChanged?

boolean = ...

Whether the client supports issuing notifications for changes to the roots list.

sampling?

{ context?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; tools?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; } = ...

Present if the client supports sampling from an LLM.

Deprecated

Deprecated as of protocol version 2026-07-28 (SEP-2577); remains in the specification for at least twelve months. Migrate to calling LLM provider APIs directly.

sampling.context?

{[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; } = ...

Present if the client supports context inclusion via includeContext parameter. If not declared, servers SHOULD only use includeContext: "none" (or omit it).

sampling.tools?

{[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; } = ...

Present if the client supports tool use via tools and toolChoice parameters.

tasks?

{[key: string]: unknown; cancel?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; list?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; requests?: {[key: string]: unknown; elicitation?: {[key: string]: unknown; create?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | ...[] | null; }; }; sampling?: {[key: string]: unknown; createMessage?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | ...[] | null; }; }; }; } = ...

Present if the client supports task creation.

Deprecated

2025-11-25 wire vocabulary with no SDK runtime; parsed for interoperability only — servers built on this SDK never advertise it.

tasks.cancel?

{[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; } = ...

Present if the client supports cancelling tasks.

tasks.list?

{[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; } = ...

Present if the client supports listing tasks.

tasks.requests?

{[key: string]: unknown; elicitation?: {[key: string]: unknown; create?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | ...[] | null; }; }; sampling?: {[key: string]: unknown; createMessage?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | ...[] | null; }; }; } = ...

Capabilities for task creation on specific request types.

tasks.requests.elicitation?

{[key: string]: unknown; create?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | ...[] | null; }; } = ...

Task support for elicitation requests.

tasks.requests.elicitation.create?

{[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | ...[] | null; } = ...

tasks.requests.sampling?

{[key: string]: unknown; createMessage?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | ...[] | null; }; } = ...

Task support for sampling requests.

tasks.requests.sampling.createMessage?

{[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | ...[] | null; } = ...

Returns

void

removeNotificationHandler()

removeNotificationHandler(method): void

Defined in: packages/core-internal/src/shared/protocol.ts:1841

Removes the notification handler for the given method.

Parameters
method

string

Returns

void

Inherited from

Protocol.removeNotificationHandler

removeRequestHandler()

removeRequestHandler(method): void

Defined in: packages/core-internal/src/shared/protocol.ts:1758

Removes the request handler for the given method.

Parameters
method

string

Returns

void

Inherited from

Protocol.removeRequestHandler

request()
Call Signature

request<M>(request, options?): Promise<ResultTypeMap[M]>

Defined in: packages/core-internal/src/shared/protocol.ts:1259

Sends a request and waits for a response.

For spec methods the result schema is resolved automatically from the method name and the return type is method-keyed. For custom (non-spec) methods, pass a resultSchema as the second argument; the response is validated against it and the return type is inferred from the schema.

Do not use this method to emit notifications! Use notification() instead.

Type Parameters
M

M extends RequestMethod

Parameters
request
method

M

params?

Record<string, unknown>

options?

RequestOptions

Returns

Promise<ResultTypeMap[M]>

Inherited from

Protocol.request

Call Signature

request<T>(request, resultSchema, options?): Promise<InferOutput<T>>

Defined in: packages/core-internal/src/shared/protocol.ts:1263

Sends a request and waits for a response.

For spec methods the result schema is resolved automatically from the method name and the return type is method-keyed. For custom (non-spec) methods, pass a resultSchema as the second argument; the response is validated against it and the return type is inferred from the schema.

Do not use this method to emit notifications! Use notification() instead.

Type Parameters
T

T extends StandardSchemaV1<unknown, unknown>

Parameters
request
method

string = ...

params?

{[key: string]: unknown; _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; } = ...

params._meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

params._meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

resultSchema

T

options?

RequestOptions

Returns

Promise<InferOutput<T>>

Inherited from

Protocol.request

sendRootsListChanged()

sendRootsListChanged(): Promise<void>

Defined in: packages/client/src/client/client.ts:2565

Notifies the server that the client's root list has changed. Requires the roots.listChanged capability.

Returns

Promise<void>

Deprecated

Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains functional during the deprecation window (at least twelve months). Migrate to passing paths via tool parameters, resource URIs, or configuration.

setLoggingLevel()

setLoggingLevel(level, options?): Promise<{ _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

Defined in: packages/client/src/client/client.ts:1510

Sets the minimum severity level for log messages sent by the server.

Parameters
level

LoggingLevel

options?

RequestOptions

Returns

Promise<{ _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

Deprecated

Deprecated as of protocol version 2026-07-28 (SEP-2577). Remains functional during the deprecation window (at least twelve months). Migrate to stderr logging (STDIO servers) or OpenTelemetry.

setNotificationHandler()
Call Signature

setNotificationHandler<M>(method, handler): void

Defined in: packages/core-internal/src/shared/protocol.ts:1784

Registers a handler to invoke when this protocol object receives a notification with the given method.

Note that this will replace any previous notification handler for the same method.

For spec methods, pass (method, handler); the notification is parsed with the spec schema. For custom (non-spec) methods, pass (method, schemas, handler); params are validated against schemas.params and the handler receives the parsed params object directly. The raw notification is passed as the second argument; _meta is recoverable via notification.params?._meta (minus the reserved io.modelcontextprotocol/* envelope keys, which the protocol layer lifts out before dispatch).

Type Parameters
M

M extends NotificationMethod

Parameters
method

M

handler

(notification) => void | Promise<void>

Returns

void

Inherited from

Protocol.setNotificationHandler

Call Signature

setNotificationHandler<P>(method, schemas, handler): void

Defined in: packages/core-internal/src/shared/protocol.ts:1788

Registers a handler to invoke when this protocol object receives a notification with the given method.

Note that this will replace any previous notification handler for the same method.

For spec methods, pass (method, handler); the notification is parsed with the spec schema. For custom (non-spec) methods, pass (method, schemas, handler); params are validated against schemas.params and the handler receives the parsed params object directly. The raw notification is passed as the second argument; _meta is recoverable via notification.params?._meta (minus the reserved io.modelcontextprotocol/* envelope keys, which the protocol layer lifts out before dispatch).

Type Parameters
P

P extends StandardSchemaV1<unknown, unknown>

Parameters
method

string

schemas
params

P

handler

(params, notification) => void | Promise<void>

Returns

void

Inherited from

Protocol.setNotificationHandler

setRequestHandler()
Call Signature

setRequestHandler<M>(method, handler): void

Defined in: packages/core-internal/src/shared/protocol.ts:1668

Registers a handler to invoke when this protocol object receives a request with the given method.

Note that this will replace any previous request handler for the same method.

For spec methods, pass (method, handler); the request is parsed with the spec schema and the handler receives the typed Request. For custom (non-spec) methods, pass (method, schemas, handler); params are validated against schemas.params and the handler receives the parsed params object directly. Supplying schemas.result types the handler's return value.

Type Parameters
M

M extends RequestMethod

Parameters
method

M

handler

(request, ctx) => HandlerResultTypeMap[M] | Promise<HandlerResultTypeMap[M]>

Returns

void

Example

Custom request method

ts
const SearchParams = z.object({ query: z.string(), limit: z.number().optional() });
const SearchResult = z.object({ hits: z.array(z.string()) });

protocol.setRequestHandler('acme/search', { params: SearchParams, result: SearchResult }, async (params, _ctx) => {
    return { hits: [`result for ${params.query}`] };
});
Inherited from

Protocol.setRequestHandler

Call Signature

setRequestHandler<P, R>(method, schemas, handler): void

Defined in: packages/core-internal/src/shared/protocol.ts:1672

Registers a handler to invoke when this protocol object receives a request with the given method.

Note that this will replace any previous request handler for the same method.

For spec methods, pass (method, handler); the request is parsed with the spec schema and the handler receives the typed Request. For custom (non-spec) methods, pass (method, schemas, handler); params are validated against schemas.params and the handler receives the parsed params object directly. Supplying schemas.result types the handler's return value.

Type Parameters
P

P extends StandardSchemaV1<unknown, unknown>

R

R extends StandardSchemaV1<unknown, unknown> | undefined = undefined

Parameters
method

string

schemas
params

P

result?

R

handler

(params, ctx) => InferHandlerResult<R> | Promise<InferHandlerResult<R>>

Returns

void

Example

Custom request method

ts
const SearchParams = z.object({ query: z.string(), limit: z.number().optional() });
const SearchResult = z.object({ hits: z.array(z.string()) });

protocol.setRequestHandler('acme/search', { params: SearchParams, result: SearchResult }, async (params, _ctx) => {
    return { hits: [`result for ${params.query}`] };
});
Inherited from

Protocol.setRequestHandler

setVersionNegotiation()

setVersionNegotiation(options): void

Defined in: packages/client/src/client/client.ts:778

Configure protocol version negotiation before connecting (equivalent to passing versionNegotiation at construction time). Can only be called before connecting to a transport. Passing undefined clears a previously configured negotiation, restoring the default 'legacy' posture.

See ClientOptions.versionNegotiation for the mode semantics.

Parameters
options

VersionNegotiationOptions | undefined

Returns

void

subscribeResource()

subscribeResource(params, options?): Promise<{ _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

Defined in: packages/client/src/client/client.ts:1857

Subscribes to change notifications for a resource. The server must support resource subscriptions.

Parameters
params
_meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

_meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

uri

string = ...

The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.

Format

uri

options?

RequestOptions

Returns

Promise<{ _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

unsubscribeResource()

unsubscribeResource(params, options?): Promise<{ _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

Defined in: packages/client/src/client/client.ts:1862

Unsubscribes from change notifications for a resource.

Parameters
params
_meta?

{[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; } = ...

See General fields: _meta for notes on _meta usage.

{ taskId: string; } = ...

If specified, this request is related to the provided task.

string = ...

_meta.progressToken?

string | number = ...

If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

uri

string = ...

The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.

Format

uri

options?

RequestOptions

Returns

Promise<{ _meta?: {[key: string]: unknown; io.modelcontextprotocol/related-task?: { taskId: string; }; progressToken?: string | number; }; }>

Interfaces

McpSubscription

Defined in: packages/client/src/client/client.ts:416

A handle to an open subscriptions/listen stream (protocol revision 2026-07-28). Change notifications delivered on the stream dispatch to the existing Client.setNotificationHandler registrations.

Properties

closed

readonly closed: Promise<"local" | "graceful" | "remote">

Defined in: packages/client/src/client/client.ts:441

Resolves exactly once when the subscription has terminated. Never rejects — this is an observation, not an operation.

  • 'local' — you called close (or aborted the RequestOptions.signal you passed to listen()).
  • 'graceful' — the server ended the subscription deliberately by sending the empty subscriptions/listen response (e.g. on shutdown).
  • 'remote' — the stream ended without a response, or the transport dropped — an unexpected disconnect. Re-listen if you still want events.
honoredFilter

readonly honoredFilter: object

Defined in: packages/client/src/client/client.ts:421

The subset of the requested filter the server agreed to honor (from notifications/subscriptions/acknowledged).

promptsListChanged?

optional promptsListChanged?: boolean

If true, receive notifications/prompts/list_changed.

resourcesListChanged?

optional resourcesListChanged?: boolean

If true, receive notifications/resources/list_changed.

resourceSubscriptions?

optional resourceSubscriptions?: string[]

Subscribe to notifications/resources/updated for these resource URIs. Replaces the former resources/subscribe RPC on the 2026-07-28 revision.

toolsListChanged?

optional toolsListChanged?: boolean

If true, receive notifications/tools/list_changed.

Methods

close()

close(): Promise<void>

Defined in: packages/client/src/client/client.ts:428

Tears the subscription down. Idempotent. Aborts the listen request's stream (where the transport supports it) AND sends notifications/cancelled referencing the listen request id — both, always, so close works on any transport.

Returns

Promise<void>

Type Aliases

CacheableRequestOptions

CacheableRequestOptions = RequestOptions & object

Defined in: packages/client/src/client/client.ts:369

RequestOptions extended with the per-call cache disposition for the cacheable verbs (listTools() / listPrompts() / listResources() / listResourceTemplates() / readResource()). See CacheMode.

Type Declaration

cacheMode?

optional cacheMode?: CacheMode

'use' (default) serves a still-fresh cached entry without a round trip; 'refresh' always fetches and re-stores; 'bypass' fetches without consulting or writing the cache. Applies to the no-cursor auto-aggregate path on the list verbs and to readResource; ignored elsewhere.


CallToolRequestOptions

CallToolRequestOptions = RequestOptions & object

Defined in: packages/client/src/client/client.ts:387

Options for Client.callTool. Extends RequestOptions with an escape hatch for callers that already hold the tool definition (e.g. from a previous session or configuration) — pass it via toolDefinition so SEP-2243 Mcp-Param-* header mirroring can run without a prior tools/list.

Type Declaration

toolDefinition?

optional toolDefinition?: Tool

The tool definition to use for SEP-2243 Mcp-Param-* header mirroring on a 2026-07-28 connection over Streamable HTTP, AND for output-schema validation of the result. When set, the client uses this definition's inputSchema and outputSchema instead of (and without consulting) the cached tools/list result, so the two derived views agree.


ClientOptions

ClientOptions = ProtocolOptions & object

Defined in: packages/client/src/client/client.ts:161

Type Declaration

cachePartition?

optional cachePartition?: string

Opaque per-principal identifier for response-cache writes whose server-reported cacheScope is 'private' (the spec's "MUST NOT share across authorization contexts"). Within the connected server's namespace, 'public'-scoped entries live at the shared [serverIdentity, ''] partition and 'private'-scoped entries at [serverIdentity, cachePartition]. Set this to a stable identity of the authorization context (e.g. the auth subject) when one responseCacheStore backs several principals; with the default '' every entry — public or private — lives at the server's shared partition, which is the safe single-tenant posture.

capabilities?

optional capabilities?: ClientCapabilities

Capabilities to advertise as being supported by this client.

defaultCacheTtlMs?

optional defaultCacheTtlMs?: number

TTL (ms) applied when a cacheable result arrives without a ttlMs field. Default 0 — a result without an explicit hint is never served from cache (every call refetches), but it is still stored so the tools/list-derived index that callTool's SEP-2243 mirroring and output-schema validation read keeps working regardless. The spec defines absent-or-≤0 as "immediately stale".

inputRequired?

optional inputRequired?: InputRequiredOptions

Multi-round-trip auto-fulfilment (protocol revision 2026-07-28).

On the 2026-07-28 era, servers obtain client input (elicitation, sampling, roots) by answering tools/call, prompts/get, or resources/read with an input_required result instead of sending a server→client request. By default the client fulfils those embedded requests automatically through the SAME handlers registered via setRequestHandler (e.g. elicitation/create), then retries the original call with the collected inputResponses and a byte-exact echo of the opaque requestState, on a fresh request id, up to maxRounds rounds. client.callTool() (and its siblings) keep returning their plain result type — the interactive rounds happen inside the call.

Set autoFulfill: false for manual mode: an input_required response then surfaces as a typed error unless the individual call passes allowInputRequired: true (pair it with withInputRequired() on the explicit-schema path to type both outcomes).

Has no effect on 2025-era connections, which have no input_required vocabulary.

jsonSchemaValidator?

optional jsonSchemaValidator?: jsonSchemaValidator

JSON Schema validator for tool output validation.

The validator is used to validate structured content returned by tools against their declared output schemas.

Default

Runtime-selected validator (AJV-backed on Node.js, @cfworker/json-schema-backed on browser/workerd runtimes)

listChanged?

optional listChanged?: ListChangedHandlers

Configure handlers for list changed notifications (tools, prompts, resources).

Example
ts
const client = new Client(
    { name: 'my-client', version: '1.0.0' },
    {
        listChanged: {
            tools: {
                onChanged: (error, tools) => {
                    if (error) {
                        console.error('Failed to refresh tools:', error);
                        return;
                    }
                    console.log('Tools updated:', tools);
                }
            },
            prompts: {
                onChanged: (error, prompts) => console.log('Prompts updated:', prompts)
            }
        }
    }
);
listMaxPages?

optional listMaxPages?: number

Cap on the number of pages the auto-aggregating listTools() / listPrompts() / listResources() / listResourceTemplates() walk fetches before throwing (a defence against a server whose nextCursor never converges). 0 disables the cap. Default: 64. Applies only to the no-argument auto-aggregate path; an explicit-cursor per-page call is never capped.

responseCacheStore?

optional responseCacheStore?: ResponseCacheStore

The response-cache store backing the client's derived views (the cached tools/list result that callTool's output validation and SEP-2243 header mirroring read) and the SEP-2549 cache-hint serving on the cacheable verbs. Defaults to a fresh InMemoryResponseCacheStore per client.

Entries are automatically scoped by connected-server identity (derived from serverInfo after connect) AND, for 'private'-scoped results, by cachePartition — encoded collision-free via JSON.stringify, so a server cannot craft a serverInfo that bleeds into another server's namespace or another principal's slot. One store may therefore back several clients (e.g. a host pool against the same server, or one persistent KV across servers); list_changed evictions are scoped to the connected server's partitions, so co-tenants are unaffected. Set cachePartition to your principal identifier (e.g. the auth subject) when sharing across principals. Note serverInfo is self-reported — a server that deliberately impersonates another's name/version shares its 'public' slot; the per-principal isolation via cachePartition holds regardless.

versionNegotiation?

optional versionNegotiation?: VersionNegotiationOptions

Opt-in protocol version negotiation (protocol revision 2026-07-28 and later).

The default is 'legacy': absent (or mode: 'legacy'), connect() runs the plain 2025 sequence, byte-identical to today's behavior (no probe, no new headers). Opt into 'auto' or pin to talk to a 2026-07-28 server.

  • mode: 'auto'connect() probes the server with server/discover first: definitive modern evidence selects the modern era; definitive legacy signals (and anything unrecognized) fall back to the plain legacy initialize handshake on the same connection, byte-equivalent to a 2025 client. A network outage rejects with a typed connect error. A probe timeout is transport-aware: on stdio it indicates a legacy server (some legacy servers never answer unknown pre-initialize requests) and falls back to initialize on the same stream; on HTTP it rejects with a typed timeout error (silence on a deployed server is an outage, not a legacy signal).
  • mode: { pin: '2026-07-28' } — modern era at exactly the pinned revision; no probe-and-fallback: anything else fails loudly.

Probe policy lives under probe: { timeoutMs?, maxRetries? }; the probe inherits the client's standard request timeout unless overridden, and maxRetries (default 0) governs timeout re-sends only — the spec-mandated -32022 corrective continuation is never counted against it.

Once a modern era is negotiated, the client automatically attaches the per-request _meta envelope (the reserved protocol-version / client-info / client-capabilities keys) to every outgoing request and notification; user-supplied _meta keys take precedence over the auto-attached ones.


ConnectOptions

ConnectOptions = RequestOptions & object

Defined in: packages/client/src/client/client.ts:328

Options for Client.connect. Extends RequestOptions (the timeout/signal apply to the connect-time handshake or probe) with the cached-era-verdict knob.

Type Declaration

prior?

optional prior?: PriorDiscovery

A cached era verdict, taking precedence over versionNegotiation: { kind: 'modern', discover } adopts a prior DiscoverResult with zero round trips (throws SdkError(EraNegotiationFailed) on no 2026-07-28+ overlap); { kind: 'legacy' } skips the probe and runs the plain legacy initialize handshake. Freshness is the supplying host's responsibility — see PriorDiscovery. Reuse only within one authorization context.

Functions

getSupportedElicitationModes()

getSupportedElicitationModes(capabilities): object

Defined in: packages/client/src/client/client.ts:143

Determines which elicitation modes are supported based on declared client capabilities.

According to the spec:

  • An empty elicitation capability object defaults to form mode support (backwards compatibility)
  • URL mode is only supported if explicitly declared

Parameters

capabilities

{[key: string]: string | number | boolean | {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; form?: {[key: string]: string | number | boolean | {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; applyDefaults?: boolean; }; url?: {[key: string]: string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null)[] | null; } | string | number | boolean | { [x: string]: string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | number | boolean | ... | (string | ... 4 more ... | null)[] | null)[] | null)[] | null)[] | null; } | (string | ... 4 more ... | null)[] | null[] | null; }; } | undefined

The client's elicitation capabilities

Returns

object

An object indicating which modes are supported

supportsFormMode

supportsFormMode: boolean

supportsUrlMode

supportsUrlMode: boolean