mcp_client
Dart implementation of Model Context Protocol (MCP) client. Supports protocol revisions 2024-11-05 / 2025-03-26 / 2025-06-18 / 2025-11-25 with per-version capability negotiation, OAuth 2.1, and stdio / SSE / Streamable HTTP transports.
2.2.1
2.7K downloads/mo
#4810 most downloaded on pub.dev
app-appplayer/mcp_client
What this package is like to depend on
Last release 11 days ago
13 Aug 2026
Release timing varies
gaps range from 2 weeks to 4 months
Nearly every release is documented
notes for 18 of 20 stable releases
Nothing withdrawn
no release was ever pulled
1 years old
20 releases · first in 2025
9 releases in the last 12 months
see the full history below
Release timeline
20 releases · Mar 2025 to Aug 2026Releases
latest 20-
2.2.113 Aug 2026Release notes
Open source →Fixed
Client.connectfails when the transport reports a wire error instead of waiting out the 30-second request timeout. Requests in flight are completed with that error rather than left pending. An unreachable endpoint now fails in milliseconds.
-
2.2.031 Jul 2026Release notes
Open source →Added — headers that are fetched, not fixed
StreamableHttpTransportConfig.headersis set when the transport is built and spread onto every request unchanged. Anything that expires cannot live there: a host holding a short-lived attestation or session credential has no way to attach it, because by the time a request goes out the value it captured is stale.headersProvideris asked on every outbound request — POST, the SSE GET stream, and the session-terminating DELETE — and receives(url, method)so one provider can serve several transports and decide per destination.RequestHeadersProviderandreservedHeaderNamesare exported with the transport.Three properties make it safe to hand to host code, including a page script:
- It cannot break the exchange. Names the protocol owns (
Content-Type,Accept,MCP-Session-Id,MCP-Protocol-Version,Mcp-Method,Mcp-Name,Last-Event-ID) are dropped rather than honoured, matched case-insensitively. A suppliedMCP-Session-Idwould otherwise fail the exchange in a way that reads as the server's fault. - It cannot cost a request. A provider that throws, or exceeds
headersProviderTimeout(5s default), contributes nothing and the request goes without it. Failing the request instead would report a hook problem as an unreachable server. What the origin then says about the missing credential is the accurate answer, and it comes from the origin. - Its failure is visible.
lastHeadersProviderErrorrecords the last one, because "the origin refused us" and "we never attached what the origin wanted" look identical on the wire and send a debugger to different places.
Explicitly configured
headerswin over supplied ones: a host that set a value meant it, and the provider is the general case yielding to the specific one.Additive — no existing name or signature changed, and a transport with no provider behaves exactly as before. Ten regressions assert against a real socket, since the header map is assembled inside the transport and a mocked client would only be checking our own arrangement. Both guards mutation-checked.
- It cannot break the exchange. Names the protocol owns (
-
2.1.129 Jul 2026Release notes
Open source →Two cuts. The transport split changes behavior only on platforms without
dart:io— the STDIO and legacy SSE implementations are the same code, moved to the native branch of a conditional export. The conformance work adds methods and makes the protocol revision selectable; it removes nothing.Added — methods the protocol defines that this client could not send
Found by running this client against the official reference server: the calls simply did not exist on
Client.ping()— and an inboundpingis now answered with an empty result. The server side already handledping; the client neither sent nor answered one, so a server keepalive gotMethod not foundback.complete(ref, argument, {context})forcompletion/complete.
Changed — the protocol revision is chosen per client
Client.protocolVersionwasfinal, fixed at build time. A client could not speak a revision a peer offered, and could not be exercised against more than one. It is now a constructor parameter, carried throughMcpClientConfig,McpClient.createClientandcopyWith, defaulting to this build's default version.Added — required request headers on revision
2026-07-28The Streamable HTTP transport mirrors
Mcp-Method, and for the operations that name a targetMcp-Name, into headers on the stateless path, using the specification's base64 sentinel when a value cannot be carried as plain ASCII. The values are derived from the body, never assumed: a mirror that disagrees with the body is a rejectable mismatch.Changed
ClientTransportmoved tosrc/transport/client_transport.dartso both platform branches implement one type.src/transport/transport.dartis now a barrel that resolvesStdioClientTransportandSseClientTransportper platform.- The auth / compressed / heartbeat SSE variants resolve through
src/transport/legacy_sse.dartinstead of being exported individually.mcp_client.dartexports the barrel; the class names it re-exports are unchanged.
Fixed
- On platforms without
dart:io, constructing a transport that requires it now fails with an explicitMcpErrornaming the unsupported transport and pointing atStreamableHttpClientTransport, instead of surfacing an opaque platform error from deep inside the implementation. An unavailable capability is reported, never silently substituted. example/mcp_client_example_2.dart— non-English log strings replaced with English.
-
2.1.019 Jul 2026Release notes
Open source →Additive, backward-compatible (all new fields optional/named;
==/hashCodeunchanged; behavior changes are negotiated-version gated). No public API removed.Added — 2025-11-25 conformance
ResourceTemplate.icons(was dropped on resource templates).- Sampling tool-calling:
CreateMessageRequest.tools/toolChoice(SamplingToolChoicebuilders) +CreateMessageResult.toolCalls(SEP-1577). - Typed elicitation layer (
elicitation.dart):EnumSchema(titled/untitledenumNames), single- and multi-select enums (SEP-1330), URL-mode elicitation (SEP-1036), primitive default values (SEP-1034); raw-map path preserved. Implementation.descriptiononClientInfo/ServerInfo.- JSON Schema 2020-12 default dialect helper (SEP-1613).
- OAuth: PRM discovery (RFC 9728,
WwwAuthenticateChallenge.parse+discoverFrom401), OIDC Discovery 1.0 (PR#797), Client ID Metadata Documents (SEP-991,OAuthConfig.clientIdMetadataUrl), incremental scope step-up (SEP-835).
Deprecated
CallToolResult.isStreaming— non-standard hint, honored nowhere. Standard streaming = enable via a tool (tools/call) + deliver via a reactive resource (Client.listen/subscriptions/listen, or legacysubscribeResource). Retained + serialized for backward compatibility; removed in 3.0.
Added — 2026-07-28 stateless core (BUILD-DORMANT, opt-in via
connect(statelessMode: true), default off)_metareverse-DNS keys (McpRequestMeta),server/discover(Client.discover()), Multi-Round-Trip (InputRequiredResult),subscriptions/listen(Client.listen), Extensions framework (ClientCapabilities.extensions), Tasks extension (getTask/updateTask/cancelTask), RFC 9207issvalidation.- Inert until opted in — zero behavior change for existing consumers.
-
2.0.112 Jul 2026Release notes
Open source →Fixed
Tool/Resource/ResourceTemplate.fromJsonno longer requiredescription(optional per the MCP spec; missing →''). A server omitting it madetools/list/resources/listparsing throw aNullcast.
-
2.0.030 Apr 2026Release notes
Open source →Big-Bang spec normalization. Supports protocol revisions 2024-11-05, 2025-03-26, 2025-06-18, and 2025-11-25 with per-version capability gating. Pairs with mcp_server 2.0.
Breaking
- Sampling direction fixed.
client.createMessage(...)(which sent a request to the server) is removed. Sampling is server-initiated per spec — register a handler withclient.onSamplingRequest((req) async { ... })so the host LLM fulfils it. - Roots direction fixed.
client.listRoots()(which sent a request to the server) is removed. The server requests roots from the client; configure them locally withclient.addRoot(...)/client.removeRoot(...)and read viaclient.roots. Override the default response handler withclient.onListRoots(...).roots/addandroots/removeJSON-RPC methods (non-spec) are deleted. - Cancellation is now a notification.
client.cancelOperation(opId)(which sent acancelrequest) is removed; useclient.notifyCancelled(requestId, reason: ...)which emits the specnotifications/cancellednotification. - Logging method name corrected.
setLoggingLevelnow sendslogging/setLevel(camelCase) per spec — waslogging/set_level. client.healthCheck()removed —health/checkis non-spec; expose health via your transport (e.g. an HTTP/healthendpoint).onSamplingResponselistener removed — the non-specsampling/responsenotification path is gone, replaced by the standard request/response shape.
Added
client.onSamplingRequest(handler)— register a host LLM completion handler.client.onElicitationRequest(handler)— register a user-input handler (spec 2025-06-18elicitation/create).client.onListRoots(handler)— override the defaultroots/listresponse.client.notifyCancelled(requestId, {reason})andclient.notifyProgress(token, progress, {total, message})— spec notifications.ClientCapabilities.elicitationflag.McpProtocol.v2025_06_18andMcpProtocol.v2025_11_25constants.defaultVersionadvances tov2025_11_25.- Per-version capability gates:
McpProtocol.supportsBatching/supportsElicitation/requiresProtocolHeader. - Schema:
Tool.title/Tool.outputSchema/Tool.icons/Tool.meta.CallToolResult.structuredContent.AudioContent.ResourceLinkContent. - Incoming-request infrastructure routes server-initiated requests to registered handlers and returns a JSON-RPC response with the matching id.
- Sampling direction fixed.
-
1.1.128 Apr 2026Release notes
Open source →Changed
- README cleanup — removed "MCP Family" section, installation block, dev.to articles, and donation links.
-
1.1.016 Feb 2026Release notes
Open source →- New Features
- Deferred Tool Loading support (Progressive Tool Disclosure)
ToolMetadata- Lightweight tool representation (name + description only)ToolRegistry- Cache layer for tool definitions with metadata extractionClientToolMetadataExtension- Extension for easy metadata access- Reduces token usage by 60-80% when sending tool definitions to LLMs
- Zero breaking changes - fully backward compatible, opt-in only
- Deferred Tool Loading support (Progressive Tool Disclosure)
- New Features
-
1.0.207 Oct 2025Release notes
Open source →- Bug Fixes
- Added
terminateOnCloseparameter to StreamableHTTP transport configuration- Allows controlling whether DELETE request is sent on disconnect
- Default value is
trueto maintain backward compatibility - Set to
falseto allow reconnection after disconnect without server session termination
- Enhanced session validation and localStorage management
- Server-side session validation through
hasSession()check - Automatic localStorage cleanup when session ID changes (server restart detection)
- Proper handling of invalid/expired session IDs
- Improved reconnection logic for StreamableHTTP transport
- Server-side session validation through
- Added
- Bug Fixes
-
1.0.128 Jun 2025Release notes
Open source →- Bug Fixes
- Fixed SSE endpoint parsing issue where endpoint data was incorrectly processed as null
- Added support for SSE events without explicit event type field
- Improved compatibility with various SSE server implementations
- Fixed web platform SSE implementation to match native platform behavior
- Bug Fixes
-
1.0.006 Jun 2025Release notes
Open source →-
Breaking Changes and Major Update to 2025-03-26 Protocol
- Updated to MCP protocol version 2025-03-26 (from 2024-11-05)
- Complete refactoring for modern Dart 3.8+ patterns
- Added @immutable annotations throughout models
- Introduced sealed classes and pattern matching
- Enhanced type safety with Result<T, E> pattern
- Backward API compatibility maintained
-
New Features
- Protocol version negotiation support
- Enhanced Content model with annotations
- Tool cancellation and progress tracking
- Improved resource templates
- Better error handling with typed results
- Protocol constants centralized in McpProtocol class
-
Technical Improvements
- All models now use const constructors
- Factory constructors for JSON deserialization
- Centralized protocol configuration
- Better numeric type handling in JSON
- Cleaner API surface with protocol exports
-
-
0.1.802 May 2025Release notes
Open source →- Added
- Client event monitoring system using Dart's Stream API
onConnectstream for server connection eventsonDisconnectstream for server disconnection eventsonErrorstream for error events
- New models to support event monitoring
ServerInfoclass for connection detailsDisconnectReasonenum for disconnect causes
- Client lifecycle management improvements
- Added
dispose()method for proper resource cleanup - Enhanced error propagation through dedicated stream
- Better connection state tracking and reporting
- Added
- Client event monitoring system using Dart's Stream API
- Added
-
0.1.713 Apr 2025Nothing published for this version
-
0.1.602 Apr 2025Nothing published for this version
-
0.1.501 Apr 2025 -
0.1.431 Mar 2025 -
0.1.330 Mar 2025Release notes
Open source →- Fixed
- SSE Transport Connection Issues: Fixed critical issue with Server-Sent Events (SSE) connection where the client could not properly process JSON-RPC responses from the server.
- Improved event stream processing to correctly parse JSON-RPC messages
- Fixed handling of the endpoint event to establish the message channel
- Enhanced buffer management for fragmented SSE event data
- JSON-RPC Message Flow: Corrected the bidirectional communication flow between client and server:
- Client requests via HTTP POST to message endpoint now properly receive responses
- Fixed timeout issues by correctly handling asynchronous SSE responses
- SSE Transport Connection Issues: Fixed critical issue with Server-Sent Events (SSE) connection where the client could not properly process JSON-RPC responses from the server.
- Improved
- Error Handling: Enhanced error reporting and recovery for connection issues
- Logging: Added more detailed diagnostic logging for easier troubleshooting
- Stability: More robust message endpoint URL construction and session handling
- Technical Notes
- Updated SseClientTransport implementation to maintain persistent connections
- Fixed JSON response type handling for resource templates
- Improved session management and reconnection logic
- Fixed
-
0.1.228 Mar 2025Release notes
Open source →- New Features
- Protocol Update: Full support for all features of the 2024-11-05 protocol specification
- Progress Tracking: Added onProgress method to receive notifications about progress of long-running operations
- Operation Cancellation: Added cancelOperation method to cancel running operations
- Server Health Check: Added healthCheck method to check server's health status
- Resource Template Enhancement: Added getResourceWithTemplate method to access resources using URI templates
- Tool Execution with Progress Tracking: Added callToolWithTracking method that returns operation IDs
- Enhanced Resource Update Notifications: Added onResourceContentUpdated method that includes content information
- Sampling Response Handling: Added onSamplingResponse method to process sampling results
- New Model Classes
- ServerHealth: Class to hold server health status information
- PendingOperation: Class for managing ongoing operations
- ProgressUpdate: Class for operation progress updates
- CachedResource: Class for resource caching
- ToolCallTracking: Class to return tool call results and operation IDs together
- Technical Improvements
- Enhanced protocol version validation
- Improved error handling and exception messages
- Added options to colorize logs and include timestamps for easier debugging
- New Features
-
0.1.126 Mar 2025 -
0.1.025 Mar 2025Release notes
Open source →- Initial release
- Created Model Context Protocol (MCP) client implementation for Dart
- Features:
- Connect to MCP servers with standardized protocol support
- Access data through Resources
- Execute functionality through Tools
- Utilize interaction patterns through Prompts
- Support for Roots management
- Support for Sampling (LLM text generation)
- Multiple transport layers:
- Standard I/O for local process communication
- Server-Sent Events (SSE) for HTTP-based communication
- Platform support: Android, iOS, web, Linux, Windows, macOS