McpProtocol class

MCP Protocol Version constants and definitions

Annotations
  • @immutable

Constructors

McpProtocol()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

defaultsJsonSchemaDialect(String version) bool
Whether tool schemas emitted to the negotiated version should carry an explicit $schema: <2020-12> default annotation (SEP-1613). Applied for 2025-11-25 and later peers; older peers keep prior output.
isStateless(String version) bool
Whether the version uses the stateless core (no handshake/session): client info/caps in _meta per request, server/discover for caps, MCP-Protocol-Version the sole version signal. Introduced 2026-07-28.
isSupported(String version) bool
Check if a version is supported
negotiate(List<String> clientVersions, List<String> serverVersions) String?
Get the highest compatible version between client and server
negotiateWithDateFallback(String? clientVersion, List<String> serverVersions) String?
Advanced version negotiation with date-based compatibility
requiresProtocolHeader(String version) bool
Whether the negotiated version understands the MCP-Protocol-Version HTTP header (mandatory after negotiation from 2025-06-18 onwards).
supportsBatching(String version) bool
Whether the negotiated version supports JSON-RPC batching. A bounded legacy set — batching was removed in 2025-06-18 (PR #416), so this is intentionally not an "at least" gate.
supportsElicitation(String version) bool
Whether the negotiated version knows the elicitation/create server → client request (introduced in 2025-06-18, carried forward).
supportsIconsAndSamplingTools(String version) bool
Whether the negotiated version understands Tool.icons, sampling tools / toolChoice, and URL-mode elicitation (introduced in 2025-11-25, carried forward).
supportsStructuredToolOutput(String version) bool
Whether the negotiated version understands Tool.outputSchema, CallToolResult.structuredContent, and resource_link content (introduced in 2025-06-18, carried forward).
toolErrorsAsResult(String version) bool
Whether tool execution errors are returned as an isError CallToolResult (so the model can self-correct) rather than a JSON-RPC protocol error. Clarified in 2025-11-25 (SEP-1303) and carried forward. Older negotiated versions keep the prior protocol-error behavior.
withDefaultSchemaDialect(Map<String, dynamic> schema) Map<String, dynamic>
Returns a copy of schema annotated with the default JSON Schema 2020-12 dialect ($schema) when it is an object-type schema that does not already declare a $schema. Free-form schemas that already carry a $schema, or non-object schema fragments, are returned unchanged.

Constants

errorMethodNotFound → const int
jsonRpcVersion → const String
jsonSchemaDialect2020_12 → const String
Canonical URI of the JSON Schema 2020-12 dialect — the default dialect for tool inputSchema / outputSchema as of 2025-11-25 (SEP-1613).
latest → const String
methodCallTool → const String
methodComplete → const String
methodGetPrompt → const String
methodInitialize → const String
methodInitialized → const String
methodListPrompts → const String
methodListResources → const String
methodListTools → const String
methodReadResource → const String
supportedVersions → const List<String>
All supported versions in order of preference (newest first).
v2024_11_05 → const String
v2025_03_26 → const String
v2025_06_18 → const String
v2025_11_25 → const String
v2026_07_28 → const String
Protocol version 2026-07-28 — BREAKING: stateless core (removes the initialize/initialized handshake and Mcp-Session-Id; client info/caps ride _meta on every request; server/discover fetches caps on demand), Extensions framework, Tasks extension, auth hardening, deprecations. Adopted as an additive, version-gated parallel path — the handshake path stays for ≤2025-11-25 peers. Deliberately NOT in supportedVersions until the stateless request path lands, so handshake negotiation does not advertise it yet. See docs/STATELESS-COEXISTENCE-DESIGN.md.