dart_mcp
A Dart implementation of the Model Context Protocol (MCP)
Documentation
dart_mcp
A Dart implementation of the Model Context Protocol (MCP).
Features
- Full implementation of the MCP specification
- Support for both client and server roles
- Built-in stdio transport layer
- Type-safe API with JSON serialization
- Comprehensive test coverage
Installation
Add this to your package's `pubspec.yaml` file:
dependencies:
dart_mcp: ^1.0.0Usage
Client Example
import 'package:dart_mcp/dart_mcp.dart';
void main() async {
// Create a transport for the client
final transport = StdioTransport();
// Create a client with basic capabilities
final client = McpClient(transport);
try {
// Initialize the client
final result = await client.initialize(
capabilities: ClientCapabilities(
sampling: SamplingCapability(),
),
clientInfo: Implementation(
name: 'example-client',
version: '1.0.0',
),
);
print('Connected to server: ${result.serverInfo.name} ${result.serverInfo.version}');
print('Server capabilities: ${result.capabilities}');
// Send a ping request
await client.sendRequest('ping');
print('Ping successful');
} catch (e) {
print('Error: $e');
} finally {
await client.close();
}
}Server Example
import 'package:dart_mcp/dart_mcp.dart';
void main() async {
// Create a transport for the server
final transport = StdioTransport();
// Create a server with capabilities
final server = McpServer(
transport: transport,
capabilities: ServerCapabilities(
tools: ToolsCapability(),
resources: ResourcesCapability(),
),
serverInfo: Implementation(
name: 'example-server',
version: '1.0.0',
),
);
// Register request handlers
server.onRequest('ping', (params) async {
return EmptyResult();
});
// Handle client notifications
server.onNotification('notifications/initialized', (params) {
print('Client initialized');
});
}Features and bugs
Please file feature requests and bugs at the issue tracker.
License
MIT License - see LICENSE file for details.
Frequently asked questions
What is dart_mcp?
dart_mcp is A Dart implementation of the Model Context Protocol (MCP)
How do I install dart_mcp?
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 dart_mcp open source?
Yes — it is hosted on GitHub at https://github.com/cristhro/dart_mcp and has 2 stars.
Related MCP tools
ChatMCP is an AI chat client implementing the Model Context Protocol (MCP). Dart-based implementation. Trusted by 2000+ developers.
🙌 OpenHands: Code Less, Make More for the Model Context Protocol. Enhance AI assistants with powerful integrations. Python-based implementation.
The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.
Universal memory layer for AI Agents; Announcing OpenMemory MCP - local and secure memory management. Python-based implementation.
基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择ChatGPT/Claude/DeepSeek/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。
:robot: The free, Open Source alternative to OpenAI, Claude and others. Self-hosted and local-first. Drop-in replacement for OpenAI, running on consumer-gra...
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP