mcp_host library

Kernel sub-barrel for the reference MCP host adapters.

Hosts that want a mcp_server + mcp_client backed surface import this barrel in addition to package:brain_kernel/brain_kernel.dart. The main barrel exposes only the KernelServerHost / KernelClientHost abstracts; this barrel surfaces the reference impls (ServerBootstrap aka McpServerKernelHost, McpClientKernelHost) plus the raw mcp_server / mcp_client types so hosts can reach out to wire-shape APIs (custom prompts, resource subscriptions, OAuth, etc).

Usage:

import 'package:brain_kernel/brain_kernel.dart';
import 'package:brain_kernel/mcp_host.dart';

final app = await KernelApp.boot(
  workspaceId: 'studio',
  kvStorage: kv,
  serverHostFactory: ServerBootstrap.factory,  // MCP server-backed
  clientHost: McpClientKernelHost(),           // outbound calls
);

Hosts that never expose a server transport omit serverHostFactory (kernel falls back to in-process). Hosts that never make outbound calls omit clientHost.

Classes

Annotated
Base for objects that include optional annotations for the client. The client can use annotations to inform how objects are used or displayed
AnnotatedAnnotations
Annotated.annotations.
Annotations
Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
ApiKeyValidator
Simple API key validator
AudioContent
Audio provided to or from an LLM.
AuthContext
Authorization context for MCP requests
AuthMiddleware
Authentication middleware for HTTP requests
AuthResult
Authentication result
BaseMetadata
Base interface for metadata with name (identifier) and title (display name) properties.
BlobResourceContents
Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28, ext-tasks/2026-07-28.
BooleanSchema
Revisions: 2025-06-18, 2025-11-25, 2026-07-28, ext-tasks/2026-07-28.
CacheableResult
A result that supports a time-to-live (TTL) hint for client-side caching.
CacheableResultCacheScope
Values of CacheableResult.cacheScope.
CachedResource
Cached resource item for performance optimization
CallToolRequest
Used by the client to invoke a tool provided by the server.
CallToolRequestParams
Parameters for a tools/call request.
CallToolResult
The result returned by the server for a CallToolRequesttools/call request.
CallToolResultResponse
A successful response from the server for a CallToolRequesttools/call request.
CancellationToken
Cancellation token for async operations
CancelledNotification
This notification is sent by the client to indicate that it is cancelling a request it previously issued.
CancelledNotificationParams
Parameters for a notifications/cancelled notification.
CancelledTask
Revisions: ext-tasks/2026-07-28.
CancelTaskRequest
Revisions: 2025-11-25, ext-tasks/2026-07-28.
CancelTaskRequestParams
CancelTaskRequest.params.
CancelTaskResult
Revisions: 2025-11-25, ext-tasks/2026-07-28.
Client
Main MCP Client class that handles all client-side protocol operations
ClientCapabilities
Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.
ClientCapabilitiesElicitation
ClientCapabilities.elicitation.
ClientCapabilitiesRoots
ClientCapabilities.roots.
ClientCapabilitiesSampling
ClientCapabilities.sampling.
ClientCapabilitiesTasks
ClientCapabilities.tasks.
ClientCapabilitiesTasksRequests
ClientCapabilitiesTasks.requests.
ClientCapabilitiesTasksRequestsElicitation
ClientCapabilitiesTasksRequests.elicitation.
ClientCapabilitiesTasksRequestsSampling
ClientCapabilitiesTasksRequests.sampling.
ClientNotification
This notification is sent by the client to indicate that it is cancelling a request it previously issued.
ClientRequest
Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28.
ClientSession
Client session information
CompletedTask
Revisions: ext-tasks/2026-07-28.
CompleteRequest
A request from the client to the server, to ask for completion options.
CompleteRequestParams
Parameters for a completion/complete request.
CompleteRequestParamsArgument
CompleteRequestParams.argument.
CompleteRequestParamsRef
One of: PromptReference, ResourceTemplateReference.
CompleteResult
The result returned by the server for a CompleteRequestcompletion/complete request.
CompleteResultCompletion
CompleteResult.completion.
CompleteResultResponse
A successful response from the server for a CompleteRequestcompletion/complete request.
CompletionsCapability
Completions capability — argument autocompletion via completion/complete.
CompressionConfig
Compression configuration
ContentBlock
Revisions: 2025-06-18, 2025-11-25, 2026-07-28, ext-tasks/2026-07-28.
CorsConfig
CORS configuration
CreateMessageRequest
A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.
CreateMessageRequestParams
Parameters for a sampling/createMessage request.
CreateMessageRequestParamsIncludeContext
Values of CreateMessageRequestParams.includeContext.
CreateMessageRequestParamsMeta
CreateMessageRequestParams._meta.
CreateMessageResult
The result returned by the client for a CreateMessageRequestsampling/createMessage request. The client should inform the user before returning the sampled message, to allow them to inspect the response (human in the loop) and decide whether to allow the server to see it.
CreateTaskResult
Revisions: 2025-11-25, ext-tasks/2026-07-28.
DeprecationInfo
Deprecation information
DetailedTask
Revisions: ext-tasks/2026-07-28.
DiscoverRequest
A request from the client asking the server to advertise its supported protocol versions, capabilities, and other metadata. Servers MUST implement server/discover. Clients MAY call it but are not required to — version negotiation can also happen inline via per-request _meta.
DiscoverResult
The result returned by the server for a DiscoverRequestserver/discover request.
DiscoverResultCacheScope
Values of DiscoverResult.cacheScope.
DiscoverResultResponse
A successful response from the server for a DiscoverRequestserver/discover request.
ElicitationCompleteNotification
An optional notification from the server to the client, informing it of a completion of a out-of-band elicitation request.
ElicitationCompleteNotificationParams
ElicitationCompleteNotification.params.
ElicitRequest
A request from the server to elicit additional information from the user via the client.
ElicitRequestFormParams
The parameters for a request to elicit non-sensitive information from the user via a form in the client.
ElicitRequestFormParamsMeta
ElicitRequestFormParams._meta.
ElicitRequestParams
The parameters for a request to elicit additional information from the user via the client.
ElicitRequestURLParams
The parameters for a request to elicit information from the user via a URL in the client.
ElicitRequestURLParamsMeta
ElicitRequestURLParams._meta.
ElicitResult
The result returned by the client for an ElicitRequestelicitation/create request.
ElicitResultAction
Values of ElicitResult.action.
EmbeddedResource
The contents of a resource, embedded into a prompt or tool call result.
EnumSchema
Revisions: 2025-06-18, 2025-11-25, 2026-07-28.
ErrorCode
Error codes this server sends.
ErrorObject
Revisions: 2025-11-25, 2026-07-28, ext-tasks/2026-07-28.
ExtensionTransportConnect
Injected-transport seam companion to KernelClientHost.
FailedTask
Revisions: ext-tasks/2026-07-28.
Failure<T, E extends Object>
Represents a failed result
GetPromptRequest
Used by the client to get a prompt provided by the server.
GetPromptRequestParams
Parameters for a prompts/get request.
GetPromptResult
The result returned by the server for a GetPromptRequestprompts/get request.
GetPromptResultResponse
A successful response from the server for a GetPromptRequestprompts/get request.
GetTaskPayloadRequest
A request to retrieve the result of a completed task.
GetTaskPayloadRequestParams
GetTaskPayloadRequest.params.
GetTaskPayloadResult
The response to a tasks/result request. The structure matches the result type of the original request. For example, a tools/call task would return the CallToolResult structure.
GetTaskRequest
Revisions: 2025-11-25, ext-tasks/2026-07-28.
GetTaskRequestParams
GetTaskRequest.params.
GetTaskResult
Revisions: 2025-11-25, ext-tasks/2026-07-28.
HeaderMismatchError
Returned when a server rejects a request because the values in the HTTP headers do not match the corresponding values in the request body, or because required headers are missing or malformed. For HTTP, the response status code MUST be 400 Bad Request.
HeaderMismatchErrorError
HeaderMismatchError.error.
HttpAuthAllowed
Served; caller is null for an anonymous request a non-strict server lets through.
HttpAuthDecision
How the server answers one HTTP request's credentials.
HttpAuthDenied
Refused: 401 (no or invalid token) or 403 (insufficient_scope), with the WWW-Authenticate parameters to send.
ImageContent
An image provided to or from an LLM.
Implementation
Describes the MCP implementation.
InitializedNotification
This notification is sent from the client to the server after initialization has finished.
InitializeRequest
This request is sent from the client to the server when it first connects, asking it to begin initialization.
InitializeRequestParams
Parameters for an initialize request.
InitializeRequestParamsMeta
InitializeRequestParams._meta.
InitializeResult
After receiving an initialize request from the client, the server sends this response.
InputRequest
Revisions: 2026-07-28, ext-tasks/2026-07-28.
InputRequiredResult
An InputRequiredResult sent by the server to indicate that additional input is needed before the request can be completed.
InputRequiredTask
Revisions: ext-tasks/2026-07-28.
InputResponseRequestParams
Revisions: 2026-07-28.
InternalError
A JSON-RPC error indicating that an internal error occurred on the receiver. This error is returned when the receiver encounters an unexpected condition that prevents it from fulfilling the request.
InvalidParamsError
A JSON-RPC error indicating that the method parameters are invalid or malformed.
InvalidRequestError
A JSON-RPC error indicating that the request is not a valid request object. This error is returned when the message structure does not conform to the JSON-RPC 2.0 specification requirements for a request (e.g., missing required fields like jsonrpc or method, or using invalid types for these fields).
JSONRPCErrorResponse
A response to a request that indicates an error occurred.
JsonRpcMessage
JSON-RPC message
JSONRPCNotification
A notification which does not expect a response.
JSONRPCRequest
A request that expects a response.
JSONRPCResponse
A response to a request, containing either the result or error.
JSONRPCResultResponse
A successful (non-error) response to a request.
JsonSchemaError
One failed assertion.
JsonSchemaLimits
Bounds on one evaluation.
JsonSchemaResult
The outcome of JsonSchemaValidator.validate.
JsonSchemaValidator
Validates instances against one schema.
LegacyTitledEnumSchema
Use TitledSingleSelectEnumSchema instead. This interface will be removed in a future version.
Level
Levels to control logging output. Logging can be enabled to include all levels above certain Level. Levels are ordered using an integer value Level.value. The predefined Level constants below are sorted as follows (in descending order): Level.SHOUT, Level.SEVERE, Level.WARNING, Level.INFO, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, and Level.ALL.
ListPromptsRequest
Sent from the client to request a list of prompts and prompt templates the server has.
ListPromptsResult
The result returned by the server for a ListPromptsRequestprompts/list request.
ListPromptsResultCacheScope
Values of ListPromptsResult.cacheScope.
ListPromptsResultResponse
A successful response from the server for a ListPromptsRequestprompts/list request.
ListResourcesRequest
Sent from the client to request a list of resources the server has.
ListResourcesResult
The result returned by the server for a ListResourcesRequestresources/list request.
ListResourcesResultCacheScope
Values of ListResourcesResult.cacheScope.
ListResourcesResultResponse
A successful response from the server for a ListResourcesRequestresources/list request.
ListResourceTemplatesRequest
Sent from the client to request a list of resource templates the server has.
ListResourceTemplatesResult
The result returned by the server for a ListResourceTemplatesRequestresources/templates/list request.
ListResourceTemplatesResultCacheScope
Values of ListResourceTemplatesResult.cacheScope.
ListResourceTemplatesResultResponse
A successful response from the server for a ListResourceTemplatesRequestresources/templates/list request.
ListRootsRequest
Sent from the server to request a list of root URIs from the client. Roots allow servers to ask for specific directories or files to operate on. A common example for roots is providing a set of repositories or directories a server should operate on.
ListRootsRequestParams
ListRootsRequest.params.
ListRootsResult
The result returned by the client for a ListRootsRequestroots/list request. This result contains an array of Root objects, each representing a root directory or file that the server can operate on.
ListTasksRequest
A request to retrieve a list of tasks.
ListTasksResult
The response to a tasks/list request.
ListToolsRequest
Sent from the client to request a list of tools the server has.
ListToolsResult
The result returned by the server for a ListToolsRequesttools/list request.
ListToolsResultCacheScope
Values of ListToolsResult.cacheScope.
ListToolsResultResponse
A successful response from the server for a ListToolsRequesttools/list request.
Logger
Use a Logger to log debug messages.
LoggingCapability
Logging capability.
LoggingLevel
The severity of a log message.
LoggingMessageNotification
JSONRPCNotification of a log message passed from server to client. The client opts in by setting "io.modelcontextprotocol/logLevel" in a request's _meta.
LoggingMessageNotificationParams
Parameters for a notifications/message notification.
LogRecord
A log entry representation used to propagate information from Logger to individual handlers.
McpCaller
The authenticated caller of the request currently being handled.
McpClientKernelHost
McpEnum
Base of every generated string-valued enumeration. Values outside the schema's set are kept, so a newer peer's value is passed through rather than rejected.
McpErrorCodes
MCP Error codes as defined in the specification
McpIcon
An optionally-sized icon that can be displayed in a user interface.
McpIcons
Base interface to add icons property.
McpIconTheme
Values of McpIcon.theme.
McpJson
A value that serialises to JSON.
McpMethods
Standard MCP methods that must be implemented
McpMethodSpec
One MCP method as the schema defines it.
McpMrtr
McpNotification
Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28.
McpObject
Base of every generated object type.
McpProtocol
MCP Protocol Version constants and definitions
McpRequestMeta
Reverse-DNS _meta keys and typed read/write helpers for the 2026-07-28 stateless core (SEP-2577).
McpRequestState
Seals and opens requestState values with HMAC-SHA256.
McpResult
Common result fields.
McpResultType
Draft ResultType discriminator values (schema.ts ResultType).
McpServer
Modern MCP Server factory with enhanced configuration and error handling
McpServerConfig
Configuration for creating MCP servers
McpTaskContext
The task whose work is running (see Server.currentTask).
McpTaskRecord
One task.
McpTaskStatus
Task statuses (identical in both specifications).
McpTaskStore
The receiver's tasks.
MethodNotFoundError
A JSON-RPC error indicating that the requested method does not exist or is not available.
MissingRequiredClientCapabilityError
Returned when processing a request requires a capability the client did not declare in clientCapabilities. For HTTP, the response status code MUST be 400 Bad Request.
MissingRequiredClientCapabilityErrorError
MissingRequiredClientCapabilityError.error.
MissingRequiredClientCapabilityErrorErrorData
MissingRequiredClientCapabilityErrorError.data.
ModelHint
Hints to use for model selection.
ModelPreferences
The server's preferences for model selection, requested of the client during sampling.
MultiSelectEnumSchema
Revisions: 2025-11-25, 2026-07-28.
NotificationMetaObject
Extends MetaObject with additional notification-specific fields. All key naming rules from MetaObject apply.
NotificationParams
Common params for any notification.
NumberSchema
Revisions: 2025-06-18, 2025-11-25, 2026-07-28, ext-tasks/2026-07-28.
NumberSchemaType
Values of NumberSchema.type.
OAuthTokenValidator
OAuth 2.1 token validator
PaginatedRequest
Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28.
PaginatedRequestParams
Common params for paginated requests.
PaginatedResult
Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28.
ParseError
A JSON-RPC error indicating that invalid JSON was received by the server. This error is returned when the server cannot parse the JSON text of a message.
PendingOperation
Pending operation for cancellation support
PingRequest
A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.
PrimitiveSchemaDefinition
Restricted schema definitions that only allow primitive types without nested objects or arrays.
ProgressNotification
An out-of-band notification used to inform the receiver of a progress update for a long-running request.
ProgressNotificationParams
Parameters for a ProgressNotificationnotifications/progress notification.
Prompt
A prompt or prompt template that the server offers.
PromptArgument
Describes an argument that a prompt can accept.
PromptListChangedNotification
An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This is only delivered on a SubscriptionsListenRequestsubscriptions/listen stream when the client requested it via the promptsListChanged filter field.
PromptMessage
Describes a message returned as part of a prompt.
PromptReference
Identifies a prompt.
PromptsCapability
Prompts capability.
RateLimitConfig
Rate limit configuration
ReadResourceRequest
Sent from the client to the server, to read a specific resource URI.
ReadResourceRequestParams
Parameters for a resources/read request.
ReadResourceResult
The result returned by the server for a ReadResourceRequestresources/read request.
ReadResourceResultCacheScope
Values of ReadResourceResult.cacheScope.
ReadResourceResultResponse
A successful response from the server for a ReadResourceRequestresources/read request.
RelatedTaskMetadata
Metadata for associating messages with a task. Include this in the _meta field under the key io.modelcontextprotocol/related-task.
Request
Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28.
RequestMetaObject
Extends MetaObject with additional request-specific fields. All key naming rules from MetaObject apply.
RequestParams
Common params for any request.
Resource
A known resource that the server is capable of reading.
ResourceContents
One of: TextResourceContents, BlobResourceContents.
A resource that the server is capable of reading, included in a prompt or tool call result.
ResourceListChangedNotification
An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This is only delivered on a SubscriptionsListenRequestsubscriptions/listen stream when the client requested it via the resourcesListChanged filter field.
ResourceReference
A reference to a resource or resource template definition.
ResourceRequestParams
Common params for resource-related requests.
ResourcesCapability
Resources capability.
ResourceTemplate
A template description for resources available on the server.
ResourceTemplateReference
A reference to a resource or resource template definition.
ResourceUpdatedNotification
A notification from the server to the client, informing it that a resource has changed and may need to be read again. This is only sent for resources the client opted in to via the resourceSubscriptions field of a SubscriptionsListenRequestsubscriptions/listen request.
ResourceUpdatedNotificationParams
Parameters for a notifications/resources/updated notification.
ResourceUsage
Resource usage indicators
Result<T, E extends Object>
A sealed class representing the result of an operation that can succeed or fail
ResultMetaObject
Extends MetaObject with additional result-specific fields. All key naming rules from MetaObject apply.
Results
Utility functions for working with Results
Role
The sender or recipient of messages and data in a conversation.
Root
Represents a root directory or file that the server can operate on.
RootsListChangedNotification
A notification from the client to the server, informing it that the list of roots has changed. This notification should be sent whenever the client adds, removes, or modifies any root. The server should then request an updated list of roots using the ListRootsRequest.
SamplingMessage
Describes a message issued to or received from an LLM API.
SamplingMessageContentBlock
Revisions: 2025-11-25, 2026-07-28, ext-tasks/2026-07-28.
Server
Main MCP Server class that handles all server-side protocol operations
ServerBootstrap
ServerCapabilities
What this server advertises in capabilities (initialize result and server/discover). Only the keys the schema's ServerCapabilities defines are sent.
ServerCapabilitiesPrompts
ServerCapabilities.prompts.
ServerCapabilitiesResources
ServerCapabilities.resources.
ServerCapabilitiesTasks
ServerCapabilities.tasks.
ServerCapabilitiesTasksRequests
ServerCapabilitiesTasks.requests.
ServerCapabilitiesTasksRequestsTools
ServerCapabilitiesTasksRequests.tools.
ServerCapabilitiesTools
ServerCapabilities.tools.
ServerHealth
Server health information
ServerInterface
Interface for server to expose key functionality for testing
ServerNotification
Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28.
ServerRequest
Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25.
ServerTransport
Abstract base class for server transport implementations
SetLevelRequest
A request from the client to the server, to enable or adjust logging.
SetLevelRequestParams
Parameters for a logging/setLevel request.
SetLevelRequestParamsMeta
SetLevelRequestParams._meta.
SharedClientNotifications
Fans a client's notifications out to several listeners.
SharedResourceSubscriptions
Reference-counted resources/subscribe over a client several consumers share.
SingleSelectEnumSchema
Revisions: 2025-11-25, 2026-07-28.
SseClientTransport
Legacy SSE transport built on dart:io HTTP types. Native platforms only.
SseServerTransport
Transport implementation using Server-Sent Events (SSE) over HTTP
SseStreamInfo
SSE stream information for request-specific streams
SseTransportConfig
StdioClientTransport
Process-backed STDIO transport. Native platforms only.
StdioServerTransport
Transport implementation using standard input/output streams
StdioTransportConfig
StreamableHttpClientTransport
StreamableHttpServerConfig
Configuration for StreamableHTTP server transport
StreamableHttpServerTransport
MCP 2025-03-26 StreamableHTTP Server Transport Implementation Supports both JSON responses and SSE streaming according to MCP standard
StreamableHttpTransportConfig
StringSchema
Revisions: 2025-06-18, 2025-11-25, 2026-07-28, ext-tasks/2026-07-28.
StringSchemaFormat
Values of StringSchema.format.
SubscribeRequest
Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
SubscribeRequestParams
Parameters for a resources/subscribe request.
SubscribeRequestParamsMeta
SubscribeRequestParams._meta.
SubscriptionFilter
The set of notification types a client may opt in to on a SubscriptionsListenRequestsubscriptions/listen request.
SubscriptionsAcknowledgedNotification
Sent by the server to acknowledge that a SubscriptionsListenRequestsubscriptions/listen subscription has been established and to report which notification types it agreed to honor.
SubscriptionsAcknowledgedNotificationParams
Parameters for a SubscriptionsAcknowledgedNotificationnotifications/subscriptions/acknowledged notification.
SubscriptionsListenRequest
Sent from the client to open a long-lived channel for receiving notifications outside the context of a specific request. Replaces the previous HTTP GET endpoint and ensures consistent behavior between HTTP and STDIO.
SubscriptionsListenRequestParams
Parameters for a SubscriptionsListenRequestsubscriptions/listen request.
SubscriptionsListenResult
The response to a SubscriptionsListenRequestsubscriptions/listen request, signalling that the subscription has ended gracefully (for example, during server shutdown). Because the listen stream is long-lived, this result is sent only when the server tears the subscription down; an abrupt transport close carries no response. The result body is otherwise empty.
SubscriptionsListenResultMetaObject
Extends ResultMetaObject with the subscription-stream identifier carried by a SubscriptionsListenResult. All key naming rules from MetaObject apply.
SubscriptionsListenResultResponse
A successful response from the server for a SubscriptionsListenRequestsubscriptions/listen request, sent when the server tears the subscription down gracefully.
Success<T, E extends Object>
Represents a successful result
Task
Revisions: 2025-11-25, ext-tasks/2026-07-28.
TaskAugmentedRequestParams
Common params for any task-augmented request.
TaskAugmentedRequestParamsMeta
TaskAugmentedRequestParams._meta.
TaskMetadata
Metadata for augmenting a request with task execution. Include this in the task field of the request parameters.
TaskStatus
Revisions: 2025-11-25, ext-tasks/2026-07-28.
TaskStatusNotification
Revisions: 2025-11-25, ext-tasks/2026-07-28.
TaskStatusNotificationParams
Revisions: 2025-11-25, ext-tasks/2026-07-28.
TaskSubscriptionAcknowledgedNotifications
Revisions: ext-tasks/2026-07-28.
TaskSubscriptionNotifications
Revisions: ext-tasks/2026-07-28.
TextContent
Text provided to or from an LLM.
TextResourceContents
Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28, ext-tasks/2026-07-28.
TitledMultiSelectEnumSchema
Schema for multiple-selection enumeration with display titles for each option.
TitledMultiSelectEnumSchemaItems
TitledMultiSelectEnumSchema.items.
TitledMultiSelectEnumSchemaItemsAnyOfItem
TitledMultiSelectEnumSchemaItems.anyOfItem.
TitledSingleSelectEnumSchema
Schema for single-selection enumeration with display titles for each option.
TitledSingleSelectEnumSchemaOneOfItem
TitledSingleSelectEnumSchema.oneOfItem.
TokenValidator
Token validation interface
Tool
Definition for a tool the client can call.
ToolAnnotationBuilder
Tool annotation builder for creating standard annotations
ToolAnnotationKeys
Standard tool annotation keys defined in MCP 2025-03-26
ToolAnnotationPresets
Common tool annotation presets
ToolAnnotations
Additional properties describing a Tool to clients.
ToolAnnotationUtils
Utility functions for working with tool annotations
ToolChoice
Controls tool selection behavior for sampling requests.
ToolChoiceMode
Values of ToolChoice.mode.
ToolExecution
Execution-related properties for a tool.
ToolExecutionTaskSupport
Values of ToolExecution.taskSupport.
ToolListChangedNotification
An optional notification from the server to the client, informing it that the list of tools it offers has changed. This is only delivered on a SubscriptionsListenRequestsubscriptions/listen stream when the client requested it via the toolsListChanged filter field.
ToolResultContent
The result of a tool use, provided by the user back to the assistant.
ToolsCapability
Tools capability.
ToolUseContent
A request from the assistant to call a tool.
TransportConfig
Configuration for transport connections
UnknownClientNotification
A ClientNotification whose kind this revision set does not define, kept intact.
UnknownClientRequest
A ClientRequest whose kind this revision set does not define, kept intact.
UnknownCompleteRequestParamsRef
A CompleteRequestParamsRef whose kind this revision set does not define, kept intact.
UnknownContentBlock
A ContentBlock whose kind this revision set does not define, kept intact.
UnknownElicitRequestParams
A ElicitRequestParams whose kind this revision set does not define, kept intact.
UnknownEnumSchema
A EnumSchema whose kind this revision set does not define, kept intact.
UnknownInputRequest
A InputRequest whose kind this revision set does not define, kept intact.
UnknownJSONRPCResponse
A JSONRPCResponse whose kind this revision set does not define, kept intact.
UnknownMultiSelectEnumSchema
A MultiSelectEnumSchema whose kind this revision set does not define, kept intact.
UnknownPrimitiveSchemaDefinition
A PrimitiveSchemaDefinition whose kind this revision set does not define, kept intact.
UnknownResourceContents
A ResourceContents whose kind this revision set does not define, kept intact.
UnknownSamplingMessageContentBlock
A SamplingMessageContentBlock whose kind this revision set does not define, kept intact.
UnknownServerNotification
A ServerNotification whose kind this revision set does not define, kept intact.
UnknownServerRequest
A ServerRequest whose kind this revision set does not define, kept intact.
UnknownSingleSelectEnumSchema
A SingleSelectEnumSchema whose kind this revision set does not define, kept intact.
UnsubscribeRequest
Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.
UnsubscribeRequestParams
Parameters for a resources/unsubscribe request.
UnsubscribeRequestParamsMeta
UnsubscribeRequestParams._meta.
UnsupportedProtocolVersionError
Returned when the request's protocol version is unknown to the server or unsupported (e.g., a known experimental or draft version the server has chosen not to implement). For HTTP, the response status code MUST be 400 Bad Request.
UnsupportedProtocolVersionErrorError
UnsupportedProtocolVersionError.error.
UnsupportedProtocolVersionErrorErrorData
UnsupportedProtocolVersionErrorError.data.
UntitledMultiSelectEnumSchema
Schema for multiple-selection enumeration without display titles for options.
UntitledMultiSelectEnumSchemaItems
UntitledMultiSelectEnumSchema.items.
UntitledSingleSelectEnumSchema
Schema for single-selection enumeration without display titles for options.
UpdateTaskRequest
Revisions: ext-tasks/2026-07-28.
UpdateTaskRequestParams
UpdateTaskRequest.params.
UpdateTaskResult
Revisions: ext-tasks/2026-07-28.
URLElicitationRequiredError
An error response that indicates that the server requires the client to provide additional information via an elicitation request.
URLElicitationRequiredErrorError
URLElicitationRequiredError.error.
URLElicitationRequiredErrorErrorData
URLElicitationRequiredErrorError.data.
WorkingTask
Revisions: ext-tasks/2026-07-28.

Enums

CompressionType
Compression types supported
JsonSchemaDialect
JSON Schema dialects this validator implements.
McpDirection
Direction of an MCP message.
McpLogLevel
Log levels, in the order the protocol ranks them.
McpTaskFlavor
Which task specification a task follows; it decides the wire shape.
ToolPriority
Tool priority levels

Extension Types

Message
2.x's Message: a prompt message. role is a Role or its value ('user', 'assistant'). A type as well as a constructor; the value is the PromptMessage itself.
ResourceContent
2.x's ResourceContent: an embedded resource content block. A type as well as a constructor; the value is the EmbeddedResource itself, read through the 2.x members (uri, text, blob, mimeType and annotations as a map).
ResourceContentInfo
2.x's ResourceContentInfo: resource contents with either text or blob (base64). A type as well as a constructor, so 2.x code that names it (List<ResourceContentInfo>) keeps compiling; the value is the TextResourceContents or BlobResourceContents itself.

Extensions

FutureResultExtensions on Future<Result<T, E>>
Extension methods for Future<Result>
LoggerExtensions on Logger
OAuthServerMethods on Server
SubscriptionFilterDecisions on SubscriptionFilter
Subscription filter decisions (2026-07-28 subscriptions/listen).
TaskLifecycle on Task
Lifecycle helper on a task (2.x Task.isTerminal).
TaskStatusLifecycle on TaskStatus
Lifecycle helpers on the protocol TaskStatus.

Constants

absent → const Object
Marker for "leave this key out" in constructors of properties whose schema allows an explicit null (where null and absent mean different things).
defaultLevel → const Level
The default Level.
getStreamKey → const String
mcpMethods → const List<McpMethodSpec>
Every method in every supported source.
mcpProtocolVersionHeader → const String
HTTP header carrying the MCP protocol version (2025-06-18+, and the sole version signal on the 2026-07-28 stateless path).
mcpSchemaUnionBranches → const Map<String, List<String>>
Branches of every discriminated union, by schema name (for tests and tools).
tasksExtensionId → const String
The tasks extension identifier (2026-07-28).

Properties

hierarchicalLoggingEnabled ↔ bool
Whether to allow fine-grain logging and configuration of loggers in a hierarchy.
getter/setter pair
mcpSchemaReaders → Map<String, McpJson Function(Map<String, Object?>)>
Reader for every object and union definition, by schema name.
final
recordStackTraceAtLevel ↔ Level
Automatically record stack traces for any message of this level or above.
getter/setter pair

Functions

$any(Object? v, String path) → Object?
Reads any JSON value as is (copied).
$bool(Object? v, String path) → bool
Reads a boolean.
$encode(Object? v) → Object?
Encodes a typed value back to JSON.
$enum<T>(T of(String)) → T Function(Object?, String)
Reads an enumeration value with of.
$int(Object? v, String path) → int
Reads an integer (an integral num is accepted).
$list<T>(T item(Object? value, String path)) → List<T> Function(Object?, String)
Reads a list, converting each element with item.
$map<T>(T item(Object? value, String path)) → Map<String, T> Function(Object?, String)
Reads a map, converting each value with item.
$model<T>(T fromJson(Map<String, Object?>)) → T Function(Object?, String)
Reads a JSON object with fromJson.
$num(Object? v, String path) → num
Reads a number.
$object(Object? v, String path) → Map<String, Object?>
Reads a JSON object as a map (copied).
$oneOrList<T>(T item(Object? value, String path)) → List<T> Function(Object?, String)
Reads one value or a list of them as a list.
$string(Object? v, String path) → String
Reads a string.
attachStderrLogSink({Level? level}) → StreamSubscription<LogRecord>
Route all log records to stderr so a stdio-based MCP host cannot have its stdout — which carries the protocol JSON-RPC stream — corrupted by log output. Opt-in and idempotent: call it once during startup on the stdio transport. 2025-11-25 clarifies servers may emit logs at any level to stderr on the stdio transport.
connectExtension(KernelClientHost? clientHost, {required String id, required ClientTransport transport}) → Future<KernelClientConnection>
Canonical way to drive the extension-transport seam off a — possibly null, possibly non-capable — clientHost. Probes ExtensionTransportConnect and injects transport, or throws a StateError if the host cannot.
decodeMcpHeaderValue(String header) → String?
The value a header carries (sentinel decoded), or null when the header value has characters a header may not hold or a malformed sentinel.
detachStderrLogSink() → Future<void>
Remove the stderr log sink installed by attachStderrLogSink. Safe to call when no sink is attached.
elicitationRequestProblem(Map params) → String?
Why the params of an elicitation/create request are not what their mode requires, or null (client/elicitation, 2025-11-25+): every request has a message; form mode (or no mode) has a requestedSchema that is a flat object of primitive properties; URL mode has a valid url and an elicitationId.
encodeMcpHeaderValue(String value) → String
A header value as Streamable HTTP carries it: as-is when it is plain visible ASCII without surrounding whitespace, otherwise (or when it looks like the sentinel) =?base64?…?= of its UTF-8 bytes.
isAbsoluteUri(String value) → bool
Whether value is an absolute URI under RFC 3986's generic syntax (scheme ":" hier-part …) — the check the uri format uses. Unlike Uri.tryParse, it does not treat data: (or any scheme) specially, so data://config and other custom-scheme resource URIs are accepted.
mcpMethodDefined(String method, McpDirection direction, String revision, {Set<String> extensions = const {}}) → bool?
Whether method is a protocol method of revision in direction — defined by the core revision, or by an extension in extensions (ids such as io.modelcontextprotocol/tasks). Null when the method is not a protocol method of any supported revision (an application method).
mcpParamHeaders(Object? inputSchema) → ({List<McpParamHeader> headers, String? problem})
The x-mcp-header annotations of inputSchema (2026-07-28 Streamable HTTP, custom headers from tool parameters), or the reason the tool definition is invalid: an empty or non-token name, a name repeated (case-insensitively), a parameter that is not integer / string / boolean, or one not reachable through properties alone.
mcpParamHeaderValues(List<McpParamHeader> headers, Map arguments) → Map<String, String>
The Mcp-Param-{name} values for a call with arguments (absent and null values omitted), encoded for the header; throws ArgumentError for a value of the wrong type or an integer outside the safe range.
samplingMessagesProblem(Object? messages) → String?
Why the messages of a sampling/createMessage request break the sampling rules, or null (specification, client/sampling: message content constraints, 2025-11-25+):
stripInternalRoutingKeys(dynamic message) → dynamic
Strip transport-internal routing metadata from an outbound message.
uriTemplateMatches(String template, String uri) → bool
Whether uri is an expansion of the RFC 6570 URI template template (resource templates: uriTemplate). Every operator is understood: simple {x} (unreserved characters only, so a / is not part of the value), reserved {+x}, fragment {#x}, label {.x}, path {/x}, path parameters {;x}, query {?x} and continuation {&x}; prefix (:n) and explode (*) modifiers are accepted. An undefined variable may expand to nothing.
uriTemplateValid(String template) → bool
Whether template is a well-formed RFC 6570 URI template.
uriTemplateVariables(String template, String uri) → Map<String, String>?
The values of the simple and reserved variables of template in uri, or null when it does not match.

Typedefs

ClientResult = McpResult
Common result fields.
CompletionHandler = Future<Map<String, dynamic>> Function(Map<String, dynamic> ref, Map<String, dynamic> argument, Map<String, dynamic>? context)
Type definition for completion handler functions (spec completion/complete).
Content = ContentBlock
2.x name of ContentBlock.
Cursor = String
An opaque token used to represent a cursor for pagination.
EmptyResult = McpResult
Common result fields.
InputRequests = Map<String, InputRequest>
A map of server-initiated requests that the client must fulfill. Keys are server-assigned identifiers; values are the request objects.
InputResponse = Map<String, Object?>
Revisions: 2026-07-28, ext-tasks/2026-07-28.
InputResponses = Map<String, Map<String, Object?>>
A map of client responses to server-initiated requests. Keys correspond to the keys in the InputRequests map; values are the client's result for each request.
IsCancelledCheck = bool Function()
Callback type for checking if operation is cancelled
JSONArray = List<Object?>
Revisions: 2026-07-28.
JSONObject = Map<String, Object?>
Revisions: 2026-07-28, ext-tasks/2026-07-28.
JSONRPCBatchRequest = List<Object?>
A JSON-RPC batch request, as described in https://www.jsonrpc.org/specification#batch.
JSONRPCBatchResponse = List<Object?>
A JSON-RPC batch response, as described in https://www.jsonrpc.org/specification#batch.
JSONRPCError = JSONRPCErrorResponse
Revisions: 2025-06-18.
JSONRPCMessage = Map<String, Object?>
Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.
JSONValue = Object?
Revisions: 2026-07-28, ext-tasks/2026-07-28.
McpParamHeader = ({String name, List<String> path, String type})
One x-mcp-header annotation of a tool's inputSchema: the header name part, the property path to the value, and the property's type.
MCPServer = McpServer
MetaObject = Map<String, Object?>
Represents the contents of a _meta field, which clients and servers use to attach additional metadata to their interactions.
ProgressCallback = void Function(double progress, String message)
Callback type for tool execution progress updates
ProgressToken = Object
A progress token, used to associate progress notifications with the original request.
PromptHandler = Future Function(Map<String, dynamic> arguments)
Type definition for prompt handler functions
RequestId = Object
A uniquely identifying ID for a request in JSON-RPC.
ResourceHandler = Future Function(String uri, Map<String, dynamic> params)
Type definition for resource handler functions
ResourceLinkContent = ResourceLink
2.x name of ResourceLink.
ResultType = String
Indicates the type of a Result object, allowing the client to determine how to parse the response.
ServerCapabilitiesSchema = ServerCapabilities
The schema's ServerCapabilities type (this package's own ServerCapabilities is the configuration class the server advertises).
ServerResult = Map<String, Object?>
Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28.
SseServerConfig = SseTransportConfig
TasksExtensionCapability = Map<String, Object?>
Revisions: ext-tasks/2026-07-28.
ToolHandler = Future Function(Map<String, dynamic> arguments)
Type definition for tool handler functions with cancellation and progress reporting

Exceptions / Errors

CancelledException
Exception thrown when an operation is cancelled
JsonSchemaException
A schema that cannot be used: unsupported dialect, unresolvable reference, malformed keyword, or a limit exceeded while evaluating.
McpError
Error class for MCP-related errors
McpUrlElicitationRequired
Thrown by a tool handler when the call cannot proceed until the user completes URL-mode elicitations (URLElicitationRequiredError, -32042, 2025-11-25). Each entry is URL-mode elicitation params with an elicitationId. On other revisions it is reported like any tool failure.
RequestStateException
Sealed requestState that must be rejected.