
emillindfors/mcp
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
A crate for making MCP (Model Context Protocol) compatible programs with rust
概要
A Rust implementation of the Model Context Protocol (MCP), providing a standardized way for AI models to access external context and resources. mcp.rs is a high-performance, type-safe Rust implementation of the Model Context Protocol, designed to enable seamless communication between AI applications and their integrations. It provides a robust foundation for building MCP servers that can expose various types of resources (files, data, APIs) to AI models. - : - Standard Input/Output (stdio) transport for CLI tools - HTTP with Server-Sent Events (SSE) for web integrations - Extensible transport system for custom implementations - : - File system resource provider - Resource templating support - Real-time resource updates - Resource subscription capabilities - : - YAML/JSON configuration files - Environment variable overrides - Command-line arguments - Sensible defaults - : - Built-in access controls - Path traversal protection - Rate limiting - CORS support Add mcp.
README
以下は原文 README の抜粋です。原文を見る。
mcp.rs
A Rust implementation of the Model Context Protocol (MCP), providing a standardized way for AI models to access external context and resources.
Quickstart
Client
# List resources
cargo run --bin client list-resources
# Read a specific file
cargo run --bin client read-resource -u "file:///path/to/file"
# Use a prompt
cargo run --bin client get-prompt -n "code_review" -a '{"code": "fn main() {}", "language": "rust"}'
# Call a tool
cargo run --bin client -- --server "http://127.0.0.1:3000" call-tool --name "file_system" --args '{\"operation\": \"read_file\", \"path\": \"Config.toml\"}'
# Set log level
cargo run --bin client set-log-level -l "debug"
# Use SSE transport
cargo run --bin client -t sse -s http://localhost:3000 list-resources
Server
# Run with test config
cargo run --bin server -- --config "../servers/test.json"
Overview
mcp.rs is a high-performance, type-safe Rust implementation of the Model Context Protocol, designed to enable seamless communication between AI applications and their integrations. It provides a robust foundation for building MCP servers that can expose various types of resources (files, data, APIs) to AI models.
Features
-
Multiple Transport Types:
- Standard Input/Output (stdio) transport for CLI tools
- HTTP with Server-Sent Events (SSE) for web integrations
- Extensible transport system for custom implementations
-
Resource Management:
- File system resource provider
- Resource templating support
- Real-time resource updates
- Resource subscription capabilities
-
Flexible Configuration:
- YAML/JSON configuration files
- Environment variable overrides
- Command-line arguments
- Sensible defaults
-
Security:
- Built-in access controls
- Path traversal protection
- Rate limiting
- CORS support
Installation
Add mcp.rs to your project’s Cargo.toml:
[dependencies]
mcp = "0.1.0"
Quick Start
- Create a basic MCP server:
use mcp::{McpServer, ServerConfig};
#[tokio::main]
async fn main() -> Result {
// Create server with default configuration
let server = McpServer::new(ServerConfig::default());
// Run the server
server.run().await
}
- Configure via command line:
# Run with stdio transport
mcp-server -t stdio
# Run with SSE transport on port 3000
mcp-server -t sse -p 3000
# Enable debug logging
mcp-server -l debug
- Or use a configuration file:
server:
name: "my-mcp-server"
version: "1.0.0"
transport: sse
port: 3000
resources:
root_path: "./resources"
allowed_schemes:
- file
max_file_size: 10485760
security:
enable_auth: false
allowed_origins:
- "*"
logging:
level: "info"
format: "pretty"
Architecture
mcp.rs follows a modular architecture:
- Transport Layer: Handles communication between clients and servers
インストール
This server does not publish a one-line install command.
Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →