mcp-sse-rust
mcp-sse-rustは、Rustプログラミング言語を使用して、特定の機能を実装するためのライブラリです。このプロジェクトは、Rustの特性を活かしつつ、効率的なコード生成やデータ処理を目指しています。初心者には少し難しいかもしれませんが、Rustに慣れている開発者にとっては有用なツールとなるでしょう。
GitHubスター
0
ユーザー評価
未評価
お気に入り
0
閲覧数
10
フォーク
0
イシュー
0
🧮 MCP SSE Rust Calculator Server
A high-performance Model Context Protocol (MCP) server implemented in Rust that provides calculator functionality through Server-Sent Events (SSE) and JSON-RPC APIs.
✨ Features
- 🚀 High Performance: Built with Rust and Axum for maximum performance
- 🔄 Real-time Communication: Server-Sent Events (SSE) support
- 🧮 Calculator Tools: Addition, multiplication, square, and square root operations
- 📡 JSON-RPC Protocol: Compliant with MCP 2024-11-05 specification
- 🌐 CORS Enabled: Cross-origin resource sharing support
- 🧪 Well Tested: Comprehensive unit tests included
- ⚡ Async/Await: Fully asynchronous implementation with Tokio
🛠️ Available Tools
Tool | Description | Parameters |
---|---|---|
add |
Add two numbers together | a: number , b: number |
multiply |
Multiply two numbers together | a: number , b: number |
square |
Calculate the square of a number | number: number |
sqrt |
Calculate the square root of a number | number: number (non-negative) |
🚀 Quick Start
Prerequisites
Installation
Clone the repository
git clone https://github.com/SuyodhanJ6/mcp-sse-rust.git cd mcp-sse-rust
Install dependencies
cargo build
Run the server
cargo run
The server will start on http://localhost:3000
🎉
MCP Integration with Cursor
To use this server with Cursor IDE, add the following to your ~/.cursor/mcp.json
:
{
"mcpServers": {
"mcp-calculator-sse": {
"url": "http://127.0.0.1:3000/mcp",
"transport": "sse"
}
}
}
After adding the configuration, restart Cursor to enable the calculator tools.
Development
For development with auto-reload:
cargo install cargo-watch
cargo watch -x run
📖 API Documentation
Endpoints
Health Check
GET /health
Returns server health status.
MCP Endpoint (for Cursor integration)
GET /mcp
Model Context Protocol endpoint with Server-Sent Events for Cursor IDE integration.
JSON-RPC Endpoint
POST /jsonrpc
Content-Type: application/json
Server-Sent Events
GET /sse
Establishes SSE connection for real-time communication.
JSON-RPC Methods
Initialize
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {}
}
List Tools
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list"
}
Call Tool
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "add",
"arguments": {
"a": 5,
"b": 3
}
}
}
🧪 Examples
Using curl
Add two numbers:
curl -X POST http://localhost:3000/jsonrpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "add",
"arguments": {"a": 10, "b": 5}
}
}'
Calculate square root:
curl -X POST http://localhost:3000/jsonrpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "sqrt",
"arguments": {"number": 16}
}
}'
Server-Sent Events
Connect to the SSE endpoint:
curl -N http://localhost:3000/sse
🧪 Testing
Run the test suite:
cargo test
Run tests with output:
cargo test -- --nocapture
📁 Project Structure
mcp-sse-rust/
├── src/
│ └── main.rs # Main server implementation
├── Cargo.toml # Dependencies and project metadata
├── Cargo.lock # Dependency lock file
├── LICENSE # MIT License
├── README.md # This file
└── .gitignore # Git ignore patterns
🔧 Configuration
The server runs on port 3000
by default. You can modify this in the main()
function in src/main.rs
.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Axum - Web application framework
- Tokio - Asynchronous runtime
- Serde - Serialization framework
- Model Context Protocol - Protocol specification
- MCP SSE Rust - Related MCP server implementation
Made with ❤️ in Rust by Prashant Malge