rmcp-quickstart
Quick start guide for creating MCP servers with the rmcp crate - installation, concepts, and first server
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o rmcp-quickstart.zip https://jpskill.com/download/19027.zip && unzip -o rmcp-quickstart.zip && rm rmcp-quickstart.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/19027.zip -OutFile "$d\rmcp-quickstart.zip"; Expand-Archive "$d\rmcp-quickstart.zip" -DestinationPath $d -Force; ri "$d\rmcp-quickstart.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
rmcp-quickstart.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
rmcp-quickstartフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[スキル名] rmcp-quickstart あなたは rmcp クレートのエキスパートガイドとして、開発者が Rust で MCP サーバーを迅速に構築し始めるのを支援します。
あなたの専門知識
あなたは開発者を支援します:
- MCP (Model Context Protocol) の基本を理解する
- rmcp クレートをインストールして設定する
- 最初の MCP サーバーを作成する
- MCP サーバーをローカルでテストおよび検証する
- rmcp のアーキテクチャを理解する
MCP とは?
Model Context Protocol (MCP) は、AI アシスタントが外部ツール、データソース、および機能に安全にアクセスできるようにするオープンプロトコルです。これは、アプリケーションが大規模言語モデルにコンテキストを提供する方法を標準化します。
MCP の核となる概念
-
ツール: AI アシスタントが呼び出すことができる関数
- 検索、計算、操作の実行
- 構造化されたパラメータを受け取る
- 型付きの結果を返す
-
リソース: コンテキストを提供するデータソース
- ファイル、データベース、API
- URI ベースのアドレス指定
- リストおよびフェッチ操作
-
プロンプト: AI との対話をガイドするテンプレート
- 事前定義された会話の開始
- 動的な引数注入
- コンテキストに応じた提案
rmcp クレートの概要
rmcp は、Model Context Protocol の公式 Rust SDK です。
主な機能
- クリーンな API: 強力なマクロによる最小限のボイラープレート
- Async-first: 高性能のために tokio 上に構築
- 型安全: Rust の型システムを活用
- 複数のトランスポート: stdio、SSE、HTTP ストリーミング
- 本番環境対応: 実世界のアプリケーションで使用されています
現在のバージョン
- バージョン: 0.8.3 (2025年11月現在)
- リポジトリ: https://github.com/modelcontextprotocol/rust-sdk
- 代替: https://github.com/4t145/rmcp (最高の Rust SDK)
クイックスタートガイド
ステップ 1: インストール
Cargo.toml に rmcp を追加します:
[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"
ステップ 2: 最初のサーバーを作成する
以下は、完全な「Hello World」MCP サーバーです:
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(())
}
ステップ 3: パターンを理解する
rmcp パターンには3つのステップがあります:
- トランスポートを構築する - 通信レイヤー
- サービスを構築する - ServerHandler トレイトを実装する
- 一緒に提供する - 接続して実行する
// 1. Transport
let transport = stdio_transport();
// 2. Service (automatically implements ServerHandler via macro)
let service = MyService;
// 3. Serve
service.serve(transport).await?;
ステップ 4: #[tool] マクロ
#[tool] マクロは、rmcp を簡単にする魔法です:
#[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))
}
}
重要な点:
- impl ブロックに
#[tool(tool_box)] - 各ツール関数に
#[tool(description = "...")] - 関数は
asyncである必要があります - 戻り値の型は
IntoCallToolResultを実装している必要があります
ステップ 5: サーバーをテストする
テストファイル 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);
}
テストを実行します:
cargo test
トランスポートの種類
stdio トランスポート (ローカル)
ローカル実行、サブプロセス通信用:
use rmcp::transport::stdio::stdio_transport;
let transport = stdio_transport();
ユースケース:
- ローカル開発
- パーソナルツール
- 迅速なプロトタイピング
- デスクトップ統合
SSE トランスポート (クラウド)
Server-Sent Events (クラウドホスティング) 用:
use rmcp::transport::sse::SseTransport;
let transport = SseTransport::new(addr).await?;
ユースケース:
- クラウドデプロイメント
- リモートアクセス
- ウェブサービス
- マルチユーザーサーバー
HTTP ストリーマブルトランスポート
最新の HTTP ストリーミング用:
use rmcp::transport::http::HttpTransport;
let transport = HttpTransport::new(addr).await?;
ユースケース:
- REST ライクなインターフェース
- ロードバランサー
- API ゲートウェイ
- 最新のウェブアプリ
プロジェクト構造
MCP サーバーの推奨構造:
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
一般的なパターン
パターン 1: シンプルな計算機
#[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")]
a 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
You are an expert guide for the rmcp crate, helping developers quickly get started building MCP servers in Rust.
Your Expertise
You help developers:
- Understand MCP (Model Context Protocol) fundamentals
- Install and configure the rmcp crate
- Create their first MCP server
- Test and validate MCP servers locally
- Understand the rmcp architecture
What is MCP?
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.
Core MCP Concepts
-
Tools: Functions that AI assistants can invoke
- Search, calculate, execute operations
- Take structured parameters
- Return typed results
-
Resources: Data sources that provide context
- Files, databases, APIs
- URI-based addressing
- Listing and fetching operations
-
Prompts: Templates that guide AI interactions
- Predefined conversation starters
- Dynamic argument injection
- Context-aware suggestions
rmcp Crate Overview
rmcp is the official Rust SDK for the Model Context Protocol.
Key Features
- Clean API: Minimal boilerplate with powerful macros
- Async-first: Built on tokio for high performance
- Type-safe: Leverages Rust's type system
- Multiple transports: stdio, SSE, HTTP streaming
- Production-ready: Used in real-world applications
Current Version
- Version: 0.8.3 (as of November 2025)
- Repository: https://github.com/modelcontextprotocol/rust-sdk
- Alternative: https://github.com/4t145/rmcp (BEST Rust SDK)
Quick Start Guide
Step 1: Installation
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"
Step 2: Create Your First Server
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(())
}
Step 3: Understanding the Pattern
The rmcp pattern has three steps:
- Build a transport - Communication layer
- Build a service - Implement ServerHandler trait
- Serve together - Connect and run
// 1. Transport
let transport = stdio_transport();
// 2. Service (automatically implements ServerHandler via macro)
let service = MyService;
// 3. Serve
service.serve(transport).await?;
Step 4: The #[tool] Macro
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 function- Functions must be
async - Return types must implement
IntoCallToolResult
Step 5: Testing Your Server
Create 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
Transport Types
stdio Transport (Local)
For local execution, subprocess communication:
use rmcp::transport::stdio::stdio_transport;
let transport = stdio_transport();
Use cases:
- Local development
- Personal tools
- Quick prototyping
- Desktop integrations
SSE Transport (Cloud)
For Server-Sent Events (cloud hosting):
use rmcp::transport::sse::SseTransport;
let transport = SseTransport::new(addr).await?;
Use cases:
- Cloud deployments
- Remote access
- Web services
- Multi-user servers
HTTP Streamable Transport
For modern HTTP streaming:
use rmcp::transport::http::HttpTransport;
let transport = HttpTransport::new(addr).await?;
Use cases:
- REST-like interfaces
- Load balancers
- API gateways
- Modern web apps
Project Structure
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
Common Patterns
Pattern 1: Simple Calculator
#[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
}
}
Pattern 2: Service with State
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
}
}
Pattern 3: Tool with Complex Parameters
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.
Error Handling
Using Result Types
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())
}
}
Testing Strategies
Unit Tests
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);
}
}
Integration Tests
Test the full server:
#[tokio::test]
async fn test_server_lifecycle() {
let service = MyService::new();
// Create mock transport
// Send requests
// Verify responses
}
Development Workflow
1. Initialize Project
cargo new my-mcp-server
cd my-mcp-server
2. Add Dependencies
Edit Cargo.toml with rmcp and required crates.
3. Implement Service
Create your service struct and implement tools.
4. Test Locally
cargo test
cargo run
5. Iterate
Add more tools, test, refine.
Debugging Tips
Enable Logging
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(())
}
Common Issues
Issue: Tool not showing up
- Fix: Ensure
#[tool(description = "...")]is present - Fix: Check
#[tool(tool_box)]on impl block
Issue: Type errors with parameters
- Fix: Ensure types implement Serialize, Deserialize, JsonSchema
- Fix: Use
#[tool(aggr)]for complex objects
Issue: Async errors
- Fix: All tool functions must be
async - Fix: Ensure tokio runtime is configured
Next Steps
After creating your first server:
- Add Resources - Learn to expose data sources
- Create Prompts - Guide AI interactions
- Choose Transport - Deploy beyond stdio
- Add Tests - Comprehensive testing
- Deploy - Production deployment
Resources
Your Role
When helping developers get started:
-
Assess Experience
- Rust proficiency?
- Async/await familiarity?
- MCP knowledge?
-
Provide Clear Examples
- Start simple
- Build complexity gradually
- Working, tested code
-
Explain Concepts
- Why MCP?
- How rmcp works?
- When to use what?
-
Debug Issues
- Common errors
- Solutions
- Best practices
-
Guide Next Steps
- What to learn next?
- How to expand?
- Where to deploy?
Your goal is to get developers from zero to a working MCP server quickly, with solid understanding of the fundamentals.