opencode
opencode copied to clipboard
[Bug] Web UI spawns duplicate MCP server waves during active session
Environment
- OpenCode version: 1.1.16
- OS: Linux (Contabo VPS)
- Access:
opencode web --port 4096via Cloudflare tunnel
Bug Description
The Web UI spawns multiple complete waves of all configured MCP servers during a single session, causing duplicate tool responses (e.g., speak tool speaks twice).
Evidence
Process snapshot showing duplicates:
Web UI (PID 1103894) children:
WAVE 1 (08:49:33):
1104065 memory-mcp
1104066 tunnel-mcp
1104067 speak-mcp ← First instance
1104073 port-manager-mcp
...
WAVE 2 (10:33:58 - 1hr 44min later):
1110223 memory-mcp ← Duplicate!
1110224 tunnel-mcp ← Duplicate!
1110225 speak-mcp ← Duplicate!
1110226 port-manager-mcp
...
All 8 MCP types spawned twice, totaling 16 processes from one Web UI instance.
Steps to Reproduce
- Start
opencode web --port 4096 - Access via browser, start a conversation
- Wait ~30 minutes or make additional requests
- Check:
pstree -p $(pgrep -f "opencode web") - Observe: Multiple instances of each MCP type
Expected Behavior
Each MCP server should spawn exactly once per Web UI instance.
Actual Behavior
MCPs spawn in waves (observed 2+ waves), causing:
- Duplicate tool responses (speak speaks twice)
- Resource waste (double memory/CPU usage)
- Confusion about which instance handles requests
Workaround
Periodic cleanup script that kills duplicate MCPs (keeping lowest PID).
Related Issues
- #6633 - MCP not terminated after session (different: orphans on exit)
- #7261 - MCP orphans after crash (different: our duplicates spawn while running)