rust-mcp-server-generator
github/awesome-copilot
Generate production-ready Rust MCP servers with tools, prompts, resources, and tests using the official rmcp SDK.
What is rust-mcp-server-generator?
A code generator that scaffolds complete Rust Model Context Protocol server projects. Use this when you need to create a new MCP server with custom tools, prompts, resources, and integrated tests following best practices.
- Generates complete project structure with Cargo.toml, source files, and tests
- Creates tool, prompt, and resource handler implementations with async support
- Supports multiple transport types (stdio, SSE, HTTP) with feature flags
- Includes tracing/logging setup and error handling patterns
- Provides integration test templates and development configuration
- Generates README with installation and usage instructions
How to install rust-mcp-server-generator
npx skills add https://github.com/github/awesome-copilot --skill rust-mcp-server-generator- Rust toolchain (1.70+) and Cargo installed
- Basic familiarity with async Rust and tokio
- Understanding of MCP protocol concepts (tools, prompts, resources)
How to use rust-mcp-server-generator
- 1.Run the generator and provide project name, description, and transport type preference
- 2.Specify which tools to include (e.g., 'weather lookup', 'forecast')
- 3.Indicate whether to include prompts and resources in the server
- 4.Review generated project structure and customize tool implementations in src/tools/
- 5.Update Cargo.toml dependencies if adding external integrations
- 6.Run `cargo build --release` to compile the server
- 7.Configure the server in your MCP client (e.g., Claude Desktop config)
- 8.Run `cargo test` to verify integration tests pass
Use cases
- Creating a custom MCP server for domain-specific tools (weather, database, API integration)
- Building an MCP server that exposes internal services to Claude or other AI clients
- Generating a starter project with multiple tools and prompts for rapid development
- Setting up an HTTP-based MCP server with proper async/await patterns
- Scaffolding a production-ready server with logging and test infrastructure
- Rust developers building MCP servers
- Teams integrating AI agents with custom backend services
- Developers creating specialized tools for Claude Desktop or other MCP clients
- Backend engineers exposing APIs through the MCP protocol
rust-mcp-server-generator FAQ
Stdio (default), SSE, HTTP, and combinations thereof. HTTP transport requires the 'http' feature flag in Cargo.toml.
Create a new file in src/tools/{tool_name}.rs, implement the tool logic, add it to src/tools/mod.rs, and register it in src/handler.rs using the #[tool] macro.
Yes. The generated structure supports adding dependencies like reqwest or other HTTP clients. Add them to Cargo.toml and use them in your tool implementations.
The generator uses rmcp 0.8.1 with the server feature. Check the generated Cargo.toml to update versions as needed.
Run with `RUST_LOG=debug cargo run` to see debug-level logs. The server uses the tracing crate, configured in main.rs.
Full instructions (SKILL.md)
Source of truth, from github/awesome-copilot.
name: rust-mcp-server-generator description: 'Generate a complete Rust Model Context Protocol server project with tools, prompts, resources, and tests using the official rmcp SDK'
Rust MCP Server Generator
You are a Rust MCP server generator. Create a complete, production-ready Rust MCP server project using the official rmcp SDK.
Project Requirements
Ask the user for:
- Project name (e.g., "my-mcp-server")
- Server description (e.g., "A weather data MCP server")
- Transport type (stdio, sse, http, or all)
- Tools to include (e.g., "weather lookup", "forecast", "alerts")
- Whether to include prompts and resources
Project Structure
Generate this structure:
{project-name}/
├── Cargo.toml
├── .gitignore
├── README.md
├── src/
│ ├── main.rs
│ ├── handler.rs
│ ├── tools/
│ │ ├── mod.rs
│ │ └── {tool_name}.rs
│ ├── prompts/
│ │ ├── mod.rs
│ │ └── {prompt_name}.rs
│ ├── resources/
│ │ ├── mod.rs
│ │ └── {resource_name}.rs
│ └── state.rs
└── tests/
└── integration_test.rs
File Templates
Cargo.toml
[package]
name = "{project-name}"
version = "0.1.0"
edition = "2021"
[dependencies]
rmcp = { version = "0.8.1", features = ["server"] }
rmcp-macros = "0.8"
tokio = { version = "1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
anyhow = "1.0"
tracing = "0.1"
tracing-subscriber = "0.3"
schemars = { version = "0.8", features = ["derive"] }
async-trait = "0.1"
# Optional: for HTTP transports
axum = { version = "0.7", optional = true }
tower-http = { version = "0.5", features = ["cors"], optional = true }
[dev-dependencies]
tokio-test = "0.4"
[features]
default = []
http = ["dep:axum", "dep:tower-http"]
[[bin]]
name = "{project-name}"
path = "src/main.rs"
.gitignore
/target
Cargo.lock
*.swp
*.swo
*~
.DS_Store
README.md
# {Project Name}
{Server description}
## Installation
```bash
cargo build --release
Usage
Stdio Transport
cargo run
SSE Transport
cargo run --features http -- --transport sse
HTTP Transport
cargo run --features http -- --transport http
Configuration
Configure in your MCP client (e.g., Claude Desktop):
{
"mcpServers": {
"{project-name}": {
"command": "path/to/target/release/{project-name}",
"args": []
}
}
}
Tools
- {tool_name}: {Tool description}
Development
Run tests:
cargo test
Run with logging:
RUST_LOG=debug cargo run
### src/main.rs
```rust
use anyhow::Result;
use rmcp::{
protocol::ServerCapabilities,
server::Server,
transport::StdioTransport,
};
use tokio::signal;
use tracing_subscriber;
mod handler;
mod state;
mod tools;
mod prompts;
mod resources;
use handler::McpHandler;
#[tokio::main]
async fn main() -> Result<()> {
// Initialize tracing
tracing_subscriber::fmt()
.with_max_level(tracing::Level::INFO)
.with_target(false)
.init();
tracing::info!("Starting {project-name} MCP server");
// Create handler
let handler = McpHandler::new();
// Create transport (stdio by default)
let transport = StdioTransport::new();
// Build server with capabilities
let server = Server::builder()
.with_handler(handler)
.with_capabilities(ServerCapabilities {
tools: Some(Default::default()),
prompts: Some(Default::default()),
resources: Some(Default::default()),
..Default::default()
})
.build(transport)?;
tracing::info!("Server started, waiting for requests");
// Run server until Ctrl+C
server.run(signal::ctrl_c()).await?;
tracing::info!("Server shutting down");
Ok(())
}
src/handler.rs
use rmcp::{
model::*,
protocol::*,
server::{RequestContext, ServerHandler, RoleServer, ToolRouter},
ErrorData,
};
use rmcp::{tool_router, tool_handler};
use async_trait::async_trait;
use crate::state::ServerState;
use crate::tools;
pub struct McpHandler {
state: ServerState,
tool_router: ToolRouter,
}
#[tool_router]
impl McpHandler {
// Include tool definitions from tools module
#[tool(
name = "example_tool",
description = "An example tool",
annotations(read_only_hint = true)
)]
async fn example_tool(params: Parameters<tools::ExampleParams>) -> Result<String, String> {
tools::example::execute(params).await
}
pub fn new() -> Self {
Self {
state: ServerState::new(),
tool_router: Self::tool_router(),
}
}
}
#[tool_handler]
#[async_trait]
impl ServerHandler for McpHandler {
async fn list_prompts(
&self,
_request: Option<PaginatedRequestParam>,
_context: RequestContext<RoleServer>,
) -> Result<ListPromptsResult, ErrorData> {
let prompts = vec![
Prompt {
name: "example-prompt".to_string(),
description: Some("An example prompt".to_string()),
arguments: Some(vec![
PromptArgument {
name: "topic".to_string(),
description: Some("The topic to discuss".to_string()),
required: Some(true),
},
]),
},
];
Ok(ListPromptsResult { prompts })
}
async fn get_prompt(
&self,
request: GetPromptRequestParam,
_context: RequestContext<RoleServer>,
) -> Result<GetPromptResult, ErrorData> {
match request.name.as_str() {
"example-prompt" => {
let topic = request.arguments
.as_ref()
.and_then(|args| args.get("topic"))
.ok_or_else(|| ErrorData::invalid_params("topic required"))?;
Ok(GetPromptResult {
description: Some("Example prompt".to_string()),
messages: vec![
PromptMessage::user(format!("Let's discuss: {}", topic)),
],
})
}
_ => Err(ErrorData::invalid_params("Unknown prompt")),
}
}
async fn list_resources(
&self,
_request: Option<PaginatedRequestParam>,
_context: RequestContext<RoleServer>,
) -> Result<ListResourcesResult, ErrorData> {
let resources = vec![
Resource {
uri: "example://data/info".to_string(),
name: "Example Resource".to_string(),
description: Some("An example resource".to_string()),
mime_type: Some("text/plain".to_string()),
},
];
Ok(ListResourcesResult { resources })
}
async fn read_resource(
&self,
request: ReadResourceRequestParam,
_context: RequestContext<RoleServer>,
) -> Result<ReadResourceResult, ErrorData> {
match request.uri.as_str() {
"example://data/info" => {
Ok(ReadResourceResult {
contents: vec![
ResourceContents::text("Example resource content".to_string())
.with_uri(request.uri)
.with_mime_type("text/plain"),
],
})
}
_ => Err(ErrorData::invalid_params("Unknown resource")),
}
}
}
src/state.rs
use std::sync::Arc;
use tokio::sync::RwLock;
#[derive(Clone)]
pub struct ServerState {
// Add shared state here
counter: Arc<RwLock<i32>>,
}
impl ServerState {
pub fn new() -> Self {
Self {
counter: Arc::new(RwLock::new(0)),
}
}
pub async fn increment(&self) -> i32 {
let mut counter = self.counter.write().await;
*counter += 1;
*counter
}
pub async fn get(&self) -> i32 {
*self.counter.read().await
}
}
src/tools/mod.rs
pub mod example;
pub use example::ExampleParams;
src/tools/example.rs
use rmcp::model::Parameters;
use serde::{Deserialize, Serialize};
use schemars::JsonSchema;
#[derive(Debug, Deserialize, JsonSchema)]
pub struct ExampleParams {
pub input: String,
}
pub async fn execute(params: Parameters<ExampleParams>) -> Result<String, String> {
let input = ¶ms.inner().input;
// Tool logic here
Ok(format!("Processed: {}", input))
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_example_tool() {
let params = Parameters::new(ExampleParams {
input: "test".to_string(),
});
let result = execute(params).await.unwrap();
assert!(result.contains("test"));
}
}
src/prompts/mod.rs
// Prompt implementations can go here if needed
src/resources/mod.rs
// Resource implementations can go here if needed
tests/integration_test.rs
use rmcp::{
model::*,
protocol::*,
server::{RequestContext, ServerHandler, RoleServer},
};
// Replace with your actual project name in snake_case
// Example: if project is "my-mcp-server", use my_mcp_server
use my_mcp_server::handler::McpHandler;
#[tokio::test]
async fn test_list_tools() {
let handler = McpHandler::new();
let context = RequestContext::default();
let result = handler.list_tools(None, context).await.unwrap();
assert!(!result.tools.is_empty());
assert!(result.tools.iter().any(|t| t.name == "example_tool"));
}
#[tokio::test]
async fn test_call_tool() {
let handler = McpHandler::new();
let context = RequestContext::default();
let request = CallToolRequestParam {
name: "example_tool".to_string(),
arguments: Some(serde_json::json!({
"input": "test"
})),
};
let result = handler.call_tool(request, context).await;
assert!(result.is_ok());
}
#[tokio::test]
async fn test_list_prompts() {
let handler = McpHandler::new();
let context = RequestContext::default();
let result = handler.list_prompts(None, context).await.unwrap();
assert!(!result.prompts.is_empty());
}
#[tokio::test]
async fn test_list_resources() {
let handler = McpHandler::new();
let context = RequestContext::default();
let result = handler.list_resources(None, context).await.unwrap();
assert!(!result.resources.is_empty());
}
Implementation Guidelines
- Use rmcp-macros: Leverage
#[tool],#[tool_router], and#[tool_handler]macros for cleaner code - Type Safety: Use
schemars::JsonSchemafor all parameter types - Error Handling: Return
Resulttypes with proper error messages - Async/Await: All handlers must be async
- State Management: Use
Arc<RwLock<T>>for shared state - Testing: Include unit tests for tools and integration tests for handlers
- Logging: Use
tracingmacros (info!,debug!,warn!,error!) - Documentation: Add doc comments to all public items
Example Tool Patterns
Simple Read-Only Tool
#[derive(Debug, Deserialize, JsonSchema)]
pub struct GreetParams {
pub name: String,
}
#[tool(
name = "greet",
description = "Greets a user by name",
annotations(read_only_hint = true, idempotent_hint = true)
)]
async fn greet(params: Parameters<GreetParams>) -> String {
format!("Hello, {}!", params.inner().name)
}
Tool with Error Handling
#[derive(Debug, Deserialize, JsonSchema)]
pub struct DivideParams {
pub a: f64,
pub b: f64,
}
#[tool(name = "divide", description = "Divides two numbers")]
async fn divide(params: Parameters<DivideParams>) -> Result<f64, String> {
let p = params.inner();
if p.b == 0.0 {
Err("Cannot divide by zero".to_string())
} else {
Ok(p.a / p.b)
}
}
Tool with State
#[tool(
name = "increment",
description = "Increments the counter",
annotations(destructive_hint = true)
)]
async fn increment(state: &ServerState) -> i32 {
state.increment().await
}
Running the Generated Server
After generation:
cd {project-name}
cargo build
cargo test
cargo run
For Claude Desktop integration:
{
"mcpServers": {
"{project-name}": {
"command": "path/to/{project-name}/target/release/{project-name}",
"args": []
}
}
}
Now generate the complete project based on the user's requirements!
Related skills
More from github/awesome-copilot and the wider catalog.

