🐳 Docker MCP网关-一键设置
将所有MCP服务器整合到一个网关中。将上下文窗口的使用率降低90%以上。
你得到的是一个网关,它只动态加载你需要的东西(约500个令牌),而不是5个MCP服务器和50个工具淹没你的AI上下文(约20000个令牌)。
______________________________________________________________________
⚡ 快速安装
Windows(PowerShell)
irm https://raw.githubusercontent.com/global-mysterysnailrevolution/docker-mcp-mcp/main/install.ps1 | iex或者下载并双击 install.bat
它的作用
- ✅ 安装Docker桌面(如果需要)
- ✅ 启用MCP工具包
- ✅ 配置 克劳德代码, 光标,以及 克劳德桌面
- ✅ 添加基本的MCP服务器(GitHub、文件系统、fetch等)
______________________________________________________________________
📁 文件
| 文件 | 描述 |
|---|---|
install.bat | 双击运行(Windows) |
install.ps1 | 主PowerShell安装脚本 |
sample-workflow.js | 示例代码执行工作流 |
______________________________________________________________________
🔧 手动设置
如果脚本不起作用,请手动执行此操作:
1.安装Docker桌面
下载自https://www.docker.com/products/docker-desktop/
2.启用MCP工具包
- 打开Docker桌面
- 设置 → 开发中的特点
- 启用 “MCP工具包”
- 点击 应用并重新启动
3.将MCP配置添加到您的AI工具中
克劳德代码 (~/.claude.json 或 %USERPROFILE%\.claude.json):
{
"mcpServers": {
"MCP_DOCKER": {
"command": "docker",
"args": ["mcp", "gateway", "run"],
"type": "stdio"
}
}
}光标 (~/.cursor/mcp.json 或 %USERPROFILE%\.cursor\mcp.json):
{
"mcpServers": {
"MCP_DOCKER": {
"command": "docker",
"args": ["mcp", "gateway", "run"],
"type": "stdio"
}
}
}克劳德桌面 (%APPDATA%\Claude\claude_desktop_config.json):
{
"mcpServers": {
"MCP_DOCKER": {
"command": "docker",
"args": ["mcp", "gateway", "run"],
"type": "stdio"
}
}
}4.添加MCP服务器
在Docker桌面→ MCP工具包→ 目录,添加:
github-GitHub APIfilesystem-本地文件访问fetch-HTTP请求puppeteer-浏览器自动化memory-持久存储
______________________________________________________________________
🧪 测试IT
设置后,重新启动AI工具并询问:
“列出您可用的MCP工具”
你应该看看 MCP_DOCKER 使用网关提供的工具。
______________________________________________________________________
🚀 为什么这很重要
之前(传统MCP)
Agent → MCP Server 1 (10 tools) → context
Agent → MCP Server 2 (10 tools) → context
Agent → MCP Server 3 (10 tools) → context
Total: 30 tool definitions = ~15,000 tokens in context之后(Docker MCP网关)
Agent → Docker Gateway (searches tools on-demand) → context
Total: 1 gateway + selected tools = ~500 tokens代码执行工作流
更好的是:使用代码执行MCP来编排工具,而不会淹没上下文:
// This runs in a sandbox - only the summary returns to your AI
async function workflow(callTool) {
const data = await callTool("fetch", { url: "..." }); // 10KB stays in sandbox
const more = await callTool("fetch", { url: "..." }); // 10KB stays in sandbox
await callTool("filesystem.write", { path: "out.json", content: data });
return { summary: "Fetched 2 URLs, saved to out.json" }; // Only this goes to AI
}______________________________________________________________________
📚 资源
______________________________________________________________________
🤝 贡献
PR欢迎!这是一个社区工具,使MCP设置更容易。
______________________________________________________________________
📄 许可证
麻省理工学院-随心所欲。
