mcp_dart
Dart implementation of MCP SDK
Documentation
MCP (Model Context Protocol) for Dart
`mcp_dart` is a dual-era Dart and Flutter SDK for MCP clients, servers, and AI
hosts. It implements the complete core client/server wire surface of the locked
MCP 2026-07-28 specification, retains the MCP 2025-11-25 feature set, and
negotiates supported earlier initialization-based specifications.
Here, core means the normative wire requirements assigned to client and server
roles by the pinned final specification. It excludes optional MCP
extensions, host UI behavior, an authorization-server implementation, JSON
Schema external-reference resolution, and custom JSON Schema vocabularies.
> [!IMPORTANT]
> The current stable packages are `mcp_dart 2.4.1` and
> `mcp_dart_cli 0.2.0`; the CLI's `^2.3.0` SDK constraint accepts 2.4.
> Current source passes every scored requirement in the official alpha.11 MCP
> `2025-11-25` and `2026-07-28` client and server sets, including all 25
> required 2026 authorization scenarios, plus bidirectional published
> TypeScript SDK 2.0.0 and Python SDK 2.0.0 interoperability.
SDK Tier 1 target
The project is pursuing
MCP SDK Tier 1. Tier 1
is not yet claimed or assigned. The technical baseline is green; the remaining
official audit, repository-governance, and SDK Working Group steps are tracked
in the roadmap and
48-feature coverage inventory.
The public maintenance contract is documented in the
contribution guide, security policy,
dependency policy, and
Requirements
| Package | Minimum Dart SDK |
|---|---|
| `mcp_dart 2.4.1` | 3.4 |
| `mcp_dart_cli 0.2.0` | 3.12 |
SDK-only generated projects retain the SDK's Dart 3.4 minimum. CLI projects
use Dart 3.12 because the CLI and its toolchain target that release.
Install Dart from dart.dev.
Installation
Production channel
Use the latest stable package for production projects:
dart pub add mcp_dartPin the stable SDK release
Pin the stable 2.4 line explicitly when reproducible dependency resolution is
important:
dependencies:
mcp_dart: ^2.4.1The snippets below use the current stable SDK line. Package versions
remain separate from protocol profiles: `McpProtocol.stable` names the SDK's
default compatibility policy.
The SDK and CLI are versioned independently. The stable CLI's `^2.3.0`
constraint remains compatible with the 2.4 SDK.
For direct SDK integration, start with the
The CLI below is optional and provides scaffolding, inspection, and conformance
commands.
What the SDK provides
- MCP servers, clients, and host integrations with null-safe Dart APIs.
- Core tools, resources, prompts, completion, elicitation, subscriptions,
logging, roots, and sampling APIs with behavior selected for the negotiated
protocol era. MCP 2026-07-28 logging is retained for compatibility but is
deprecated upstream.
- Stdio, Streamable HTTP, IO stream, and custom transports.
- OAuth client discovery/PKCE hooks, server authentication callbacks, DNS
rebinding protection, and strict Streamable HTTP validation.
- An experimental Tasks extension implementation, MCP Apps metadata helpers,
and generic extension negotiation. Extensions are separate from core
protocol coverage; Tasks is not an official extension or part of the SDK's
core conformance claim.
- Automated MCP 2025-11-25 and MCP 2026-07-28 conformance, bidirectional
published TypeScript SDK 2.0.0 interoperability, bidirectional Python SDK
2.0.0 interoperability, real-browser transport tests, a real Flutter Web
service integration in Chrome, deterministic widget tests, and an
independent pinned JSON Schema Test Suite gate.
- `mcp_dart 2.4.1` hardens Streamable HTTP access and JSON-RPC error
diagnostics and retains the deprecated, opt-in legacy HTTP+SSE client with
same-origin routing and bidirectional interoperability against official
TypeScript SDK 1.30.0 and Python SDK 2.0.0 peers.
MCP has three roles: a host owns the user experience, a client connects that
host to one server, and a server exposes tools, resources, and prompts. A host
can manage multiple clients and servers.
Protocol profiles
| Profile | Protocol behavior |
|---|---|
| `McpProtocol.stable` | Default dual-era profile: prefer MCP 2026-07-28, then fall back to initialization-based MCP specifications; body-only discovery probes are bounded to 5 seconds |
| `McpProtocol.legacy` | Initialization-era profile: negotiate the MCP 2025-11-25, MCP 2025-06-18, MCP 2025-03-26, MCP 2024-11-05, or MCP 2024-10-07 specification |
| `McpProtocol.require2026` | Require MCP 2026-07-28 and reject legacy initialization |
Use `stableProtocolVersion` or `defaultProtocolVersion` for MCP `2026-07-28`.
`previewProtocolVersion` remains as a deprecated alias for applications built
against a 2.3 prerelease.
`latestInitializationProtocolVersion` remains `2025-11-25` when the default
profile falls back to the legacy lifecycle. For compatibility,
`latestProtocolVersion` and `supportedProtocolVersions` retain their mcp_dart
2.2 initialization-era values; use `allSupportedProtocolVersions` for the
dual-era list.
Select a profile only when you need to constrain negotiation:
final legacyClient = McpClient(
const Implementation(name: 'my-client', version: '1.0.0'),
options: const McpClientOptions(protocol: McpProtocol.legacy),
);
final strict2026Server = McpServer(
const Implementation(name: 'my-server', version: '1.0.0'),
options: const McpServerOptions(protocol: McpProtocol.require2026),
);See the MCP 2026-07-28 transition guide
for fallback rules and APIs specific to MCP 2026-07-28, or run the
strict MCP 2026-07-28 example.
Applications upgrading from the stable 2.2 line should also follow the
Quick start with the CLI
Install the matching stable CLI:
dart pub global activate mcp_dart_cli 0.2.0
mcp_dart create my_server
cd my_server
mcp_dart inspectThe `0.2.0` CLI creates a project with `mcp_dart: ^2.3.0`. The inspector
launches the generated stdio server itself. After leaving the interactive
inspector, you can run a single tool directly:
mcp_dart inspect --tool add --json-args '{"a": 1, "b": 2}'Useful commands:
| Command | Purpose |
|---|---|
| `create` | Scaffold a Dart MCP server using the SDK channel paired with the CLI |
| `serve` | Run a generated server over stdio or HTTP |
| `doctor` | Check project health and connectivity |
| `inspect` | Interactively use a server's capabilities |
| `inspect-server` | Produce a structured report for a live server |
| `inspect-client` | Run a stdio harness that inspects a connecting client |
| `trace` | Proxy and record a real stdio session |
| `conformance` | Run the repository's built-in protocol regression fixtures |
See the CLI documentation
for command options and scope.
Documentation
- Start: getting started, server guide, client guide, quick reference
- Upgrade: 2.2 to 2.3 migration guide, migration cookbooks, MCP 2026-07-28 transition guide
- Build: tools, transports, examples, MCP Apps
- Deploy: Streamable HTTP security, OAuth examples, Flutter recipes
- Verify: interop matrix, MCP 2025-11-25 coverage, MCP 2026-07-28 coverage, day-0 runbook
Standalone integration examples may declare newer Dart SDK requirements; check
each example README before running it.
Authentication
`StreamableHttpClientTransport` supports `OAuthClientProvider` and optional
authorization-code discovery. Servers can use `authenticator` or
`authenticationHandler` and publish protected-resource metadata.
The checked-in OAuth examples store tokens in plaintext files for local
learning. Production applications must use platform secure storage or an
encrypted credential service. See the OAuth examples
and Streamable HTTP authentication.
Do not expose example HTTP servers directly to untrusted networks. Production
deployments should use TLS, authenticate requests, and configure the documented
Platform support
| Target | Stdio | Streamable HTTP | Legacy HTTP+SSE | IO/custom stream |
|---|---|---|---|---|
| Dart VM / desktop server | Yes | Client and server | Client and server | Yes |
| Browser / Flutter Web | No process spawning | Client | Client | Yes |
| Flutter mobile | Only app-managed native helpers | Remote client | Remote client | Yes |
| Flutter desktop | Local helper processes | Client and server | Client and server | Yes |
Legacy HTTP+SSE is deprecated under MCP SEP-2596 and is retained only for
explicit compatibility. Use Streamable HTTP for new remote integrations.
See Flutter host and client recipes
for lifecycle and secure-storage guidance.
Choosing a Dart MCP package
The Dart team maintains `dart_mcp` in
Choose it when you prefer the Dart team's APIs. Choose `mcp_dart` when you need
this SDK's transport, security, compatibility, extension, and inspection
surface. Re-check both packages' current releases before a production decision.
Support
Frequently asked questions
What is mcp_dart?
mcp_dart is Dart implementation of MCP SDK
How do I install mcp_dart?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp_dart open source?
Yes — it is hosted on GitHub at https://github.com/leehack/mcp_dart/ and has 85 stars.
Related MCP tools
ChatMCP is an AI chat client implementing the Model Context Protocol (MCP). Dart-based implementation. Trusted by 2000+ developers.
The official TypeScript SDK for Model Context Protocol servers and clients Trusted by 10500+ developers. Trusted by 10500+ developers.
Visual testing tool for MCP servers TypeScript-based implementation. Trusted by 7300+ developers. Trusted by 7300+ developers.
AWS MCP Servers — helping you get the most out of AWS, wherever you use MCP. Python-based implementation. Trusted by 6900+ developers.
A collection of MCP clients. Trusted by 5900+ developers. Trusted by 5900+ developers. Trusted by 5900+ developers. Trusted by 5900+ developers.
MCP 资源精选, MCP指南,Claude MCP,MCP Servers, MCP Clients Trusted by 4800+ developers. Trusted by 4800+ developers. Trusted by 4800+ developers.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP