mcprax-模型上下文协议机架管理器
一个强大的CLI工具,用于将模型上下文协议(MCP)服务器作为可配置的“机架”管理和部署到Claude Desktop,从而简化您的开发工作流程。
安装
通过npm全局安装:
npm install -g @ownlytics/mcprax这将使 rax 全球可用的命令。
什么是mcprax?
mcprax(发音为“mcp-racks”)是用于管理Claude Desktop中的模型上下文协议(mcp)服务器的专用工具。它允许您:
- 定义多个MCP服务器配置
- 将这些服务器分组到“机架”(集合)中
- 在不同机架之间切换
- 将机架配置应用于Claude Desktop
这种方法类似于nvm、rvm和conda等版本管理器,允许您维护多个服务器配置并在它们之间轻松切换。
快速开始
# Create a new rack for development
rax create ai-tools-rack
# Create an MCP server for filesystem access
rax server create filesystem '{"command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/username/Documents", "/Users/username/Projects"]}'
# Create a GitHub MCP server
rax server create github-server '{"command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": {"GITHUB_PERSONAL_ACCESS_TOKEN": "your-token-here"}}'
# Set the rack as active
rax use ai-tools-rack
# Mount servers to the active rack
rax mount filesystem
rax mount github-server
# Apply the rack to Claude Desktop
rax apply
# Verify your configuration
rax mounted命令
机架管理
rax create-创建一个新的空机架rax use-激活特定机架rax list-列出可用机架rax current-显示当前活动机架rax delete-删除机架
服务器管理
rax server create [config]-创建新的服务器配置
- config 可以是JSON字符串、JSON文件的路径或command+args
rax server list-列出可用服务器rax server show-显示服务器配置的详细信息rax server delete-删除服务器配置
机架式服务器操作
rax mount-将服务器添加到活动机架rax unmount-从活动机架中卸下服务器rax mounted-列出活动机架中的服务器
配置应用
rax apply-将活动机架应用于Claude Desktop配置
- 使用 --force 即使机架没有服务器,也要应用 - 使用 --yes 跳过确认提示 - 使用 --restart 应用后自动重新启动Claude Desktop
应用程序管理
rax reboot-重新启动Claude Desktop应用程序
- 使用 --force 跳过确认提示
版本管理
rax version-显示版本信息
- 使用 --check 检查更新
rax update-检查并应用mcprax的更新
- 使用 --check-only 若要仅检查更新,请不要安装 - 使用 --force 即使已使用最新版本,也要进行更新 - 使用 --enable-notifications 启用更新通知 - 使用 --disable-notifications 禁用更新通知
MCP服务器配置
MCP(模型上下文协议)服务器允许像克劳德这样的人工智能系统通过标准化的接口与外部工具、数据源和服务进行交互。mcprax可帮助您管理Claude Desktop的这些服务器配置。
服务器配置格式
{
"name": "github-server",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your-token-here"
},
"disabled": false,
"alwaysAllow": ["fetch", "readFile"]
}配置字段
name-服务器的标识符command-要运行的可执行文件(npx、node、python等)args-命令行参数数组env-要设置的环境变量disabled-默认情况下是否禁用服务器alwaysAllow-始终允许此服务器的操作数组
创建服务器配置
有多种方法可以创建服务器配置:
直接使用JSON
rax server create postgres-server '{"command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgresql"], "env": {"PGUSER": "user", "PGPASSWORD": "password", "PGDATABASE": "mydb"}}'使用命令参数
rax server create vector-db npx -y @modelcontextprotocol/server-chroma使用交互模式
rax server create custom-server --interactive从JSON文件
rax server create config-server path/to/server-config.json机架配置
机架是服务器配置的集合。应用时,机架中的所有服务器都在Claude Desktop中配置。
{
"name": "ai-tools-rack",
"servers": ["filesystem", "github-server", "brave-search"],
"description": "Development environment with file access, GitHub, and search capabilities"
}运作原理
mcprax管理:
- 服务器配置(JSON文件
~/.mcprax/servers/) - 机架配置(JSON文件
~/.mcprax/racks/) - 主动机架跟踪
- Claude桌面配置生成
当你奔跑时 rax apply,麦委会:
- 读取活动机架配置
- 在机架中加载所有服务器配置
- 生成一个包含所有服务器配置的Claude Desktop配置文件
- 备份现有的Claude Desktop配置(如果有)
- 将新配置写入Claude Desktop
示例工作流
基本MCP服务器设置
# Create a development rack
rax create mcp-basic
# Create filesystem server for local file access
rax server create filesystem '{"command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/username/Documents"]}'
# Activate and configure
rax use mcp-basic
rax mount filesystem
rax apply多环境管理
# Create different racks for different purposes
rax create coding-tools
rax create data-analysis
rax create content-creation
# Configure coding tools rack
rax use coding-tools
rax mount github-server
rax mount code-assistant
rax apply
# Later, switch to data analysis tools
rax use data-analysis
rax mount postgres-server
rax mount csv-tools
rax apply流行的MCP服务器示例
以下是您可能想要配置的流行MCP服务器的一些示例:
- 文件系统 -提供文件系统访问权限
rax server create filesystem '{"command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/directory"]}'- GitHub -存储库和代码管理
rax server create github '{"command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": {"GITHUB_PERSONAL_ACCESS_TOKEN": "your-token"}}'- PostgreSQL -数据库访问
rax server create postgres '{"command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgresql"], "env": {"PGUSER": "user", "PGPASSWORD": "pass", "PGDATABASE": "db", "PGHOST": "localhost"}}'- 勇敢的搜索 -网络搜索功能
rax server create brave-search '{"command": "npx", "args": ["-y", "@modelcontextprotocol/server-brave-search"], "env": {"BRAVE_API_KEY": "your-api-key"}}'- 记忆 -LLM的持久内存
rax server create memory '{"command": "npx", "args": ["-y", "@modelcontextprotocol/server-memory"]}'存储位置
mcprax将配置存储在用户的主目录中:
~/.mcprax/
├── active.json # Tracks active rack
├── servers/ # Server definitions
│ ├── filesystem.json
│ └── github-server.json
└── racks/ # Rack definitions
├── coding-tools.json
└── data-analysis.jsonClaude Desktop配置存储在:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 窗户:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
提示和最佳实践
- 描述性地命名服务器 -使用表示函数的名称(例如,“github服务器”、“postgres-db”)
- 创建专用机架 -为不同的工作流程创建不同的机架
- 使用
--force小心标记 -它将在未经确认的情况下覆盖配置 - 应用前检查已安装的服务器 -使用
rax mounted验证机架内容 - 使用
--restart或rax reboot-使用rax apply --restart或rax reboot应用更改后重新启动Claude Desktop - 确保敏感信息的安全 -MCP服务器配置中的API密钥和令牌应受到保护
故障排除
常见问题
- “未设置活动机架” -快跑
rax use设置活动机架 - “找不到服务器” -检查服务器是否存在
rax server list - 配置未生效 -使用
rax reboot应用更改后重新启动Claude Desktop - 权限问题 -确保您具有对Claude Desktop配置目录的写访问权限
- MCP服务器错误 -检查Claude Desktop日志以获取特定于服务器的错误消息
- 更新失败 -如果
rax update如果失败,您可能需要管理员权限。试着跑步npm install -g @ownlytics/mcprax手动地
更新管理
mcprax包括内置工具,可帮助您保持最新状态:
# Check the current version and available updates
rax version --check
# Update to the latest version
rax update
# Disable update notifications
rax update --disable-notifications
# Enable update notifications
rax update --enable-notifications配置备份
在应用更改之前,mcprax会自动创建Claude Desktop配置的备份。备份与带有时间戳后缀的配置文件存储在同一目录中。
许可证
麻省理工学院
