ClientCapabilities

Capabilities a client advertises during initialization.

Members

Functions

forVersion
ClientCapabilities forVersion(ProtocolVersion v)

Project these capabilities to the wire shape for protocol version v, stripping any field newer than v and migrating tasks to the draft extensions map. roots/rootsListChanged, a bare sampling, and experimental exist in every supported version and pass through unchanged. elicitation applies from 2025-06-18, so it is gated to >= 2025-06-18 (a client that set only an elicitation submode still projects a bare elicitation there). The sampling/elicitation sub-objects (sampling.tools/sampling.context, elicitation.form/elicitation.url) apply from 2025-11-25 and are stripped below that. tasks is a first-class client capability in the stable 2025-11-25 era (and any future stable revision >= 2025-11-25); the draft schema has no top-level client tasks, so for draft it is folded into extensions[tasksExtensionKey]. The extensions negotiation map itself is draft-only.

missingFrom
Nullable!ClientCapabilities missingFrom(ClientCapabilities declared)

Compute the capabilities this object requires that are NOT present in declared. Used by a server to build the data.requiredCapabilities payload of a -32003 MissingRequiredClientCapabilityError: this is the set a request needs, declared is what the client actually advertised, and the result is a ClientCapabilities containing exactly the missing ones. A capability is satisfied when the client declared at least the same presence flag (sub-capability flags imply their parent presence here, in line with toJson). The result is null iff every requirement is met; a non-null value carries exactly the unmet ones. The experimental and extensions Json maps are compared by required-key presence: any required key absent from declared is reported.

supports
bool supports(ClientCapability cap)

Whether cap is advertised. The single lookup that owns the capability->field mapping; transports gate sample/elicit/listRoots through here rather than re-deriving it.

Variables

elicitation
bool elicitation;

presence (>= 2025-06-18); empty object => form mode only

elicitationForm
bool elicitationForm;

elicitation.form submode (2025-11-25): declares support for schema-driven form elicitation. Implies elicitation. An empty elicitation object is equivalent to declaring form mode only, so this is treated as set when a peer advertises a bare {}.

elicitationUrl
bool elicitationUrl;

elicitation.url submode (2025-11-25): declares support for URL-mode elicitation (elicitUrl). Implies elicitation. Servers MUST NOT send URL-mode elicitation requests unless this is advertised.

extensions
Json extensions;

draft Extension Negotiation: map of extension identifiers (e.g. "io.modelcontextprotocol/ui") to per-extension settings objects. Distinct from experimental.

roots
bool roots;

presence (with optional listChanged below)

sampling
bool sampling;

presence (with optional tools/context sub-caps below)

samplingContext
bool samplingContext;

sampling.context sub-capability (soft-deprecated): gates the includeContext values thisServer/allServers. Implies sampling.

samplingTools
bool samplingTools;

sampling.tools sub-capability (>= 2025-11-25): declares support for tool use in sampling requests. Servers MUST NOT send tool-enabled sampling requests unless this is advertised. Implies sampling.

tasks
Nullable!TasksCapability tasks;

task-augmented requests (>= 2025-11-25); client form carries only the requests map (its list/cancel fields are server-only).