mcp_client library
Kernel sub-barrel for outbound MCP client usage.
mcp_client is exposed through a dedicated entry point (rather than
the main brain_kernel.dart barrel) because its model classes
— Content / TextContent / ImageContent / CallToolResult /
transport configs — collide pervasively with mcp_server's
same-named classes. Rolling them into the main barrel forces every
domain consumer to disambiguate. Splitting the surfaces keeps the
main barrel clean for the typical builder usage (server-side MCP +
bundle + LLM) while still letting tools that genuinely need
outbound clients (inspector probes, cross-server wiring) reach the
types through the kernel.
Usage:
import 'package:brain_kernel/mcp_client.dart';
final result = await McpClient.createAndConnect(
config: const McpClientConfig(...),
);
if (result.content.first is TextContent) { ... }
Domain code that imports both brain_kernel.dart (for the
server / bundle types) and this file should use a prefix on one of
them to silence the expected collisions on Content / etc.
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
- AudioContent
- Audio provided to or from an LLM.
- AuthServerMetadata
- Authorization server metadata (RFC8414)
- 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. - 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
- Server information (2025-03-26 compliant) What this client supports, as it advertises it.
- 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.
- ClientTransport
- Abstract base class for client transport implementations
- 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. - Connected
- The connection is established and ready
- Connecting
- The connection is in the process of connecting
- ConnectionError
- The connection has failed with an error
- ConnectionState
- Represents the various states of an MCP connection
- ContentBlock
- Revisions: 2025-06-18, 2025-11-25, 2026-07-28, ext-tasks/2026-07-28.
- 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.
- DelegatingClient
- A Client that hands every call to inner. Extend it to wrap a client — add caching, limits or logging — and override only the members that change; everything else, including members later versions add, reaches inner unchanged.
- DetailedTask
- Revisions: ext-tasks/2026-07-28.
- Disconnected
- The connection is disconnected
- Disconnecting
- The connection is in the process of disconnecting
- 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.
- ErrorObject
- Revisions: 2025-11-25, 2026-07-28, ext-tasks/2026-07-28.
- 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. - HeartbeatConfig
- Heartbeat configuration.
- HeartbeatStats
- Heartbeat statistics.
- HttpOAuthClient
- HTTP-based OAuth 2.1 client implementation
- 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.
- 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.
- McpClient
- Modern MCP Client factory with enhanced error handling and configuration
- McpClientConfig
- Configuration for creating MCP clients
- 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.
- 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.
- McpMethodSpec
- One MCP method as the schema defines it.
- McpNotification
- Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28.
- McpOAuth
- One client's authorization with the MCP servers it talks to.
- McpOAuthOptions
- How this client identifies itself and reaches the user.
- McpObject
- Base of every generated object type.
- McpProtocol
- MCP protocol versions and constants
- McpRequestMeta
-
Reverse-DNS
_metakey constants and typed accessors for the stateless core. All keys sit under the reservedio.modelcontextprotocol/prefix. - McpResult
- Common result fields.
- McpResultType
-
Draft
ResultTypediscriminator values (schema.tsResultType). - McpTaskRecord
- One task.
- McpTaskStatus
- Task statuses (identical in both specifications).
- McpTaskStore
- The receiver's tasks.
- MemoryOAuthStore
- OAuthStore in memory.
- 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. - OAuthClient
- OAuth client interface
- OAuthClientRegistration
- A client identity at one authorization server.
- OAuthConfig
- OAuth 2.1 authentication configuration
- OAuthDiscoveryResult
-
Result of resolving a
401challenge into concrete OAuth endpoints (RFC 9728 PRM + RFC 8414/OIDC authorization-server discovery). - OAuthError
- OAuth error response
- OAuthGrant
- What a client holds for one MCP server: the token and where it came from.
- OAuthStore
- Where client registrations and grants live. Registrations are keyed by the issuing authorization server, grants by the MCP server.
- OAuthToken
- OAuth 2.1 token response
- OAuthTokenManager
- OAuth token manager with automatic refresh
- 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.
- PendingAuthorization
- An authorization request on its way to the authorization server: what the client must keep to judge the answer. Encode it to survive a page navigation; it holds the PKCE verifier, so keep it only for the session.
- 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. - ProgressUpdate
- Progress update for long-running operations
- 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.
- ProtectedResourceMetadata
-
OAuth 2.0 Protected Resource Metadata (RFC 9728), served at
/.well-known/oauth-protected-resourceby a Resource Server. - ProtocolCapabilities
- Protocol capabilities
- 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. - RequestOptions
- Per-request settings.
- 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.
- 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. -
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.
- Semaphore
- Semaphore for controlling concurrent requests
- ServerCapabilities
- What a server supports, as it advertised it.
- ServerCapabilitiesPrompts
-
ServerCapabilities.prompts. - ServerCapabilitiesResources
-
ServerCapabilities.resources. - ServerCapabilitiesTasks
-
ServerCapabilities.tasks. - ServerCapabilitiesTasksRequests
-
ServerCapabilitiesTasks.requests. - ServerCapabilitiesTasksRequestsTools
-
ServerCapabilitiesTasksRequests.tools. - ServerCapabilitiesTools
-
ServerCapabilities.tools. - ServerHealth
- Server health information
- 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.
- SetLevelRequest
- A request from the client to the server, to enable or adjust logging.
- SetLevelRequestParams
-
Parameters for a
logging/setLevelrequest. - SetLevelRequestParamsMeta
-
SetLevelRequestParams._meta. - SingleSelectEnumSchema
- Revisions: 2025-11-25, 2026-07-28.
- SseAuthClientTransport
- OAuth-aware legacy SSE transport. Native platforms only.
- SseClientTransport
-
Legacy SSE transport built on
dart:ioHTTP types. Native platforms only. - SseCompressedClientTransport
- Compression-negotiating legacy SSE transport. Native platforms only.
- SseHeartbeatClientTransport
- Heartbeat-monitoring legacy SSE transport. Native platforms only.
- SseTransportConfig
- StdioClientTransport
- Process-backed STDIO transport. Native platforms only.
- StdioTransportConfig
- StreamableHttpClientTransport
- 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. - Subscription
- SubscriptionFilter
-
The set of notification types a client may opt in to on a
SubscriptionsListenRequestsubscriptions/listenrequest. - SubscriptionNotification
- A single notification delivered on a Subscription stream.
- 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. - TokenLifecycleEvent
- Token lifecycle event.
- Tool
- Definition for a tool the client can call.
- ToolAnnotations
-
Additional properties describing a
Toolto clients. - ToolCallTracking
- Class to hold result of a tracked tool call
- 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. - ToolMetadata
- Lightweight tool metadata (name + description only) Used for token-efficient LLM context in deferred loading mode
- ToolRegistry
- Cache layer for tool definitions Provides metadata extraction and full schema lookup LLM-agnostic: can be used without mcp_llm
- ToolResultContent
- The result of a tool use, provided by the user back to the assistant.
- 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.
- WwwAuthenticateChallenge
-
A parsed
WWW-Authenticate: Bearer …challenge (RFC 6750 / RFC 9728).
Enums
- CompressionType
- Content encodings the compressed SSE transport can negotiate.
- ConnectionHealth
- Connection health as judged by the heartbeat transport.
- DisconnectReason
- Reason for disconnection
- 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.
- OAuthGrantType
- OAuth 2.1 grant types supported by MCP
- ProtocolEra
- Which protocol era a connection speaks (specification, versioning).
- TokenEventType
- Token lifecycle event types.
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
- ClientToolMetadataExtension on Client
- Extension on Client for easy metadata access in deferred loading mode
- DiscoverResultAccess on DiscoverResult
-
What a
server/discoverresult means to this client. -
FutureResultExtensions
on Future<
Result< T, E> > -
Extension methods for
Future<Result> - GetTaskResultLifecycle on GetTaskResult
- Lifecycle helper on a polled task.
- LoggerExtensions on Logger
- 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.
-
mcpMethods
→ const List<
McpMethodSpec> - Every method in every supported source.
-
mcpSchemaUnionBranches
→ const Map<
String, List< String> > - Branches of every discriminated union, by schema name (for tests and tools).
-
reservedHeaderNames
→ const Set<
String> - Header names a provider may not set, because the transport's correctness depends on them.
- 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.
-
Where the metadata of the authorization server
issuermay be, in the order to try (RFC 8414 §3.1 with OpenID Connect Discovery). -
canonicalResourceUri(
String url) → String - The canonical URI of an MCP server (RFC 8707 resource indicator): lower-case scheme and host, no fragment, no trailing slash.
-
checkAuthorizationResponseIssuer(
{required String recordedIssuer, required bool issParameterSupported, required String? iss}) → void -
RFC 9207 §2.4 as MCP applies it: a present
issmust equal the recorded issuer exactly (no normalization); an absent one is refused only when the server said it sends one. Throws OAuthError otherwise. -
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.
-
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. -
protectedResourceMetadataUrls(
String serverUrl) → List< Uri> -
Where the Protected Resource Metadata of
serverUrlmay be, in the order to try: at the server's path, then at the root (RFC 9728 §3.1). -
samplingMessagesProblem(
Object? messages) → String? -
Why the
messagesof asampling/createMessagerequest break the sampling rules, or null (specification, client/sampling: message content constraints, 2025-11-25+): -
taskOf(
Map< String, dynamic> createTaskResult) → Task -
The task a
CreateTaskResultannounces, in either form: the 2025-11-25 core nests it undertask; the 2026-07-28 extension puts its fields on the result itself. -
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
- ClientCapabilitiesSchema = ClientCapabilities
-
The generated
ClientCapabilities(wire form, every field). - ClientInfo = Implementation
- 2.x name of Implementation for a client.
- ClientResult = McpResult
- Common result fields.
- CompletionResult = CompleteResult
- 2.x name of CompleteResult.
- 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. -
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.
- MCPClient = McpClient
-
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. -
MetaObject
= Map<
String, Object?> -
Represents the contents of a
_metafield, which clients and servers use to attach additional metadata to their interactions. - ProgressToken = Object
- A progress token, used to associate progress notifications with the original request.
-
RequestHeadersProvider
= FutureOr<
Map< Function(({String method, String url}) request)String, String> > - Supplies headers for one outbound request.
- RequestId = Object
- A uniquely identifying ID for a request in JSON-RPC.
- 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 generated
ServerCapabilities(wire form, every field). - ServerInfo = Implementation
- 2.x name of Implementation for a server.
-
ServerResult
= Map<
String, Object?> - Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28.
-
TasksExtensionCapability
= Map<
String, Object?> - Revisions: ext-tasks/2026-07-28.
Exceptions / Errors
- 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
- McpUserRejected
- Thrown by a sampling handler when the user declines the request; the server receives error code -1 (client/sampling: error handling).