Calculator (Rust Binary)
VerifiedLocalAbout Calculator (Rust Binary)
Calculator (Rust Binary) is an example MCP server packaged as a compiled Rust executable in an MCP Bundle. It demonstrates the binary server type for Rust projects and other workloads that need a native binary.
Key features
- 01Rust binary MCP server
- 02Sum and difference tools
- 03MCP Bundle binary packaging example
- 04Stdio protocol communication
Use cases
- 01Package a Rust MCP server as a binary bundle
- 02Test calculator tool calls over MCP
MCP support
The server exposes `sum` and `sub` tools to MCP clients over stdio. It is packaged as a binary-type MCP Bundle.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
2Saved tool list · updated 2w ago
This tool takes no parameters.
Details
From the project READMECalculator Rust Binary Example
Demonstrates packaging a compiled Rust binary as an MCP Bundle using the binary server type. Based on the official Rust MCP SDK calculator example.
What is Binary Server Type?
Unlike node or uv server types where the source code is bundled and executed by a runtime, the binary server type packages a pre-compiled native executable. This is useful for:
- Rust, Go, C/C++ MCP servers
- Performance-sensitive workloads
- Servers with no runtime dependencies
The tradeoff is that binaries are platform-specific — you need a separate build for each target OS/architecture.
Structure
calculator-rust/
├── manifest.json # server.type = "binary"
├── Cargo.toml # Rust project
├── .mcpbignore # Exclude source from bundle
└── src/
└── main.rs # Calculator MCP server (~80 LOC)
After building, the server/ directory is created with the compiled binary.
Building
Requires Rust 1.85+.
cd examples/calculator-rust
cargo build --release
mkdir -p server
cp target/release/mcp-calculator server/
Packing
mcpb pack examples/calculator-rust
The .mcpbignore file excludes source code and build artifacts — only manifest.json and server/mcp-calculator end up in the bundle.
Testing
# MCP protocol handshake
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' \
| ./server/mcp-calculator
# Tool call
(printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}\n'
printf '{"jsonrpc":"2.0","method":"notifications/initialized"}\n'
printf '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"sum","arguments":{"a":3,"b":4}}}\n'
sleep 1) | ./server/mcp-calculator
Expected: sum(3, 4) returns {"text":"7"}.
Tools
- sum — Calculate the sum of two numbers
- sub — Calculate the difference of two numbers
Notes
- Binary size: ~2.5 MB (stripped, LTO enabled)
- The
Cargo.tomlusesedition = "2024"(Rust 1.85+) - Logs are written to stderr via
tracing, so they don't interfere with MCP's stdio transport - Uses the rmcp crate (official Rust MCP SDK)
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.