hello_world_dart_mcp_server
A simple Hello World MCP server written in Dart that demonstrates basic MCP server implementation with two example tools: say_hello and get_server_info.
README
Hello World MCP Server
A simple Hello World MCP (Model Context Protocol) server written in Dart that demonstrates basic MCP server implementation with two example tools.
Overview
This MCP server provides a minimal example of how to implement an MCP server in Dart. It includes two basic tools:
say_hello: Greets a person with an optional custom messageget_server_info: Returns information about the MCP server
Features
- JSON-RPC 2.0 protocol implementation
- Stdio-based communication
- Cross-platform support (Windows, Linux, macOS)
- Native binary compilation
- Simple tool demonstration
Requirements
- Dart SDK 3.0.0 or later
- Compatible MCP client
Installation
Option 1: Using Dart Runtime (Development)
-
Clone this repository:
git clone <repository-url> cd hello-world-server -
Install dependencies:
dart pub get -
Run the server:
dart run bin/hello_world_mcp_server.dart
Option 2: Using Pre-built Binaries (Production)
Download the appropriate binary for your platform from the Releases page:
- Windows:
hello_world_mcp_server-windows-amd64.exeorhello_world_mcp_server-windows-arm64.exe - Linux:
hello_world_mcp_server-linux-amd64orhello_world_mcp_server-linux-arm64 - macOS:
hello_world_mcp_server-macos-amd64orhello_world_mcp_server-macos-arm64
Linux/macOS Setup:
# Make the binary executable
chmod +x hello_world_mcp_server-linux-amd64
# Run the server
./hello_world_mcp_server-linux-amd64
Windows Setup:
# Run directly
hello_world_mcp_server-windows-amd64.exe
Option 3: Build from Source
# Install dependencies
dart pub get
# Compile to native executable
dart compile exe bin/hello_world_mcp_server.dart -o hello_world_mcp_server
# Run the compiled binary
./hello_world_mcp_server # Linux/macOS
hello_world_mcp_server.exe # Windows
Usage
Running the MCP Server
The MCP server communicates via stdin/stdout using the JSON-RPC 2.0 protocol. It's designed to be used with MCP-compatible clients.
Using Native Dart Runner
dart run bin/hello_world_mcp_server.dart
Using Compiled Binary
# Linux/macOS
./hello_world_mcp_server-linux-amd64
# Windows
hello_world_mcp_server-windows-amd64.exe
MCP Client Configuration
To use this server with an MCP client, configure it as a stdio-based server:
Example Configuration (MCP Client)
{
"mcpServers": {
"hello-world": {
"command": "dart",
"args": ["run", "/path/to/hello-world-server/bin/hello_world_mcp_server.dart"]
}
}
}
Using Binary in MCP Client
{
"mcpServers": {
"hello-world": {
"command": "/path/to/hello_world_mcp_server-linux-amd64"
}
}
}
Manual Testing
You can test the server manually by sending JSON-RPC messages:
# Initialize the server
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | dart run bin/hello_world_mcp_server.dart
# List available tools
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' | dart run bin/hello_world_mcp_server.dart
# Call the say_hello tool
echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"say_hello","arguments":{"name":"World","message":"Greetings"}}}' | dart run bin/hello_world_mcp_server.dart
# Get server information
echo '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"get_server_info","arguments":{}}}' | dart run bin/hello_world_mcp_server.dart
Available Tools
say_hello
Greets a person with an optional custom message.
Parameters:
name(required, string): The name of the person to greetmessage(optional, string): Custom message (defaults to "Hello")
Example:
{
"name": "say_hello",
"arguments": {
"name": "Alice",
"message": "Good morning"
}
}
Response:
Good morning, Alice! 👋
get_server_info
Returns information about this MCP server.
Parameters: None
Example:
{
"name": "get_server_info",
"arguments": {}
}
Response:
Hello World MCP Server Information:
- Name: hello-world-server
- Version: 1.0.0
- Language: Dart
- Protocol Version: 2024-11-05
- Available Tools: say_hello, get_server_info
This is a simple demonstration MCP server that shows how to implement basic tools using Dart.
Development
Project Structure
hello-world-server/
├── bin/
│ └── hello_world_mcp_server.dart # Main server implementation
├── dagger/
│ └── build_script.py # Dagger build script for multi-platform builds
├── artifacts/ # Build output directory (created by Dagger)
├── BUILD.md # Detailed build instructions
├── LICENSE # MIT License
├── pubspec.yaml # Dart project configuration
├── pyproject.toml # Python project config for Dagger builds
├── README.md # This file
└── .gitignore # Git ignore rules
Running in Development
# Install dependencies
dart pub get
# Run the server
dart run bin/hello_world_mcp_server.dart
# Run with debugging output
dart run bin/hello_world_mcp_server.dart 2>debug.log
Building
Option 1: Using Dagger (Recommended)
This project uses Dagger for reproducible, containerized builds across all platforms.
Note for Windows developers, Python is used for the dagger builds, but that piece is best done in 'nix.
Prerequisites:
- Python 3.11+
- Docker (for Dagger)
Build all platforms:
# Install Python dependencies
pip install -r requirements.txt
# Run the Dagger build script
python build_script.py
This will build binaries for:
- Windows (AMD64, ARM64)
- Linux (AMD64, ARM64)
- macOS/Darwin (AMD64, ARM64)
All binaries will be saved to the artifacts/ directory.
Using pyproject.toml:
# Install in development mode
pip install -e .
# Run the build command
build-binaries
Option 2: Manual Build
See BUILD.md for comprehensive build instructions, including:
- Manual compilation
- Cross-platform building
- Release process
Protocol Details
This server implements the MCP (Model Context Protocol) specification:
- Protocol Version: 2024-11-05
- Transport: stdio (stdin/stdout)
- Message Format: JSON-RPC 2.0
- Capabilities: Tools
Supported Methods
initialize- Initialize the MCP sessionnotifications/initialized- Acknowledge initializationtools/list- List available toolstools/call- Execute a tool
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Please ensure your changes:
- Follow Dart coding conventions
- Include appropriate tests
- Don't break existing functionality
- Update documentation as needed
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For issues, questions, or contributions, please use the GitHub repository's issue tracker.
Related
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。