[Bug] MCP processes not terminated after session ends #4080

Open
opened 2026-02-16 17:42:32 -05:00 by yindo · 1 comment
Owner

Originally created by @chadongmin on GitHub (Jan 2, 2026).

Originally assigned to: @rekram1-node on GitHub.

Environment

  • OS: macOS
  • opencode version: latest

Bug Description

MCP processes spawned by opencode are not terminated when the session ends. Over time, zombie processes accumulate and require manual cleanup.

Steps to Reproduce

  1. Start opencode session
  2. Use any MCP tool (e.g., interactive-review, postgresql-mcp)
  3. Exit opencode session (or start a new session)
  4. Check running processes: ps aux | grep mcp

Expected Behavior

MCP processes should be terminated when the opencode session ends.

Actual Behavior

MCP processes remain running indefinitely after session ends.

# Example: Multiple zombie processes from different sessions
trevari  5810  5:18PM  node postgresql-mcp-server/build/index.js
trevari  5809  5:18PM  node postgresql-mcp-server/build/index.js
trevari  5808  5:18PM  uv run interactive-review/mcp-server server.py
trevari  91128 11:45AM node postgresql-mcp-server/build/index.js  # 7 hours old
trevari  91127 11:45AM node postgresql-mcp-server/build/index.js  # 7 hours old

Workaround

Manual cleanup required:

pkill -f "interactive-review"
pkill -f "postgresql-mcp"

Additional Context

  • Confirmed this is NOT an issue with individual MCP servers
  • Multiple MCP types (interactive-review, postgresql-mcp) exhibit the same behavior
  • Different TTY sessions (ttys000, ttys004) have orphaned processes
Originally created by @chadongmin on GitHub (Jan 2, 2026). Originally assigned to: @rekram1-node on GitHub. ## Environment - OS: macOS - opencode version: latest ## Bug Description MCP processes spawned by opencode are not terminated when the session ends. Over time, zombie processes accumulate and require manual cleanup. ## Steps to Reproduce 1. Start opencode session 2. Use any MCP tool (e.g., interactive-review, postgresql-mcp) 3. Exit opencode session (or start a new session) 4. Check running processes: `ps aux | grep mcp` ## Expected Behavior MCP processes should be terminated when the opencode session ends. ## Actual Behavior MCP processes remain running indefinitely after session ends. ``` # Example: Multiple zombie processes from different sessions trevari 5810 5:18PM node postgresql-mcp-server/build/index.js trevari 5809 5:18PM node postgresql-mcp-server/build/index.js trevari 5808 5:18PM uv run interactive-review/mcp-server server.py trevari 91128 11:45AM node postgresql-mcp-server/build/index.js # 7 hours old trevari 91127 11:45AM node postgresql-mcp-server/build/index.js # 7 hours old ``` ## Workaround Manual cleanup required: ```bash pkill -f "interactive-review" pkill -f "postgresql-mcp" ``` ## Additional Context - Confirmed this is NOT an issue with individual MCP servers - Multiple MCP types (interactive-review, postgresql-mcp) exhibit the same behavior - Different TTY sessions (ttys000, ttys004) have orphaned processes
Author
Owner

@github-actions[bot] commented on GitHub (Jan 2, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #5525: git bash.exe processes on Windows get orphaned (similar process orphaning on Windows)
  • #3057: Provide a way to stop all running scripts when OpenCode is interrupted (related to stopping spawned processes)
  • #5734: Subagent sessions accumulate without cleanup option (related to session/process cleanup)

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 2, 2026): This issue might be a duplicate of existing issues. Please check: - #5525: git bash.exe processes on Windows get orphaned (similar process orphaning on Windows) - #3057: Provide a way to stop all running scripts when OpenCode is interrupted (related to stopping spawned processes) - #5734: Subagent sessions accumulate without cleanup option (related to session/process cleanup) Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4080