Rust-Mcp-Server-Generator
Rust-Mcp-Server-Generator是一款code方向的AI技能,核心价值是Generate a complete Rust Model Context Protocol server project with tools, prompts, resources, and tests using the official rmcp SDK,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。
Generate a complete Rust Model Context Protocol server project with tools, prompts, resources, and tests using the official rmcp SDK
mkdir -p ./skills/rust-mcp-server-generator && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/rust-mcp-server-generator/SKILL.md -o ./skills/rust-mcp-server-generator/SKILL.md Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).
Skill Content
# 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:
1. **Project name** (e.g., "my-mcp-server")
2. **Server description** (e.g., "A weather data MCP server")
3. **Transport type** (stdio, sse, http, or all)
4. **Tools to include** (e.g., "weather lookup", "forecast", "alerts")
5. **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.rsFile 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_StoreREADME.md
# {Project Name}
{Server description}
## Installation
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
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🎯 Best For
- QA engineers
- Developers writing unit tests
- Developers scaffolding new projects
- Prototype builders
- Claude users
💡 Use Cases
- Generating test cases for edge conditions
- Writing integration test suites
- Bootstrapping React components
- Creating API route handlers
📖 How to Use This Skill
- 1
Install the Skill
Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.
- 2
Load into Your AI Assistant
Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.
- 3
Apply Rust-Mcp-Server-Generator to Your Work
Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.
- 4
Review and Refine
Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.
❓ Frequently Asked Questions
Does this generate test mocks?
Many testing skills include mock generation. Check the install command and skill content for details.
Can I customize the generated output?
Yes — modify the skill's prompt instructions to match your project conventions and coding style.
Is Rust-Mcp-Server-Generator compatible with Cursor and VS Code?
Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.
Do I need specific dependencies for Rust-Mcp-Server-Generator?
Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.
How do I install Rust-Mcp-Server-Generator?
Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/rust-mcp-server-generator/SKILL.md, ready to use.
⚠️ Common Mistakes to Avoid
Not testing edge cases
AI tends to generate happy-path tests. Manually review for boundary conditions.
Using generated code without understanding
Understand what generated code does before shipping it to production.
Skipping validation
Always test AI-generated code changes, even for simple refactors.
Missing dependency updates
Check if the skill requires updated dependencies or new packages.