McpProtocol class
MCP protocol versions and constants
Constructors
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
$schemaunder the negotiatedversion. 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
versionuses the stateless core (no handshake/session): client info/caps in_metaper request,server/discoverfor caps,MCP-Protocol-Versionas the sole version signal. Introduced 2026-07-28. Seedocs/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
versionrequires theMCP-Protocol-VersionHTTP 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
schemaannotated with the 2020-12$schemadialect when (a) the negotiatedversionpins 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
versionsupports JSON-RPC batching. Removed in 2025-06-18. -
supportsElicitation(
String version) → bool -
Whether the negotiated
versionunderstandselicitation/create(introduced 2025-06-18). -
supportsIconsAndSamplingTools(
String version) → bool -
Whether the negotiated
versionunderstandsicons, samplingtools/toolChoice, URL-mode elicitation, multi-select / default-valued elicitation primitives, andImplementation.description(all introduced in 2025-11-25). Mirrors the server package'sMcpProtocol.supportsIconsAndSamplingToolspredicate so both sides gate the same behavior on the same negotiated revision. -
supportsImplementationDescription(
String version) → bool -
Whether the negotiated
versioncarriesImplementation.descriptiononclientInfo/serverInfo(2025-11-25). Older peers ignore an emitteddescription, so emission is additive; this predicate exists so callers may suppress it for strict older-revision fixtures. -
supportsSamplingTools(
String version) → bool -
Whether the negotiated
versionunderstands sampling tool calling — thetools/toolChoicerequest fields and tool-call results onsampling/createMessage(SEP: sampling with tools, 2025-11-25). Alias of supportsIconsAndSamplingTools scoped to the sampling surface. -
supportsUrlElicitation(
String version) → bool -
Whether the negotiated
versionunderstands 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/outputSchemaand elicitationrequestedSchemawhen the negotiated revision is 2025-11-25+ (SEP-1613). A schema that omits$schemais interpreted against this dialect; existing schemas that declare their own$schemaare 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/initializedhandshake andMcp-Session-Id; client info/caps ride_metaon every request;server/discoverfetches 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).