A forkable starting point for Model Context Protocol
servers in Rust. Single binary, two transports (stdio + streamable-HTTP),
one example tool, real tests, real CI. Built on the
rmcp SDK.
# stdio (default — suitable for Claude Desktop / Claude Code / any local MCP client)
cargo run
# streamable-HTTP, loopback:8080
cargo run -- --transport httpClick Use this template on GitHub to create a new repo from this scaffold, or run:
gh repo create my-mcp-server --template shoehn/rust-mcp-server-template --publicAfter creating your repo:
- Rename the crate in
Cargo.toml([package].name,repository). - Rename
McpServerHandlerinsrc/server/handler.rs(and its re-exports insrc/server/mod.rsandsrc/lib.rs) to match your server's domain. - Sweep crate-name references in source:
grep -rn rust_mcp_server_template src testswill surfacesrc/main.rs,tests/ping_tool.rs, and the binary-name strings insrc/config.rstests. Update each to your new crate name (with hyphens for the package name, underscores for the module identifier). - Update this README.
- Replace the
pingexample tool insrc/tools/with your real tools.
- Create
src/tools/<name>.rswithArgs+Outputtypes derivingDeserialize+JsonSchema/Serialize+JsonSchema. - Add a
pub mod <name>;line insrc/tools/mod.rs. - Add a
#[tool(name = "...", description = "...")]method on your handler struct insrc/server/handler.rsthat delegates to the pure handler in your new file.
The #[tool_router] macro picks it up automatically — no other wiring.
| Flag | Env var | Default |
|---|---|---|
--transport stdio|http |
MCP_TRANSPORT |
stdio |
--bind <addr> |
MCP_BIND |
127.0.0.1:8080 |
--log-format pretty|json |
MCP_LOG_FORMAT |
pretty |
just test # cargo test --all-targets
just lint # cargo clippy --all-targets -- -D warnings
just fmt # cargo fmt --all
just ci # fmt --check + clippy + test