SuyodhanJ6/mcp-sse-rust
If you are the rightful owner of mcp-sse-rust and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The MCP SSE Rust Calculator Server is a high-performance server implemented in Rust, providing calculator functionalities through Server-Sent Events (SSE) and JSON-RPC APIs.
๐งฎ 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 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