一个连接并管理其他MCP(模型上下文协议)服务器的中心服务器。
该项目构建了一个MCP中心服务器,通过单一接口连接并管理多个MCP(模型上下文协议)服务器。它有助于防止不常用MCP(如Atlassian MCP、Playwright MCP)导致的上下文过度使用和污染,只需在需要时连接它们。这减少了AI错误,并通过保持活跃工具集的集中和可管理性来提高性能。
在您的mcp.json中添加以下内容:
{
"mcpServers": {
"other-tools": {
"command": "npx",
"args": [
"-y",
"mcp-hub-mcp",
"--config-path",
"/Users/username/mcp.json"
]
}
}
}
# 克隆仓库
git clone <repository-url>
cd mcp-hub-mcp
# 安装依赖
npm install
# 或
yarn install
# 或
pnpm install
npm run build
# 或
yarn build
# 或
pnpm build
npm start
# 或
yarn start
# 或
pnpm start
npm run dev
# 或
yarn dev
# 或
pnpm dev
MCP-Hub-MCP服务器使用Claude Desktop格式的配置文件来自动连接到其他MCP服务器。您可以按以下方式指定配置文件:
MCP_CONFIG_PATH环境变量为配置文件路径--config-path选项指定配置文件路径mcp-config.json文件配置文件格式:
{
"mcpServers": {
"serverName1": {
"command": "command",
"args": ["arg1", "arg2", ...],
"env": { "ENV_VAR1": "value1", ... }
},
"serverName2": {
"command": "anotherCommand",
"args": ["arg1", "arg2", ...]
}
}
}
示例:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/Users/username/Downloads"
]
},
"other-server": {
"command": "node",
"args": ["path/to/other-mcp-server.js"]
}
}
}
MCP-Hub-MCP服务器提供以下工具:
list-all-tools返回所有已连接服务器上的工具列表。
{
"name": "list-all-tools",
"arguments": {}
}
call-tool调用特定服务器上的工具。
serverName:要调用工具的MCP服务器名称toolName:要调用的工具名称toolArgs:传递给工具的参数{
"name": "call-tool",
"arguments": {
"serverName": "filesystem",
"toolName": "readFile",
"toolArgs": {
"path": "/Users/username/Desktop/example.txt"
}
}
}
find-tools在所有已连接服务器上查找匹配正则表达式模式的工具(类似grep的功能)。
pattern:要在工具名称和描述中搜索的正则表达式模式searchIn:在哪里搜索:"name"、"description"或"both"(默认:"both")caseSensitive:搜索是否区分大小写(默认:false){
"name": "find-tools",
"arguments": {
"pattern": "file",
"searchIn": "both",
"caseSensitive": false
}
}
示例模式:
"file" - 查找包含"file"的所有工具"^read" - 查找以"read"开头的所有工具"(read|write).*file" - 查找用于读取或写入文件的工具"config$" - 查找以"config"结尾的工具示例输出:
{
"filesystem": [
{
"name": "readFile",
"description": "读取文件的内容",
"inputSchema": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "要读取的文件路径"
}
},
"required": ["path"]
}
},
{
"name": "writeFile",
"description": "将内容写入文件",
"inputSchema": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "要写入的文件路径"
},
"content": {
"type": "string",
"description": "要写入文件的内容"
}
},
"required": ["path", "content"]
}
}
]
}
此项目遵循常规提交进行自动版本控制和CHANGELOG生成。
格式:<类型>(<范围>):<描述>
示例:
feat: 添加新的中心连接功能fix: 解决服务器超时问题docs: 更新API文档chore: 更新依赖项类型:
feat:新功能(次要版本提升)fix:修复错误(补丁版本提升)docs:仅文档更改style:不影响代码意义的更改refactor:既不修复错误也不添加功能的代码更改perf:改进性能的代码更改test:添加缺失的测试或纠正现有测试chore:构建过程或辅助工具的更改重大变更:
在提交注脚中添加BREAKING CHANGE:以触发主要版本提升。
MIT