simple-rust-mcp-server

DigiBugCat/simple-rust-mcp-server

3.2

If you are the rightful owner of simple-rust-mcp-server 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.

A simple Model Context Protocol (MCP) server implementation in Rust with streamable-http transport.

Tools
  1. get_time

    Get the current time

  2. increment_counter

    Increment a counter

  3. get_counter

    Get the current counter value

  4. system_info

    Get system information

MCP Server

A simple Model Context Protocol (MCP) server implementation in Rust with streamable-http transport. This server provides example tools and can be easily deployed using Docker.

Features

  • šŸš€ Lightweight MCP server with streamable-http transport
  • šŸ› ļø Four example tools included:
    • get_time - Get the current time
    • increment_counter - Increment a counter
    • get_counter - Get the current counter value
    • system_info - Get system information
  • 🐳 Docker support with multi-platform builds (amd64/arm64)
  • šŸ”„ Automatic GitHub Actions for Docker image publishing
  • šŸ“¦ Minimal dependencies and small image size

Quick Start

Using Docker (Recommended)

Pull and run the latest image:

docker run -p 8080:8080 ghcr.io/digibugcat/simple-rust-mcp-server:latest

Using Docker Compose

docker-compose up

Building from Source

Requirements:

  • Rust 1.75 or later
# Clone the repository
git clone https://github.com/DigiBugCat/simple-rust-mcp-server.git
cd simple-rust-mcp-server

# Build and run
cargo run --release

Endpoints

  • Streamable HTTP Endpoint: http://localhost:8080/message - JSON-RPC endpoint for MCP protocol

Environment Variables

  • HOST - Server host (default: 0.0.0.0)
  • PORT - Server port (default: 8080)
  • RUST_LOG - Log level (default: mcp_server=info)

Docker Image

The Docker image is automatically built and published to GitHub Container Registry on every push to the main branch.

Available Tags

  • latest - Latest build from main branch
  • vX.Y.Z - Specific version releases
  • main - Latest main branch build

Testing with MCP Inspector

You can test the server using MCP Inspector:

  1. Start the server: docker run -p 8080:8080 ghcr.io/digibugcat/simple-rust-mcp-server:latest
  2. Open MCP Inspector
  3. Select transport: streamable-http
  4. Enter URL: http://localhost:8080/message
  5. Connect and test the tools

Example Usage with MCP Client

// Example using the MCP SDK with streamable-http transport
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StreamableHttpClientTransport } from '@modelcontextprotocol/sdk/client/streamable-http.js';

const transport = new StreamableHttpClientTransport(
  new URL('http://localhost:8080/message')
);

const client = new Client({
  name: 'example-client',
  version: '1.0.0',
}, {
  capabilities: {}
});

await client.connect(transport);

// Call a tool
const result = await client.callTool({
  name: 'get_time',
  arguments: {}
});

console.log(result);

Development

Project Structure

.
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ main.rs         # Main server entry point
│   └── mcp/
│       ā”œā”€ā”€ mod.rs      # MCP module
│       └── tools.rs    # Tool implementations
ā”œā”€ā”€ Cargo.toml          # Rust dependencies
ā”œā”€ā”€ Dockerfile          # Multi-stage Docker build
ā”œā”€ā”€ docker-compose.yml  # Local development setup
└── .github/
    └── workflows/
        └── docker-publish.yml  # CI/CD pipeline

Adding New Tools

To add new tools, edit src/mcp/tools.rs and add your tool implementation using the #[tool] macro:

#[tool(description = "Your tool description")]
async fn your_tool_name(&self, param: String) -> Result<CallToolResult, McpError> {
    // Tool implementation
    Ok(CallToolResult::success(vec![
        Content::text("Tool result")
    ]))
}

License

MIT