McpRequestMeta class

Reverse-DNS _meta keys and typed read/write helpers for the 2026-07-28 stateless core (SEP-2577).

On the stateless path there is no initialize handshake, so a client attaches its identity and per-request capabilities to the _meta object of EVERY request under the reserved io.modelcontextprotocol/* prefix (the second label modelcontextprotocol is reserved for MCP use). The server reads them per request and MUST NOT infer capabilities from any prior request.

These are additive helpers layered on top of the existing _meta passthrough — they neither consume nor rewrite unknown _meta keys, so a legacy (handshake) request that never sets them is unaffected.

Draft schema (schema/draft/schema.ts, RequestMetaObject / ResultMetaObject) is the source of truth for the key names and value shapes; see docs/STATELESS-COEXISTENCE-DESIGN.md §3.2.

Annotations
  • @immutable

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

build({required String protocolVersion, required Map<String, dynamic> clientCapabilities, Map<String, dynamic>? clientInfo, String? logLevel, Map<String, dynamic>? extra}) Map<String, dynamic>
Build a request _meta object carrying the reverse-DNS stateless keys.
buildResult({required Map<String, dynamic> serverInfo, Map<String, dynamic>? extra}) Map<String, dynamic>
Build a result _meta object carrying serverInfo, merging extra first so the reserved key wins. Returns a fresh map.
readClientCapabilities(Object? meta) Map<String, dynamic>?
Read io.modelcontextprotocol/clientCapabilities from a request _meta. Returns null when absent (distinct from an empty object, which means "declared, no optional capabilities").
readClientInfo(Object? meta) Map<String, dynamic>?
Read io.modelcontextprotocol/clientInfo from a request _meta.
readLogLevel(Object? meta) String?
Read io.modelcontextprotocol/logLevel from a request _meta.
readProtocolVersion(Object? meta) String?
Read io.modelcontextprotocol/protocolVersion from a request _meta.
readServerInfo(Object? meta) Map<String, dynamic>?
Read io.modelcontextprotocol/serverInfo from a result _meta.
readSubscriptionId(Object? meta) Object?
Read io.modelcontextprotocol/subscriptionId from a notification _meta.
withSubscriptionId(Map<String, dynamic>? params, Object subscriptionId) Map<String, dynamic>
Stamp subscriptionId onto a copy of params (a notification params object), setting _meta."io.modelcontextprotocol/subscriptionId". Never mutates the input; merges into any existing _meta.

Constants

keyClientCapabilities → const String
RequestMetaObject."io.modelcontextprotocol/clientCapabilities" — the client's capabilities FOR THIS REQUEST (REQUIRED on the stateless path). An empty object means no optional capabilities. Servers MUST NOT infer capabilities from prior requests.
keyClientInfo → const String
RequestMetaObject."io.modelcontextprotocol/clientInfo" — self-reported client software identity (name+version). Display/logging only; the server MUST NOT use it for behavior or security decisions.
keyLogLevel → const String
RequestMetaObject."io.modelcontextprotocol/logLevel" — the per-request desired log level (replaces the logging/setLevel RPC). Optional; when absent the server emits no notifications/message for this request.
keyProtocolVersion → const String
RequestMetaObject."io.modelcontextprotocol/protocolVersion" — the MCP protocol version for this request (REQUIRED on the stateless path). For HTTP it MUST equal the MCP-Protocol-Version header.
keyServerInfo → const String
ResultMetaObject."io.modelcontextprotocol/serverInfo" — self-reported server software identity carried on a response _meta.
keySubscriptionId → const String
NotificationMetaObject."io.modelcontextprotocol/subscriptionId" — the JSON-RPC id of the subscriptions/listen request that opened the stream a notification was delivered on. The server MUST stamp this on every notification sent via a subscription stream (also carried on SubscriptionsListenResult._meta). Absent on non-subscription notifications (e.g. in-flight progress).