McpProtocol class

MCP protocol versions and constants

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

defaultSchemaDialect(String version) String?
The default JSON Schema dialect a peer should assume for schemas that omit $schema under the negotiated version. 2025-11-25 pins 2020-12 (SEP-1613); earlier revisions left the dialect unspecified (returns null — callers must not stamp a dialect for those peers).
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 as the sole version signal. Introduced 2026-07-28. See docs/STATELESS-COEXISTENCE-DESIGN.md.
isVersionSupported(String version) bool
Check if a version is supported
negotiateVersion(List<String> clientVersions, List<String> serverVersions) String?
Get the best common version from client and server versions
requiresProtocolHeader(String version) bool
Whether the negotiated version requires the MCP-Protocol-Version HTTP header on every post-handshake request (mandatory from 2025-06-18).
schemaWithDefaultDialect(Map<String, dynamic> schema, String version) Map<String, dynamic>
Return a copy of schema annotated with the 2020-12 $schema dialect when (a) the negotiated version pins a default dialect and (b) the schema does not already declare its own $schema. Free-form schemas that already carry a $schema — or any schema under an older negotiated revision — are returned unchanged. Non-mutating: the input map is never modified.
supportsBatching(String version) bool
Whether the negotiated version supports JSON-RPC batching. Removed in 2025-06-18.
supportsElicitation(String version) bool
Whether the negotiated version understands elicitation/create (introduced 2025-06-18).
supportsIconsAndSamplingTools(String version) bool
Whether the negotiated version understands icons, sampling tools / toolChoice, URL-mode elicitation, multi-select / default-valued elicitation primitives, and Implementation.description (all introduced in 2025-11-25). Mirrors the server package's McpProtocol.supportsIconsAndSamplingTools predicate so both sides gate the same behavior on the same negotiated revision.
supportsImplementationDescription(String version) bool
Whether the negotiated version carries Implementation.description on clientInfo / serverInfo (2025-11-25). Older peers ignore an emitted description, so emission is additive; this predicate exists so callers may suppress it for strict older-revision fixtures.
supportsSamplingTools(String version) bool
Whether the negotiated version understands sampling tool calling — the tools / toolChoice request fields and tool-call results on sampling/createMessage (SEP: sampling with tools, 2025-11-25). Alias of supportsIconsAndSamplingTools scoped to the sampling surface.
supportsUrlElicitation(String version) bool
Whether the negotiated version understands URL-mode elicitation (mode: "url", SEP-1036), multi-select enums (SEP-1330), and default values in elicitation primitives (SEP-1034). All landed in 2025-11-25.

Constants

defaultVersion → const String
Default protocol version (latest supported).
errorInternal → const int
errorInvalidParams → const int
errorInvalidRequest → const int
errorMethodNotFound → const int
errorParse → const int
Standard error codes
errorPromptNotFound → const int
errorProtocolError → const int
errorResourceAccessDenied → const int
errorResourceNotFound → const int
MCP-specific error codes
errorToolExecutionFailed → const int
errorToolNotFound → const int
jsonRpcVersion → const String
JSON-RPC version
jsonSchemaDialect2020_12 → const String
Canonical JSON Schema dialect for tool inputSchema / outputSchema and elicitation requestedSchema when the negotiated revision is 2025-11-25+ (SEP-1613). A schema that omits $schema is interpreted against this dialect; existing schemas that declare their own $schema are left untouched.
methodAuthorize → const String
Authorization methods (2025-03-26)
methodCallTool → const String
methodCancelled → const String
methodCancelTool → const String
methodCapabilitiesUpdate → const String
2025-03-26 New methods
methodComplete → const String
methodGetPrompt → const String
methodInitialize → const String
Standard MCP methods
methodInitialized → const String
methodListPrompts → const String
methodListResources → const String
methodListResourceTemplates → const String
methodListRoots → const String
methodListTools → const String
methodLog → const String
methodProgress → const String
Notifications
methodPromptListChanged → const String
methodReadResource → const String
methodRefresh → const String
methodResourceListChanged → const String
methodResourceUpdated → const String
methodRevoke → const String
methodRootListChanged → const String
methodSetLevel → const String
methodShutdown → const String
methodSubscribeResource → const String
methodToken → const String
methodToolListChanged → const String
methodUnsubscribeResource → const String
progressTokenNumber → const String
progressTokenString → const String
Progress token types
supportedVersions → const List<String>
Supported protocol versions in order of preference (newest first).
v2024_11_05 → const String
Protocol version 2024-11-05
v2025_03_26 → const String
Protocol version 2025-03-26
v2025_06_18 → const String
Protocol version 2025-06-18 — adds elicitation, structured tool output, resource_link, OAuth Resource Server, MCP-Protocol-Version header. Removes JSON-RPC batching.
v2025_11_25 → const String
Protocol version 2025-11-25 — adds icons, sampling tool calling (tools / toolChoice), URL-mode elicitation, OIDC Discovery, Client ID Metadata Documents, default values in elicitation primitives.
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 (Roots/Sampling/Logging). Adopted as an additive, version-gated parallel path — the handshake path stays for ≤2025-11-25 peers. NOT yet in supportedVersions until the stateless request path lands (opt-in via a stateless connection mode).