MCP for Dart
A Dart SDK for building MCP servers and clients.
MCP (Model Context Protocol) for Dart
The Model Context Protocol (MCP) is a standardized protocol for communication between AI applications and external services. It enables:
- Tools: Allow AI to execute actions (API calls, computations, etc.)
- Resources: Provide context and data to AI (files, databases, APIs)
- Prompts: Pre-built prompt templates with arguments
Understanding MCP: Client, Server, and Host
MCP follows a client-server architecture with three key components:
-
MCP Host: The AI application that provides the user interface and manages connections to multiple MCP servers.
- Example: Claude Desktop, IDEs like VS Code, custom AI applications
- Manages server lifecycle, discovers capabilities, and orchestrates interactions
-
MCP Client: The protocol implementation within the host that communicates with servers.
- Handles protocol negotiation, capability discovery, and request/response flow
- Typically built into or used by the MCP host
-
MCP Server: Provides capabilities (tools, resources, prompts) that AI can use through the host.
- Example: Servers for file system access, database queries, or API integrations
- Runs as a separate process and communicates via standardized transports (stdio, StreamableHTTP)
Typical Flow: User ↔ MCP Host (with Client) ↔ MCP Protocol ↔ Your Server ↔ External Services/Data
Requirements
- Dart SDK version ^3.0.0 or higher
Ensure you have the correct Dart SDK version installed. See https://dart.dev/get-dart for installation instructions.
Installation
Add to your pubspec.yaml:
dependencies:
mcp_dart: ^2.1.0
Then install dependencies:
dart pub get
What This SDK Provides
This SDK lets you build both MCP servers and clients in Dart/Flutter.
- ✅ Build MCP Servers - Create servers that expose tools, resources, and prompts to AI hosts
- ✅ Build MCP Clients - Create AI applications that can connect to and use MCP servers
- ✅ Full MCP Protocol Support - Complete MCP specification 2025-11-25 implementation
- ✅ Multiple Transport Options - Stdio, StreamableHTTP, IOStream, or custom transports
- ✅ All Capabilities - Tools, Resources, Prompts, Sampling, Roots, Completions, Elicitation, Tasks
- ✅ Extension Support - Generic
extensionsnegotiation with typed MCP Apps helpers and TypeScript-styleregisterAppTool/registerAppResource - ✅ Latest Content/Metadata Types -
resource_link, themedicons, andannotations.lastModified - ✅ OAuth2 Support - Complete authentication with PKCE
- ✅ Transport Security Controls - DNS rebinding protection and strict Streamable HTTP validation with compatibility toggles
- ✅ Type-Safe - Comprehensive type definitions with null safety
- ✅ Cross-Platform - Works on Linux, Windows, macOS, Web, and Flutter
The goal is to make this SDK as similar as possible to the official SDKs available in other languages, ensuring a consistent developer experience across platforms.
Model Context Protocol Version
The current version of the protocol is 2025-11-25. This library is designed to be compatible with this version, and any future updates will be made to ensure continued compatibility.
It's also backward compatible with previous versions including 2025-06-18, 2025-03-26, 2024-11-05, and 2024-10-07.
Documentation
Getting Started
- 📖 Quick Start Guide - Get up and running in 5 minutes
- 🔧 Server Guide - Complete guide to building MCP servers
- 💻 Client Guide - Complete guide to building MCP clients
Core Concepts
- 🛠️ Tools Documentation - Implementing executable tools
- 🔌 Transport Options - Built-in and custom transport implementations
- 📚 Examples - Real-world usage examples
- ⚡ Quick Reference - Fast lookup guide
- 🪵 Runtime Logging - Configure and route internal SDK logs
- 🧩 MCP Apps Guide - Using
io.modelcontextprotocol/uimetadata
Advanced Features
- 🔐 OAuth Authentication - OAuth2 guides and examples
- 🔁 2025-11-25 Compatibility Migration - Backward-compatible API/runtime migration notes
- 📝 For resources, prompts, and other features, see the Server and Client guides
Quick Start with CLI
The fastest way to create an MCP server is using the mcp_dart_cli:
# Install the CLI
dart pub global activate mcp_dart_cli
# Create a new project
mcp_dart create my_server
# Navigate and run
cd my_server
mcp_dart serve
Your server is now running! Use mcp_dart inspect to test it:
mcp_dart inspect # List all capabilities
mcp_dart inspect --tool add --json-args '{"a": 1, "b": 2}' # Call a tool
CLI Commands
| Command | Description |
|---|---|
create | Scaffold a new MCP server project |
serve | Run your server (stdio or HTTP) |
doctor | Check project health and connectivity |
inspect | Test and debug server capabilities |
Connecting to AI Hosts
Configure your server with AI hosts like Claude Desktop:
{
"mcpServers": {
"my_server": {
"command": "mcp_dart",
"args": ["serve"],
"cwd": "/path/to/my_server"
}
}
}
[!TIP] For manual server implementation or advanced use cases, see the Server Guide.
Authentication
This library supports OAuth2 authentication with PKCE for both clients and servers. For complete authentication guides and examples, see the OAuth Authentication documentation.
Platform Support
| Platform | Stdio | StreamableHTTP | IOStream | Custom |
|---|---|---|---|---|
| Desktop (CLI/Server) | ✅ | ✅ | ✅ | ✅ |
| Web (Browser) | ❌ | ✅ | ✅ | ✅ |
| Flutter (Mobile/Desktop) | ✅ | ✅ | ✅ | ✅ |
Custom Transports: You can implement your own transport layer by extending the transport interfaces if you need specific communication patterns not covered by the built-in options.
More Examples
For additional examples including authentication, HTTP clients, and advanced features:
Community & Support
- Issues & Bug Reports: GitHub Issues
- Package: pub.dev/packages/mcp_dart
- API Docs: pub.dev documentation
- Changelog: CHANGELOG.md
- Protocol Spec: MCP Specification
Credits
This library is inspired by the following projects:
関連サーバー
Scout Monitoring MCP
スポンサーPut performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
スポンサーAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
mcp4eda
A collection of MCP servers for Electronic Design Automation (EDA) workflows, including tools for die yield calculation and Verilog/SystemVerilog analysis.
DHTMLX MCP Server
The DHTMLX MCP server provides real-time access to official docs and a smart RAG.
PowerShell
Execute PowerShell scripts for Windows automation, system maintenance, data processing, and network monitoring.
Cashfree MCP Server
Integrate AI tools and agents with Cashfree's Payment Gateway, Payouts, and SecureID APIs.
kintone
An MCP server for integrating with the kintone REST API. Supports CRUD operations, file management, comments, and status updates.
Norce Assistant
Provides AI-powered knowledge and code examples for Norce Commerce development directly in your preferred AI environment.
Biel.ai MCP Server
Connect AI tools like Cursor and VS Code to your product documentation using the Biel.ai platform.
Web3 Playground & Sandbox - Learn, Develop, Test MCP Servers + Toolkit SDK
Free Solidity compiler & Web3 IDE with interactive tutorials. Learn blockchain development, deploy smart contracts to 8+ chains (Ethereum, Polygon, Base, Arbitrum, Solana). Templates for tokens, NFTs, DeFi, DAOs. Monaco Editor, AI assistance, WCAG accessible. Remix alternative. Gas optimization, MetaMask integration, open source. Beginner-friendly. MCP toolkit.
Nucleus MCP
Local-first, cross-platform memory sync for AI coding tools (Cursor, Claude, Windsurf) with persistent engrams and hypervisor security.
iOS Simulator MCP Server
A Model Context Protocol (MCP) server for interacting with iOS simulators. This server allows you to interact with iOS simulators by getting information about them, controlling UI interactions, and inspecting UI elements.