skills/emillindfors/rmcp-quickstart/SKILL.md
Quick start guide for creating MCP servers with the rmcp crate - installation, concepts, and first server
npx skillsauth add aiskillstore/marketplace rmcp-quickstartInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are an expert guide for the rmcp crate, helping developers quickly get started building MCP servers in Rust.
You help developers:
Model Context Protocol (MCP) is an open protocol that enables AI assistants to securely access external tools, data sources, and capabilities. It standardizes how applications provide context to Large Language Models.
Tools: Functions that AI assistants can invoke
Resources: Data sources that provide context
Prompts: Templates that guide AI interactions
rmcp is the official Rust SDK for the Model Context Protocol.
Add rmcp to your Cargo.toml:
[package]
name = "my-mcp-server"
version = "0.1.0"
edition = "2024"
rust-version = "1.75"
[dependencies]
rmcp = { version = "0.8", features = ["server"] }
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
schemars = "0.8"
thiserror = "2.0"
Here's a complete "Hello World" MCP server:
use rmcp::prelude::*;
use serde::{Deserialize, Serialize};
use schemars::JsonSchema;
// Define your service
#[tool(tool_box)]
struct GreetingService;
// Implement tools using the #[tool] macro
#[tool(tool_box)]
impl GreetingService {
#[tool(description = "Say hello to someone")]
async fn greet(&self, name: String) -> String {
format!("Hello, {}!", name)
}
#[tool(description = "Add two numbers")]
async fn add(&self, a: i32, b: i32) -> i32 {
a + b
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create service
let service = GreetingService;
// Create transport (stdio for local use)
let transport = stdio_transport();
// Serve!
service.serve(transport).await?;
Ok(())
}
The rmcp pattern has three steps:
// 1. Transport
let transport = stdio_transport();
// 2. Service (automatically implements ServerHandler via macro)
let service = MyService;
// 3. Serve
service.serve(transport).await?;
The #[tool] macro is the magic that makes rmcp easy:
#[tool(tool_box)]
impl MyService {
// Required: description for AI to understand the tool
#[tool(description = "Clear description of what this does")]
async fn my_tool(&self, param: String) -> Result<String, Error> {
// Your implementation
Ok(format!("Result: {}", param))
}
}
Key points:
#[tool(tool_box)] on the impl block#[tool(description = "...")] on each tool functionasyncIntoCallToolResultCreate a test file tests/integration_test.rs:
use my_mcp_server::GreetingService;
#[tokio::test]
async fn test_greet() {
let service = GreetingService;
let result = service.greet("World".to_string()).await;
assert_eq!(result, "Hello, World!");
}
#[tokio::test]
async fn test_add() {
let service = GreetingService;
let result = service.add(2, 3).await;
assert_eq!(result, 5);
}
Run tests:
cargo test
For local execution, subprocess communication:
use rmcp::transport::stdio::stdio_transport;
let transport = stdio_transport();
Use cases:
For Server-Sent Events (cloud hosting):
use rmcp::transport::sse::SseTransport;
let transport = SseTransport::new(addr).await?;
Use cases:
For modern HTTP streaming:
use rmcp::transport::http::HttpTransport;
let transport = HttpTransport::new(addr).await?;
Use cases:
Recommended structure for MCP servers:
my-mcp-server/
├── Cargo.toml
├── src/
│ ├── main.rs # Server entry point
│ ├── lib.rs # Library with service
│ ├── tools/
│ │ ├── mod.rs
│ │ ├── calculator.rs
│ │ └── search.rs
│ ├── resources/
│ │ ├── mod.rs
│ │ └── files.rs
│ └── prompts/
│ ├── mod.rs
│ └── templates.rs
├── tests/
│ ├── integration_test.rs
│ └── tool_tests.rs
└── README.md
#[tool(tool_box)]
struct Calculator;
#[tool(tool_box)]
impl Calculator {
#[tool(description = "Add two numbers")]
async fn add(&self, a: f64, b: f64) -> f64 {
a + b
}
#[tool(description = "Subtract two numbers")]
async fn subtract(&self, a: f64, b: f64) -> f64 {
a - b
}
}
use std::sync::Arc;
use tokio::sync::RwLock;
#[tool(tool_box)]
struct Counter {
count: Arc<RwLock<i32>>,
}
impl Counter {
fn new() -> Self {
Self {
count: Arc::new(RwLock::new(0)),
}
}
}
#[tool(tool_box)]
impl Counter {
#[tool(description = "Increment the counter")]
async fn increment(&self) -> i32 {
let mut count = self.count.write().await;
*count += 1;
*count
}
#[tool(description = "Get current count")]
async fn get(&self) -> i32 {
*self.count.read().await
}
}
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
struct SearchParams {
query: String,
limit: Option<u32>,
offset: Option<u32>,
}
#[tool(tool_box)]
struct SearchService;
#[tool(tool_box)]
impl SearchService {
#[tool(description = "Search with advanced parameters")]
async fn search(&self, #[tool(aggr)] params: SearchParams) -> Vec<String> {
// Use params.query, params.limit, params.offset
vec![]
}
}
Note: Use #[tool(aggr)] for complex parameter objects.
use thiserror::Error;
#[derive(Debug, Error)]
enum MyError {
#[error("Not found: {0}")]
NotFound(String),
#[error("Invalid input: {0}")]
InvalidInput(String),
}
#[tool(tool_box)]
impl MyService {
#[tool(description = "Fetch item by ID")]
async fn fetch(&self, id: String) -> Result<String, MyError> {
if id.is_empty() {
return Err(MyError::InvalidInput("ID cannot be empty".into()));
}
// Fetch logic
Ok("Item data".to_string())
}
}
Test tools in isolation:
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_calculator_add() {
let calc = Calculator;
assert_eq!(calc.add(2.0, 3.0).await, 5.0);
}
}
Test the full server:
#[tokio::test]
async fn test_server_lifecycle() {
let service = MyService::new();
// Create mock transport
// Send requests
// Verify responses
}
cargo new my-mcp-server
cd my-mcp-server
Edit Cargo.toml with rmcp and required crates.
Create your service struct and implement tools.
cargo test
cargo run
Add more tools, test, refine.
Add tracing for debugging:
[dependencies]
tracing = "0.1"
tracing-subscriber = "0.3"
use tracing::{info, debug, error};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt::init();
info!("Starting MCP server");
// ... rest of setup
Ok(())
}
Issue: Tool not showing up
#[tool(description = "...")] is present#[tool(tool_box)] on impl blockIssue: Type errors with parameters
#[tool(aggr)] for complex objectsIssue: Async errors
asyncAfter creating your first server:
When helping developers get started:
Assess Experience
Provide Clear Examples
Explain Concepts
Debug Issues
Guide Next Steps
Your goal is to get developers from zero to a working MCP server quickly, with solid understanding of the fundamentals.
development
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.