Get the FREE Ultimate OpenClaw Setup Guide →

mcp-rs-template

Model Context Protocol (MCP) CLI server template for Rust

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio linux-china-mcp-rs-template mcp-rs-template --mcp \
  --env API_KEY="xxxx"

How to use

mcp-rs-template is a Rust-based MCP CLI server template that demonstrates implementing an MCP server with Rust and the rust-rpc-router library. It exposes MCP-compatible endpoints and supports command-line flags to enable MCP, display resources, prompts, and tools. To integrate with clients like Claude Desktop, you configure a server entry in your client’s MCP settings and point it at the mcp-rs-template executable with the --mcp flag. This lets the client query prompts, resources, and tools through a standardized JSON-RPC interface. You can customize the server by editing the Rust source under src/mcp/, including prompts, resources, and tools handlers, and you can optionally switch to JSON files by editing src/mcp/templates/*.json if you prefer data-driven configuration.

In Claude Desktop, you would add a server configuration with the command set to mcp-rs-template and pass --mcp as an argument, optionally supplying environment variables like API_KEY if required. The logs can be monitored via the standard OS log path (as referenced in the template’s guidance) to verify activity and diagnose issues.

How to install

Prerequisites:

  • Rust toolchain (rustup, cargo)
  • Basic knowledge of building Rust projects

Step-by-step:

  1. Install Rust: visit https://rust-lang.org and follow installation instructions for your OS.
  2. Clone the repository: git clone <repository-url> cd mcp-rs-template
  3. Build the server: cargo build --release

    The compiled binary will be at target/release/mcp-rs-template

  4. Run the MCP server locally: ./target/release/mcp-rs-template --mcp
  5. Verify the server is listening on the expected port or socket according to your environment.
  6. (Optional) Integrate with Claude Desktop by adding a server configuration that points to the built executable with the --mcp flag, as shown in the README example.

Notes:

  • If you modify code, run cargo build --release again to regenerate the binary.
  • Ensure any required environment variables (e.g., API_KEY) are provided when starting the server if your configuration uses them.

Additional notes

Tips and considerations:

  • The server uses rust-rpc-router for JSON-RPC routing; you can modify prompts.rs, resources.rs, and tools.rs to customize behavior.
  • If you enable CLI display options (--resources, --prompts, --tools), the server will expose those endpoints for discovery.
  • For debugging in Claude Desktop, enable logging and tail logs as indicated in the template (e.g., tail -n 20 -f ~/Library/Logs/Claude/mcp*.log) to monitor MCP activity.
  • If integrating with external services, securely manage API keys and secrets via environment variables rather than hard-coding them.
  • When upgrading dependencies, re-run cargo build to ensure compatibility with the rust-rpc-router library.

Related MCP Servers

Sponsor this space

Reach thousands of developers