home / mcp / mcp rust cli server template

MCP Rust CLI Server Template

Provides an MCP server interface for prompts, resources, and tools via a Rust CLI server.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "linux-china-mcp-rs-template": {
      "command": "mcp-rs-template",
      "args": [
        "--mcp"
      ],
      "env": {
        "API_KEY": "xxxx"
      }
    }
  }
}

Model Context Protocol (MCP) enables you to connect large language model applications to external data sources and actions via a standardized interface. This Rust CLI server template demonstrates how to implement an MCP server locally, allowing you to expose prompts, resources, and tools to your MCP-enabled clients.

How to use

You run the local MCP server and connect your MCP client to it. Start the server with MCP mode enabled, then use your client to query prompts, access resources, and invoke tools exposed by the server. The template is designed to be extended by implementing the prompts, resources, and tools handlers so you can tailor MCP interactions to your domain.

How to install

Prerequisites you need on your machine include Rust and Cargo, so you can build and run the MCP server locally.

1. Clone the project directory containing the MCP Rust CLI server template.

2. Install Rust toolchain if you don’t have it yet (Rustup is recommended). You can install Rust from the official source and then ensure cargo is available on your PATH.

3. Build the project to produce the runnable binary.

4. Run the server in MCP mode to expose the MCP endpoints for prompts, resources, and tools.

Additional sections

Configuration and usage notes come from the MCP server template code and its example setup. You can enable MCP mode, list resources, prompts, and tools, and wire in your own handlers for prompts, resources, and tools by editing the source files indicated in the project. The template relies on rust-rpc-router for JSON-RPC routing, and you can customize the behavior by implementing the dedicated handler modules.

MCP CLI options include enabling MCP mode and displaying resources, prompts, or tools independently. Use these options to verify what the server exposes and to help you troubleshoot during development.