Starter template for building an MCP service with crabtalk-command.
This example exposes a single time tool that returns the current UTC time.
src/
bin/main.rs CLI entry point (clap App)
lib.rs Module declarations
mcp.rs MCP server (rmcp #[tool] methods)
cmd.rs Service definition (#[command] + McpService impl)
#[command(kind = "mcp")] generates service management subcommands
(start, stop, run, logs) and a TimeCommand::start() entry point.
McpService requires a single method — fn router(&self) -> axum::Router —
which wires the rmcp StreamableHttpService into an axum router.
# Run directly
cargo run -- time run
# Install as a launchd/systemd service
cargo run -- time start
# View logs
cargo run -- time logs
# Stop
cargo run -- time stopThe MCP endpoint is available at http://127.0.0.1:<port>/mcp (port written
to ~/.crabtalk/run/time.port).
Add methods to the #[tool_router] impl TimeServer block in src/mcp.rs:
#[tool(description = "Add two numbers")]
async fn add(&self, Parameters(p): Parameters<AddParams>) -> String {
(p.a + p.b).to_string()
}Define param structs with #[derive(Deserialize, JsonSchema)].
- Clone this repo
- Rename the package in
Cargo.toml - Replace
TimeServerwith your own server implementation - Update the
#[command]name andMcpService::router()