我改进了Claude的MCP-CLI实验性MCP修复 – 在50次调用中实现了18倍的速度提升。
Claude Code 有一个实验性的 'mcp-cli' 工具,可以从 bash 中调用 MCP 服务器(如 Google Workspace、GitHub 等)。
问题:默认情况下,它是顺序执行的。我的工作流程涉及 50 多个 MCP 调用。这导致了 191 秒的延迟——在 Claude 能够合成任何内容之前,等待时间超过 3 分钟。
我发现可以在单个 Bash 工具调用中协调并行调用:
```
mcp-cli call google/get_events '{}' > /tmp/cal.json &
mcp-cli call google/list_tasks '{}' > /tmp/tasks.json &
mcp-cli call github/list_issues '{}' > /tmp/issues.json &
wait
```
不明显的部分是:这之所以有效,是因为后台作业(&)继承了父 shell 的环境。Claude Code 的会话上下文——包括 MCP 端点文件——仍然可访问。
如果你启动一个新的子 shell(bash -c 'mktemp -d; mcp-cli...'),上下文会中断,出现“找不到 MCP 端点文件”的错误。这是我花了一段时间才弄明白的陷阱。
基准测试(2026 年 1 月验证):
```
2 次调用: 7.6s → 3.8s (2 倍)
10 次调用: 38s → 3.0s (13 倍)
20 次调用: 76s → 4.9s (16 倍)
50 次调用: 191s → 10.3s (18 倍)
```
我将其打包成一个自包含的工具包:
- CLAUDE.md 片段,包含使用说明
- .claude/rules/ 模式(禁止/必需示例)
- 提醒并行模式的建议钩子
- 项目或用户级别的安装脚本
https://github.com/AIntelligentTech/claude-code-mcp-cli-parallel-godmode
需要设置 ENABLE_EXPERIMENTAL_MCP_CLI=true(mcp-cli 仍然是实验性的)。
我很好奇其他人是否也遇到了类似的瓶颈,或者是否发现了其他针对 MCP 密集型 Claude Code 工作流程的优化模式。
查看原文
Claude Code has an experimental 'mcp-cli' for invoking MCP servers (Google Workspace, GitHub, etc.) from bash.<p>Problem: it runs sequentially by default. My workflow hits 50+ MCP calls. That was 191 seconds—over 3 minutes waiting before Claude could synthesize anything.<p>I discovered you can orchestrate parallel calls within a single Bash tool invocation:<p><pre><code> mcp-cli call google/get_events '{}' > /tmp/cal.json &
mcp-cli call google/list_tasks '{}' > /tmp/tasks.json &
mcp-cli call github/list_issues '{}' > /tmp/issues.json &
wait
</code></pre>
The non-obvious part: this only works because background jobs (&) inherit the parent shell environment. Claude Code's session context—including MCP endpoint files—stays accessible.<p>If you spawn a new subshell (bash -c 'mktemp -d; mcp-cli...'), context breaks with "MCP endpoint file not found." That was the gotcha that took a while to figure out.<p>Benchmarks (verified January 2026):<p><pre><code> 2 calls: 7.6s → 3.8s (2x)
10 calls: 38s → 3.0s (13x)
20 calls: 76s → 4.9s (16x)
50 calls: 191s → 10.3s (18x)
</code></pre>
I packaged this into a self-contained toolkit:<p>- CLAUDE.md snippet with usage instructions
- .claude/rules/ patterns (FORBIDDEN/REQUIRED examples)
- Advisory hook that reminds about parallel patterns
- Install script for project or user-level setup<p>https://github.com/AIntelligentTech/claude-code-mcp-cli-parallel-godmode<p>Requires ENABLE_EXPERIMENTAL_MCP_CLI=true (the mcp-cli is still experimental).<p>Curious if others are hitting similar bottlenecks or have found other optimisation patterns for MCP-heavy Claude Code workflows.