使用说明
MCP集线器MCP服务器
连接并管理其他MCP(模型上下文协议)服务器的集线器服务器。
概述
该项目构建了一个MCP集线器服务器,该服务器通过单个接口连接并管理多个MCP(模型上下文协议)服务器。 它允许您仅在需要时连接不常用的MCP(例如Atlassian MCP、Playwright MCP),从而有助于防止过度的上下文使用和污染。 这通过保持活动工具集的专注和可管理性来减少人工智能错误并提高性能。
主要特点
- 通过配置文件自动连接到其他MCP服务器
- 列出连接服务器上的可用工具
- 调用连接服务器上的工具并返回结果
配置
将此添加到您的 mcp.json:
使用npx
{
"mcpServers": {
"other-tools": {
"command": "npx",
"args": [
"-y",
"mcp-hub-mcp",
"--config-path",
"/Users/username/mcp.json"
]
}
}
}
安装和运行
需求
- Node.js 18.0.0或更高版本
- npm、yarn或pnpm
安装
# Clone repository
git clone <repository-url>
cd mcp-hub-mcp
# Install dependencies
npm install
# or
yarn install
# or
pnpm install
构建
npm run build
# or
yarn build
# or
pnpm build
跑
npm start
# or
yarn start
# or
pnpm start
发展模式
npm run dev
# or
yarn dev
# or
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服务器提供以下工具:
1. list-all-tools
返回所有连接服务器的工具列表。
{
"name": "list-all-tools",
"arguments": {}
}
2. call-tool
调用特定服务器上的工具。
serverName:从中调用工具的MCP服务器的名称toolName:要调用的工具的名称toolArgs:要传递给工具的参数
{
"name": "call-tool",
"arguments": {
"serverName": "filesystem",
"toolName": "readFile",
"toolArgs": {
"path": "/Users/username/Desktop/example.txt"
}
}
}
3. find-tools
在所有连接的服务器上查找匹配正则表达式模式的工具(类似grep的功能)。
pattern:在工具名称和描述中搜索的正则表达式模式searchIn:搜索位置:“名称”、“描述”或“两者”(默认值:“两者”)caseSensitive:搜索是否应区分大小写(默认值:false)
{
"name": "find-tools",
"arguments": {
"pattern": "file",
"searchIn": "both",
"caseSensitive": false
}
}
示例模式:
"file"-查找所有包含“文件”的工具"^read"-查找所有以“read”开头的工具"(read|write).*file"-查找用于读取或写入文件的工具"config$"-查找以“config”结尾的工具
输出示例:
{
"filesystem": [
{
"name": "readFile",
"description": "Read the contents of a file",
"inputSchema": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Path to the file to read"
}
},
"required": ["path"]
}
},
{
"name": "writeFile",
"description": "Write content to a file",
"inputSchema": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Path to the file to write"
},
"content": {
"type": "string",
"description": "Content to write to the file"
}
},
"required": ["path", "content"]
}
}
]
}
提交消息约定
该项目如下 常规承诺 用于自动版本控制和CHANGELOG生成。
格式: <type>(<scope>): <description>
示例:
feat: add new hub connection featurefix: resolve issue with server timeoutdocs: update API documentationchore: update dependencies
类型:
feat:新功能(MINOR版本凹凸)fix:Bug修复(PATCH版本碰撞)docs:仅文档更改style:不影响代码含义的更改refactor:既不修复错误也不添加功能的代码更改perf:改进性能的代码更改test:添加缺失的测试或更正现有的测试chore:对构建过程或辅助工具的更改
重大变更:
添加 BREAKING CHANGE: 在提交页脚中触发主版本升级。
其他链接
许可证
麻省理工学院