mcp-sse-rust

SuyodhanJ6/mcp-sse-rust

3.2

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.

Tools
4
Resources
0
Prompts
0

๐Ÿงฎ MCP SSE Rust Calculator Server

Rust License: MIT Build Status

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

ToolDescriptionParameters
addAdd two numbers togethera: number, b: number
multiplyMultiply two numbers togethera: number, b: number
squareCalculate the square of a numbernumber: number
sqrtCalculate the square root of a numbernumber: number (non-negative)

๐Ÿš€ Quick Start

Prerequisites

  • Rust (version 1.70 or later)
  • Cargo (comes with Rust)

Installation

  1. Clone the repository

    git clone https://github.com/SuyodhanJ6/mcp-sse-rust.git
    cd mcp-sse-rust
    
  2. Install dependencies

    cargo build
    
  3. 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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see the file for details.

๐Ÿ™ Acknowledgments

Made with โค๏ธ in Rust by Prashant Malge