ToolBridge MCP
一个通用的MCP服务器,从 任何语言 到 任何AI.用PowerShell、Python、Bash、Node.js或任何CLI编写工具——ToolBridge使它们可以通过模型上下文协议调用。
想法
这座桥是故意装聋作哑的。它读取描述工具(名称、参数、如何调用它们)的JSON清单,并通过MCP提供服务。它不知道也不关心这些工具是用什么语言编写的。
任何一方都可以改变。这座桥具有普遍性。
- 想要公开PowerShell模块吗?生成清单。
- 想要包装Bash脚本吗?写一个10行的清单。
- 想从Claude切换到另一个AI吗?工具不会改变。
- 想添加新工具吗?将JSON文件放入manifests文件夹中。没有代码更改。
建筑
┌──────────────┐ ┌──────────────────┐ ┌────────────────────┐
│ AI Client │────▶│ ToolBridge │────▶│ Your Tools │
│ │ MCP │ (the bridge) │ │ │
│ Claude Code │◀────│ │◀────│ PowerShell modules│
│ Cursor │ │ Reads manifests │ │ Python scripts │
│ VS Code │ │ Routes execution │ │ Bash commands │
│ Custom app │ │ Returns results │ │ Node.js │
└──────────────┘ └──────────────────┘ │ Any CLI tool │
└────────────────────┘清单是合同:
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Adapter │────▶│ Manifest │◀────│ Bridge │
│ │ │ (JSON) │ │ │
│ Auto-scans │ │ │ │ Reads these │
│ PS modules │ │ - name │ │ Serves via │
│ Py packages │ │ - params │ │ MCP │
│ Or: by hand │ │ - runtime │ │ │
└──────────────┘ │ - command │ └──────────────┘
└──────────────┘快速开始
1.从PowerShell模块生成清单
python generate_manifest.py --powershell AD-SecurityAudit M365-SecurityBaseline EntraID-SecurityAudit此自动发现每个导出的函数,读取参数类型、ValidateSet值、ValidateRange边界、强制标志和帮助文本,然后为每个模块保存一个JSON清单。
2.启动MCP服务器
python run_server.py3.从克劳德代码连接
添加到您的Claude Code MCP配置中(~/.claude/claude_desktop_config.json):
{
"mcpServers": {
"toolbridge": {
"command": "python",
"args": ["C:/Users/larro/Projects/ToolBridge-MCP/run_server.py"]
}
}
}现在,Claude可以直接调用您的PowerShell工具。
手写清单
对于任何CLI工具,编写一个清单——不需要适配器:
{
"version": "1.0",
"description": "Network diagnostic tools",
"tools": [
{
"name": "ping-host",
"description": "Ping a host and return results",
"runtime": "cli",
"command": "ping -c 4 {host}",
"parameters": {
"host": {
"type": "string",
"description": "Hostname or IP to ping",
"required": true
}
}
},
{
"name": "check-ssl",
"description": "Check SSL certificate expiration",
"runtime": "bash",
"command": "echo | openssl s_client -connect {host}:443 2>/dev/null | openssl x509 -noout -dates",
"parameters": {
"host": {
"type": "string",
"description": "Hostname to check",
"required": true
}
}
}
]
}另存为 manifests/network-tools.json 并重新启动服务器。完成。
清单格式
{
"version": "1.0",
"description": "What this manifest contains",
"defaults": {
"runtime": "powershell",
"module": "My-Module",
"timeout": 120
},
"tools": [
{
"name": "Get-Something",
"description": "Human-readable description shown to AI",
"runtime": "powershell|python|bash|node|cli",
"module": "Module-Name",
"function": "Function-Name",
"command": "cli command with {param} placeholders",
"script": "path/to/script.py",
"timeout": 120,
"output_format": "text|json",
"parameters": {
"ParamName": {
"type": "string|integer|number|boolean|array",
"description": "Shown to AI for context",
"required": true,
"default": "default-value",
"enum": ["Option1", "Option2"],
"minimum": 1,
"maximum": 100
}
}
}
]
}支持的运行库
| 运行时 | 通过调用 | 最适合 |
|---|---|---|
powershell | module + function | PowerShell模块和cmdlet |
python | module + function 或 script | Python包和脚本 |
bash | command 或 script | Shell命令、Linux工具 |
node | script 或 command | Node.js脚本 |
cli | command | 任何命令行工具 |
自动发现适配器
适配器扫描现有工具源并自动生成清单:
# PowerShell: reads Get-Command, parameter metadata, Get-Help
python generate_manifest.py --powershell Module-Name
# From a specific path (module not installed globally)
python generate_manifest.py --powershell Module-Name --path "/path/to/module"设计原则
- 这座桥具有普遍性。 它知道MCP协议和清单格式。它永远不知道PowerShell、Python或任何特定的工具。
- 货单就是合同。 工具表明了它们的作用。桥为它们服务。双方都不需要了解对方。
- 零运行时依赖关系。 该桥仅使用Python标准库。没有pip安装,没有版本冲突,没有供应链风险。
- 自动发现是可选的。 适配器生成清单是为了方便。您始终可以用任何语言为任何工具手工编写清单。
- 设计安全。 网桥仅执行本地清单文件中定义的工具。参数值是shell转义的。暂停是强制执行的。
项目结构
ToolBridge-MCP/
├── toolbridge/
│ ├── __init__.py # Package version
│ ├── server.py # MCP server (the bridge)
│ ├── manifest.py # Manifest models and loader
│ ├── executor.py # Runtime execution engine
│ └── adapters/
│ ├── __init__.py
│ └── powershell.py # PS module → manifest generator
├── manifests/ # Drop manifest JSONs here
├── generate_manifest.py # CLI: auto-generate manifests
├── run_server.py # CLI: start the server
├── tests/
│ └── test_toolbridge.py # pytest suite
├── pyproject.toml
├── requirements.txt # Zero dependencies
├── LICENSE
└── README.md需求
- Python 3.10+ (仅限标准库,不依赖pip)
- PowerShell 5.1+或7+ (仅当使用PowerShell工具时)
- 您的工具需要的任何其他运行时
反馈与贡献
该工具旨在解决真正的管理员痛点。如果你有改进的想法,发现一个bug,或者想建议一个功能:
- 打开一个问题 关于此回购-- 问题
- 欢迎功能请求、错误报告和一般反馈
- 如果您想直接做出贡献,我们将不胜感激
如果你觉得这很有用,请查看我的其他工具
许可证
MIT许可证-请参阅 许可证 了解详情。
