DigiBugCat/simple-rust-mcp-server
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.
get_time
Get the current time
increment_counter
Increment a counter
get_counter
Get the current counter value
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 timeincrement_counter
- Increment a counterget_counter
- Get the current counter valuesystem_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 branchvX.Y.Z
- Specific version releasesmain
- Latest main branch build
Testing with MCP Inspector
You can test the server using MCP Inspector:
- Start the server:
docker run -p 8080:8080 ghcr.io/digibugcat/simple-rust-mcp-server:latest
- Open MCP Inspector
- Select transport:
streamable-http
- Enter URL:
http://localhost:8080/message
- 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