SaraMCP
你只是想用它吗?=> https://saramcp.com/
一个强大的模型上下文协议(MCP)服务器管理平台,用于构建、配置和部署基于HTTP的人工智能工具。
SaraMCP使您能够创建可重用的HTTP API工具工具包,通过灵活的参数绑定进行配置,并将其作为MCP服务器暴露出来,这些服务器可与Claude Desktop和其他MCP客户端无缝协作。
特点/特性
核心能力
- 可重复使用工具包 - 创建基于HTTP的工具集合(类似于Postman集合),以便在多个MCP服务器之间共享
- 灵活参数系统 - 配置具有三层解析能力的参数:
- 实例级别带有变量替换的固定值 - 服务器级别共享默认值和加密密钥 - 暴露的大语言模型(LLMs)在运行时提供的动态参数
- 类型安全 - 具有验证功能的强类型参数系统(字符串、数字、整数、布尔值、JSON、URL)
- 密钥管理 - 使用AES-256-GCM加密API密钥和敏感配置
- 热重载 - 更新工具配置而无需重启服务器
- OAuth 2.0 集成 - 三级访问控制(公开/组织/私有)
- MCP协议 - 完整实现JSON-RPC 2.0,支持HTTP和SSE传输方式
开发者体验
- Web 用户界面(或网页用户界面) - 完整的网页界面,用于管理服务器、工具包和工具实例
- 命令行界面(CLI)工具 - 用于自动化和脚本编写的命令行工具
- 执行跟踪 - 内置日志记录和调试功能
- 自动发现 - 标准
.well-knownMCP服务器发现的端点 - Docker 支持 - 使用docker-compose实现生产就绪的容器化
快速入门
先决条件
- Rust 1.75+(用于从源代码构建)
- SQLite 3
- Docker & Docker Compose(用于容器化部署)
安装
选项1:Docker(推荐)
# Clone the repository
git clone https://github.com/yourusername/saramcp.git
cd saramcp
# Copy environment template
cp .env.example .env
# Edit .env and set your configuration
# Minimal required: DATABASE_URL, SESSION_SECRET, SARAMCP_MASTER_KEY
# Start the server
docker-compose up -d服务器将在 http://localhost:8080
选项2:从源代码构建
# Clone the repository
git clone https://github.com/yourusername/saramcp.git
cd saramcp
# Create data directory
mkdir -p data
# Copy environment template
cp .env.example .env
# Run database migrations
sqlx migrate run
# Build and run
cargo build --release
./target/release/saramcp初步步骤
- 创建一个账户
- 导航至 http://localhost:8080/signup - 创建您的第一个用户帐户
- 创建一个工具包
- 进入“工具包”并点击“创建新工具包” - 添加带有参数模板的HTTP工具,如 https://api.example.com/users/{{integer:user_id}}
- 创建一个服务器
- 前往“服务器”并点击“创建新服务器” - 导入您的工具包 - 配置工具实例并绑定参数
- 与Claude桌面版一起使用
- 复制您服务器的MCP端点: http://localhost:8080/s/{server-uuid} - 添加到Claude Desktop的MCP配置中 - 在对话中开始使用你的工具吧!
配置
环境变量
创建一个 .env 包含以下变量的文件:
# Database
DATABASE_URL=sqlite://data/saramcp.db
# Security (generate random 64-character strings)
SESSION_SECRET=your_64_character_random_string_here
SARAMCP_MASTER_KEY=your_base64_encoded_32_byte_key_here
# Server
HOST=127.0.0.1
PORT=8080
RUST_LOG=info
# Email (optional - for password reset)
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USERNAME=noreply@example.com
SMTP_PASSWORD=your_smtp_password
SMTP_FROM_EMAIL=noreply@example.com
SMTP_FROM_NAME=SaraMCP
SMTP_ENCRYPTION=starttls生成密钥
# Generate SESSION_SECRET
openssl rand -hex 32
# Generate SARAMCP_MASTER_KEY
openssl rand -base64 32使用示例
示例1:货币转换器工具
工具定义:
Name: get_exchange_rate
URL: https://api.exchangerate-api.com/v4/latest/{{string:base_currency}}
Method: GET工具实例配置:
Instance Name: convert_usd_to_eur
Parameters:
- base_currency: "USD" (instance-level, fixed)当克劳德打电话来时 convert_usd_to_eur它会自动获取美元汇率。
示例2:使用密钥的身份验证API
工具定义:
Name: create_issue
URL: https://api.github.com/repos/{{string:repo}}/issues
Method: POST
Headers:
Authorization: Bearer {{string:github_token}}
Body: {"title": "{{string:title}}", "body": "{{string:description}}"}服务器配置:
Server Globals (encrypted):
- github_token: ghp_your_secret_token_here (secret)工具实例:
Instance Name: create_project_issue
Parameters:
- repo: "myorg/myproject" (instance-level)
- github_token: (server-level, uses encrypted secret)
- title: (exposed, LLM provides)
- description: (exposed, LLM provides)现在,克劳德只需提供标题和描述,就能创建 GitHub 问题!
建筑学
SaraMCP采用了一种简洁的三层架构:
┌─────────────────────────────────────┐
│ Web Handlers (Axum Routes) │ ← HTTP endpoints
└──────────────┬──────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Services (Business Logic) │ ← Core functionality
│ - Parameter Resolution │
│ - Secrets Management │
│ - HTTP Execution │
│ - MCP Protocol │
└──────────────┬──────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Models & Repositories │ ← Data access
└─────────────────────────────────────┘如需详细的架构文档,请参阅 CLAUDE.md(文件名或标记,可译为“克劳德.md”或保持原样,具体取决于上下文是否需要翻译文件名)。
发展
设置开发环境
# Install Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install sqlx-cli for database management
cargo install sqlx-cli --no-default-features --features sqlite
# Clone and setup
git clone https://github.com/yourusername/saramcp.git
cd saramcp
cp .env.example .env
mkdir -p data
# Run migrations
sqlx database create
sqlx migrate run
# Start development server
cargo run运行测试
# Run all tests
cargo test
# Run tests with output
cargo test -- --nocapture
# Run specific test
cargo test test_parameter_resolution
# Run with coverage (requires tarpaulin)
cargo tarpaulin --out Html代码质量
# Format code
cargo fmt
# Run linter
cargo clippy -- -D warnings
# Check without building
cargo check项目结构
saramcp/
├── src/
│ ├── main.rs # Application entry point
│ ├── lib.rs # Library exports
│ ├── models/ # Data models
│ ├── services/ # Business logic
│ │ ├── parameter_resolver.rs
│ │ ├── secrets_manager.rs
│ │ ├── http_executor.rs
│ │ └── instance_executor.rs
│ ├── mcp/ # MCP protocol implementation
│ │ ├── service.rs # MCP handler
│ │ ├── registry.rs # Server lifecycle
│ │ └── handlers.rs # HTTP endpoints
│ ├── handlers/ # Web request handlers
│ ├── middleware/ # Authentication & middleware
│ └── bin/
│ └── cli.rs # CLI tools
├── migrations/ # Database migrations
├── templates/ # Askama HTML templates
├── static/ # CSS, JS, images
├── tests/ # Integration tests
├── Dockerfile
├── docker-compose.yml
└── CLAUDE.md # Detailed system designAPI终端点
MCP协议端点
POST /s/{uuid}- MCP JSON-RPC HTTP传输GET /s/{uuid}/sse- MCP 服务器发送事件传输GET /.well-known/mcp-servers- MCP服务器发现GET /.well-known/oauth-authorization-server- OAuth 元数据GET /.well-known/oauth-protected-resource/s/{uuid}- 每台服务器的OAuth元数据
网页界面
/- 仪表盘/login- 认证/toolkits- 工具包管理/servers- 服务器管理/servers/{id}/instances- 工具实例配置
做出贡献
我们欢迎投稿!请参阅 CONTRIBUTING.md 翻译为中文是:“贡献指南.md” 或 “贡献说明文件.md”,具体翻译可能根据上下文有所调整,但基本意思是指一个关于如何向项目贡献代码或内容的指南文件 作为指导方针。
开发工作流程
- 为仓库创建分支(或:克隆仓库)
- 创建一个特性分支(
git checkout -b feature/amazing-feature) - 在测试中进行更改
- 确保所有测试通过(
cargo test) - 运行代码质量检查(
cargo clippy -- -D warnings && cargo fmt) - 提交您的更改(
git commit -m 'Add amazing feature') - 推送到分支(
git push origin feature/amazing-feature) - 提交一个拉取请求
安全
报告漏洞
如果您发现安全漏洞,请发送邮件至security@yourdomain.com。请不要公开发布问题。
安全特性
- 密码哈希处理Argon2id,具备安全默认设置
- 会话管理使用SQLite存储的签名、加密会话
- 秘密加密AES-256-GCM用于API密钥和敏感数据
- 跨站请求伪造(CSRF)保护所有表单均采用基于令牌的CSRF(跨站请求伪造)保护
- OAuth 2.0行业标准授权,具备三级访问控制
- 输入验证类型安全的参数验证和清理
许可证
这个项目遵循MIT许可证授权——详见 许可证 文件中有详细信息。
致谢
支持
- 文档: CLAUDE.md(文件名,可译为“克劳德.md”或保持原样,具体取决于上下文是否需要翻译文件名)
- 部署指南: \
DEPLOYMENT_GUIDE.md\翻译为中文是:\部署指南.md\ - 问题:
- 讨论:
______________________________________________________________________
为AI代理生态系统倾注爱心打造
