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/callrequest. - CallToolResult
-
The result returned by the server for a
CallToolRequesttools/callrequest. - CallToolResultResponse
-
A successful response from the server for a
CallToolRequesttools/callrequest. - 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/cancellednotification. - 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/completerequest. - CompleteRequestParamsArgument
-
CompleteRequestParams.argument. - CompleteRequestParamsRef
- One of: PromptReference, ResourceTemplateReference.
- CompleteResult
-
The result returned by the server for a
CompleteRequestcompletion/completerequest. - CompleteResultCompletion
-
CompleteResult.completion. - CompleteResultResponse
-
A successful response from the server for a
CompleteRequestcompletion/completerequest. - 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/createMessagerequest. - CreateMessageRequestParamsIncludeContext
-
Values of
CreateMessageRequestParams.includeContext. - CreateMessageRequestParamsMeta
-
CreateMessageRequestParams._meta. - CreateMessageResult
-
The result returned by the client for a
CreateMessageRequestsampling/createMessagerequest. 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/discoverrequest. - DiscoverResultCacheScope
-
Values of
DiscoverResult.cacheScope. - DiscoverResultResponse
-
A successful response from the server for a
DiscoverRequestserver/discoverrequest. - 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/createrequest. - 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/getrequest. - GetPromptResult
-
The result returned by the server for a
GetPromptRequestprompts/getrequest. - GetPromptResultResponse
-
A successful response from the server for a
GetPromptRequestprompts/getrequest. - 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 theWWW-Authenticateparameters 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
initializerequest. - 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
jsonrpcormethod, 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
TitledSingleSelectEnumSchemainstead. 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/listrequest. - ListPromptsResultCacheScope
-
Values of
ListPromptsResult.cacheScope. - ListPromptsResultResponse
-
A successful response from the server for a
ListPromptsRequestprompts/listrequest. - ListResourcesRequest
- Sent from the client to request a list of resources the server has.
- ListResourcesResult
-
The result returned by the server for a
ListResourcesRequestresources/listrequest. - ListResourcesResultCacheScope
-
Values of
ListResourcesResult.cacheScope. - ListResourcesResultResponse
-
A successful response from the server for a
ListResourcesRequestresources/listrequest. - 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/listrequest. - ListResourceTemplatesResultCacheScope
-
Values of
ListResourceTemplatesResult.cacheScope. - ListResourceTemplatesResultResponse
-
A successful response from the server for a
ListResourceTemplatesRequestresources/templates/listrequest. - 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/listrequest. This result contains an array ofRootobjects, 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/listrequest. - ListToolsResultCacheScope
-
Values of
ListToolsResult.cacheScope. - ListToolsResultResponse
-
A successful response from the server for a
ListToolsRequesttools/listrequest. - 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/messagenotification. - 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
iconsproperty. - 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
_metakeys and typed read/write helpers for the 2026-07-28 stateless core (SEP-2577). - McpRequestState
-
Seals and opens
requestStatevalues with HMAC-SHA256. - McpResult
- Common result fields.
- McpResultType
-
Draft
ResultTypediscriminator values (schema.tsResultType). - 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 be400 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
MetaObjectwith additional notification-specific fields. All key naming rules fromMetaObjectapply. - 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/progressnotification. - 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/listenstream when the client requested it via thepromptsListChangedfilter 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/readrequest. - ReadResourceResult
-
The result returned by the server for a
ReadResourceRequestresources/readrequest. - ReadResourceResultCacheScope
-
Values of
ReadResourceResult.cacheScope. - ReadResourceResultResponse
-
A successful response from the server for a
ReadResourceRequestresources/readrequest. - RelatedTaskMetadata
-
Metadata for associating messages with a task.
Include this in the
_metafield under the keyio.modelcontextprotocol/related-task. - Request
- Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28.
- RequestMetaObject
-
Extends
MetaObjectwith additional request-specific fields. All key naming rules fromMetaObjectapply. - RequestParams
- Common params for any request.
- Resource
- A known resource that the server is capable of reading.
- ResourceContents
- One of: TextResourceContents, BlobResourceContents.
- ResourceLink
- 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/listenstream when the client requested it via theresourcesListChangedfilter 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
resourceSubscriptionsfield of aSubscriptionsListenRequestsubscriptions/listenrequest. - ResourceUpdatedNotificationParams
-
Parameters for a
notifications/resources/updatednotification. - 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
MetaObjectwith additional result-specific fields. All key naming rules fromMetaObjectapply. - 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(initializeresult andserver/discover). Only the keys the schema'sServerCapabilitiesdefines 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/setLevelrequest. - SetLevelRequestParamsMeta
-
SetLevelRequestParams._meta. - Fans a client's notifications out to several listeners.
-
Reference-counted
resources/subscribeover a client several consumers share. - SingleSelectEnumSchema
- Revisions: 2025-11-25, 2026-07-28.
- SseClientTransport
-
Legacy SSE transport built on
dart:ioHTTP 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/subscriberequest. - SubscribeRequestParamsMeta
-
SubscribeRequestParams._meta. - SubscriptionFilter
-
The set of notification types a client may opt in to on a
SubscriptionsListenRequestsubscriptions/listenrequest. - SubscriptionsAcknowledgedNotification
-
Sent by the server to acknowledge that a
SubscriptionsListenRequestsubscriptions/listensubscription has been established and to report which notification types it agreed to honor. - SubscriptionsAcknowledgedNotificationParams
-
Parameters for a
SubscriptionsAcknowledgedNotificationnotifications/subscriptions/acknowledgednotification. - 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/listenrequest. - SubscriptionsListenResult
-
The response to a
SubscriptionsListenRequestsubscriptions/listenrequest, 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
ResultMetaObjectwith the subscription-stream identifier carried by aSubscriptionsListenResult. All key naming rules fromMetaObjectapply. - SubscriptionsListenResultResponse
-
A successful response from the server for a
SubscriptionsListenRequestsubscriptions/listenrequest, 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
taskfield 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
Toolto 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/listenstream when the client requested it via thetoolsListChangedfilter 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/unsubscriberequest. - 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(wherenulland 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
numis 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 injectstransport, 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/createrequest are not what their mode requires, or null (client/elicitation, 2025-11-25+): every request has amessage; form mode (or no mode) has arequestedSchemathat is a flat object of primitive properties; URL mode has a validurland anelicitationId. -
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
valueis an absolute URI under RFC 3986's generic syntax (scheme ":" hier-part …) — the check theuriformat uses. UnlikeUri.tryParse, it does not treatdata:(or any scheme) specially, sodata://configand other custom-scheme resource URIs are accepted. -
mcpMethodDefined(
String method, McpDirection direction, String revision, {Set< String> extensions = const {}}) → bool? -
Whether
methodis a protocol method ofrevisionindirection— defined by the core revision, or by an extension inextensions(ids such asio.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-headerannotations ofinputSchema(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 throughpropertiesalone. -
mcpParamHeaderValues(
List< McpParamHeader> headers, Map arguments) → Map<String, String> -
The
Mcp-Param-{name}values for a call witharguments(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
messagesof asampling/createMessagerequest 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
uriis an expansion of the RFC 6570 URI templatetemplate(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
templateis a well-formed RFC 6570 URI template. -
uriTemplateVariables(
String template, String uri) → Map< String, String> ? -
The values of the simple and reserved variables of
templateinuri, or null when it does not match.
Typedefs
- ClientResult = McpResult
- Common result fields.
-
CompletionHandler
= Future<
Map< Function(Map<String, dynamic> >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
InputRequestsmap; 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-headerannotation of a tool'sinputSchema: 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
_metafield, 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
Resultobject, allowing the client to determine how to parse the response. - ServerCapabilitiesSchema = ServerCapabilities
-
The schema's
ServerCapabilitiestype (this package's ownServerCapabilitiesis 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 anelicitationId. On other revisions it is reported like any tool failure. - RequestStateException
-
Sealed
requestStatethat must be rejected.