Back to MCP Catalog

Rust Template MCP Server

Developer ToolsRust
A template for building Model Context Protocol servers in Rust

The Rust MCP Template provides a foundation for developers to build Model Context Protocol (MCP) servers using Rust. This template simplifies the implementation of MCP servers by providing a structured framework with handlers for prompts, resources, and tools. Built on the rust-rpc-router library, it offers a clean approach to creating JSON-RPC based MCP servers that can seamlessly integrate with LLM applications.

Overview

The Rust MCP Template is designed to help developers quickly implement Model Context Protocol (MCP) servers in Rust. MCP is an open protocol that enables seamless integration between LLM applications and external data sources and tools, making it easier to build AI-powered applications with access to the context they need.

Installation

To use this template for your own MCP server:

  1. Clone the repository:

    git clone https://github.com/linux-china/mcp-rs-template.git
    cd mcp-rs-template
    
  2. Modify the project information in Cargo.toml and src/mcp/mod.rs to match your project details.

  3. Customize the server handlers:

    • src/mcp/prompts.rs: Implement your prompts handlers
    • src/mcp/resources.rs: Implement your resources handlers
    • src/mcp/tools.rs: Implement your tools handlers
  4. If you prefer using JSON files for configuration, modify the templates in src/mcp/templates/*.json.

Running the Server

The template includes several CLI options:

  • --mcp: Enable the MCP server
  • --resources: Display available resources
  • --prompts: Display available prompts
  • --tools: Display available tools

To run the server:

cargo run -- --mcp

Integration with Claude Desktop

To use your MCP server with Claude Desktop:

  1. Open Claude Desktop and navigate to Settings → Developer → Edit Config
  2. Add your server configuration to the mcpServers section:
{
   "mcpServers": {
      "your-server-name": {
         "command": "mcp-rs-template",
         "args": [
            "--mcp"
         ],
         "env": {
            "API_KEY": "your-api-key-if-needed"
         }
      }
   }
}
  1. Save the configuration and restart Claude Desktop if necessary.

You can monitor the MCP logs with:

tail -n 20 -f ~/Library/Logs/Claude/mcp*.log

Development

This template is based on rust-rpc-router, a JSON-RPC routing library for Rust. The structure follows the MCP specification, making it easy to extend with your own functionality.

For more information about MCP, refer to the official specification and the introduction to Model Context Protocol.

Related MCPs

Apple Shortcuts
Developer ToolsJavaScript

Control Apple Shortcuts automations from AI assistants

Clojars Dependency Lookup
Developer ToolsJavaScript

Fetch dependency information from Clojars, the Clojure community's artifact repository

Simple Timeserver
Developer ToolsPython

Provides Claude with current time and timezone information

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.