salesforce-apex-quality
Apex code quality guardrails for Salesforce development. Enforces bulk-safety rules (no SOQL/DML in loops), sharing model requirements, CRUD/FLS security, SOQL injection prevention, PNB test coverage (Positive / Negative / Bulk), and modern Apex idioms. Use this skill when reviewing or generating Apex classes, trigger handlers, batch jobs, or test classes to catch governor limit risks, security gaps, and quality issues before deployment.

salesforce-component-standards
Quality standards for Salesforce Lightning Web Components (LWC), Aura components, and Visualforce pages. Covers SLDS 2 compliance, accessibility (WCAG 2.1 AA), data access pattern selection, component communication rules, XSS prevention, CSRF enforcement, FLS/CRUD in AuraEnabled methods, view state management, and Jest test requirements. Use this skill when building or reviewing any Salesforce UI component to enforce platform-specific security and quality standards.

salesforce-flow-design
Salesforce Flow architecture decisions, flow type selection, bulk safety validation, and fault handling standards. Use this skill when designing or reviewing Record-Triggered, Screen, Autolaunched, Scheduled, or Platform Event flows to ensure correct type selection, no DML/Get Records in loops, proper fault connectors on all data-changing elements, and appropriate automation density checks before deployment.

sandbox-npm-install
Install npm packages in Docker sandbox via ext4 symlink to avoid native binary crashes on virtiofs.

scaffolding-oracle-to-postgres-migration-test-project
Scaffold xUnit integration test infrastructure for Oracle-to-PostgreSQL migration projects in .NET.

scoutqa-test
AI-powered exploratory testing for web applications with autonomous bug discovery and accessibility audits