MCP 管理器
⚠️ 测试版发布 - 这是一个处于活跃开发中的测试版发布。API和功能可能会发生变化。请报告您遇到的任何问题。
面向多个AI客户端的统一MCP(模型上下文协议)网关和配置管理器。
概述
MCP Manager 是一个强大的工具,它作为一个单一的统一 MCP 服务器,内部将请求路由到多个后端 MCP 服务器。您无需在您的 AI 客户端(如 Claude、Cursor、VS Code 等)中单独配置每个 MCP 服务器,只需配置一个即可: mcp-manager。
主要特点
- 单一配置点 - 在您的AI客户端中配置一个MCP服务器
- 多个后端服务器 - 连接到无限数量的MCP服务器(GitHub、Jenkins、Obsidian等)
- 动态工具管理 - 启用/禁用服务器,无需重启您的AI客户端
- 工具命名空间 - 自动添加前缀以避免命名冲突(例如。,
github__create_issue) - 健康监测 - 自动健康检查和重新连接
- 集中式认证 - 在一个地方管理所有凭据
- 跨客户端支持 - 与Claude Code、Cursor、VS Code等兼容
安装
全局安装(推荐)
npm install -g mcp-manage安装后,您可以使用 mcp 直接命令:
mcp --help
mcp init
mcp add myserver使用 npx(无需安装)
npx mcp-manage@latest
# Examples
npx mcp-manage@latest init
npx mcp-manage@latest add myserver为方便起见的别名
如果经常使用 npx,请创建一个别名:
# Add to your ~/.bashrc or ~/.zshrc
alias mcp="npx mcp-manage@latest"
# Then use
mcp init
mcp list快速入门
1. 初始化配置
mcp init这会产生:
~/.mcp/config.json- 主配置文件~/.mcp/logs/- 日志目录~/.mcp/data/- 数据目录
2. 添加MCP服务器
添加一个标准输入输出服务器(例如,shadcn):
mcp add shadcn \
--type stdio \
--command npx \
--args "shadcn@latest,mcp"添加一个HTTP服务器(例如,GitHub):
mcp add github \
--type http \
--url https://api.githubcopilot.com/mcp \
--auth bearer:YOUR_TOKEN交互模式(推荐):
mcp add myserver
# Follow the prompts
# For custom headers, select "custom" as authentication type
# Then enter each header name and value (supports ${ENV_VAR} syntax)3. 配置您的AI客户端
添加 只有一个 进入您AI客户端的MCP配置:
克劳德·科德 (~/.claude.json):
{
"mcpServers": {
"mcp-manage": {
"command": "mcp",
"args": ["serve"]
}
}
}或者如果使用 npx:
{
"mcpServers": {
"mcp-manage": {
"command": "npx",
"args": ["mcp-manage@latest", "serve"]
}
}
}光标 (.cursor/mcp.json):
{
"mcpServers": {
"mcp-manage": {
"command": "mcp",
"args": ["serve"]
}
}
}VS Code (settings.json):
{
"github.copilot.chat.mcp.servers": {
"mcp-manage": {
"command": "mcp",
"args": ["serve"]
}
}
}4. 重启您的AI客户端
搞定!您已启用的服务器上的所有工具现在都可用。
CLI 命令
所有命令均使用 mcp 命令(或 npx mcp-manage@latest (如果未全局安装):
服务器管理
# List all configured servers
mcp list
mcp ls -v # Verbose mode
# Add a new server (interactive mode)
mcp add
# Add a stdio server with options
mcp add shadcn \
--type stdio \
--command npx \
--args "shadcn@latest,mcp"
# Add an HTTP server with authentication
mcp add github \
--type http \
--url https://api.example.com/mcp \
--auth bearer:YOUR_TOKEN
# Add an HTTP server with custom headers
mcp add context7 \
--type http \
--url https://mcp.context7.com/mcp \
-H "CONTEXT7_API_KEY:${SZ_CONTEXT7_API_KEY}"
# Add server with multiple custom headers
mcp add myserver \
--type http \
--url https://api.example.com/mcp \
-H "X-API-Key:${API_KEY}" \
-H "X-Custom-Header:${CUSTOM_VALUE}"
# Add command options:
# -t, --type Transport type (stdio|http|sse)
# -c, --command Command for stdio transport
# -a, --args Arguments for stdio transport (comma-separated)
# -u, --url URL for HTTP and SSE transport
# --auth Authentication (bearer:TOKEN or basic:CREDS)
# -H, --header Custom header (KEY:VALUE, can be used multiple times)
# --enabled Enable the server immediately (default: true)
# Remove a server
mcp remove
# Enable/disable servers
mcp enable
mcp disable
# Check server status
mcp status工具发现
# List all available tools
mcp tools
# Output example:
# Tool Statistics:
# Total Servers: 3
# Connected: 3
# Total Tools: 87
# Total Resources: 12
# Total Prompts: 5
#
# By Server:
# github:
# Tools: 45
# Resources: 8
# Prompts: 2
# jenkins:
# Tools: 28
# Resources: 3
# Prompts: 1
# obsidian:
# Tools: 14
# Resources: 1
# Prompts: 2网关服务器
# Start the gateway (usually called by AI client)
mcp serve
# Use custom config file
mcp serve --config /path/to/config.json运输类型
MCP Manager 支持两种传输类型用于连接到 MCP 服务器:
STDIO 传输
用于通过标准输入/输出进行通信的本地MCP服务器:
# Add with CLI
mcp add myserver \
--type stdio \
--command node \
--args "/path/to/server.js"
# Examples:
# Node.js MCP server
mcp add nodejs-mcp --type stdio --command node --args "server.js"
# Python MCP server
mcp add python-mcp --type stdio --command python --args "server.py"
# NPX package
mcp add shadcn --type stdio --command npx --args "shadcn@latest,mcp"配置格式:
{
"transport": {
"type": "stdio",
"command": "npx",
"args": ["shadcn@latest", "mcp"]
},
"env": {
"NODE_ENV": "production"
}
}HTTP传输
用于暴露HTTP端点的远程MCP服务器:
# Add with CLI
mcp add remote-mcp \
--type http \
--url https://api.example.com/mcp
# With bearer token authentication
mcp add github \
--type http \
--url https://api.example.com/mcp \
--auth bearer:ghp_xxxxxxxxxxxxx
# With basic authentication
mcp add jenkins \
--type http \
--url https://ci.example.com/mcp \
--auth basic:username:password配置格式:
{
"transport": {
"type": "http",
"url": "https://api.example.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
}
}认证选项
这个(或“该”) --auth 旗帜支持:
- 不记名令牌(或称为载体令牌):
--auth bearer:TOKEN
- 添加标题: Authorization: Bearer TOKEN
- 基本认证:
--auth basic:CREDENTIALS
- 添加头部: Authorization: Basic base64(CREDENTIALS)
配置
配置文件位置
~/.mcp/config.json
配置模式(或配置架构)
{
"version": "1.0.0",
"servers": {
"github": {
"enabled": true,
"transport": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp",
"headers": {
"Authorization": "Bearer ghp_xxx"
}
},
"healthCheck": {
"enabled": true,
"interval": 30000,
"timeout": 5000
},
"retryPolicy": {
"maxRetries": 3,
"backoffMs": 1000
},
"toolNamespace": "github",
"metadata": {
"description": "GitHub MCP Server",
"tags": ["git", "source-control"]
}
},
"jenkins": {
"enabled": true,
"transport": {
"type": "http",
"url": "https://ci.example.com/mcp-server/mcp",
"headers": {
"Authorization": "Basic base64creds"
}
}
},
"shadcn": {
"enabled": true,
"transport": {
"type": "stdio",
"command": "npx",
"args": ["shadcn@latest", "mcp"]
},
"env": {
"NODE_ENV": "production"
}
}
},
"gateway": {
"defaultNamespace": true,
"toolPrefix": "",
"healthCheck": {
"interval": 30000
}
}
}工具命名空间
工具会自动进行命名空间划分以避免冲突:
Original tool: create_issue
Namespaced: github__create_issue
Original tool: trigger_build
Namespaced: jenkins__trigger_build当AI呼叫时 github__create_issueMCP 管理员:
- 解析命名空间:
github - 提取工具名称:
create_issue - 将呼叫路由到GitHub MCP服务器
- 将响应返回给AI
环境变量
在你的配置中使用环境变量,使用 ${VAR_NAME} 语法。这适用于任何字符串字段,包括URL、头部信息、命令参数和环境变量。
标准授权:
{
"servers": {
"github": {
"transport": {
"type": "http",
"url": "${GITHUB_MCP_URL}",
"headers": {
"Authorization": "Bearer ${GITHUB_TOKEN}"
}
}
}
}
}自定义头部:
{
"servers": {
"context7": {
"transport": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "${SZ_CONTEXT7_API_KEY}"
}
}
}
}
}在命令参数中:
{
"servers": {
"myserver": {
"transport": {
"type": "stdio",
"command": "node",
"args": ["server.js", "--token", "${API_TOKEN}"]
}
}
}
}建筑
┌─────────────────┐
│ AI Client │
│ (Claude/Cursor) │
└────────┬────────┘
│ Single MCP Connection
│
┌────▼────────┐
│ MCP Manager │
│ Gateway │
└────┬────────┘
│ Routes to multiple backends
│
┌────┴─────────────────────────┐
│ │
┌───▼────┐ ┌─────────┐ ┌────────▼───┐
│ GitHub │ │ Jenkins │ │ Obsidian │
│ MCP │ │ MCP │ │ MCP │
└────────┘ └─────────┘ └────────────┘发展
想贡献一份力量吗?请查看 CONTRIBUTING.md 翻译为中文是“贡献指南/贡献规范文件” 作为指南。
# Install dependencies
bun install
# Run in development
bun run dev
# Build
bun run build
# Lint
bun run lint
# Test
bun test贡献;做出贡献
欢迎投稿!请阅读 CONTRIBUTING.md(贡献指南文件) 有关我们的行为准则以及提交拉取请求的流程的详细信息,请参阅。
更新日志
看 CHANGELOG.md 翻译成中文是:“版本更新日志文件(Markdown 格式)” 查看更改列表和版本历史。
许可证
MIT - 查看 许可证 详情如下。
支持
- 问题:
- 文档: 入门指南
- 仓库(或存储库):
