openclaw - 💡(How to fix) Fix MCP stdio server processes not properly cleaned up (process leak) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#78304Fetched 2026-05-07 03:38:31
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
2
Timeline (top)
closed ×1commented ×1

When using MCP servers configured in stdio mode (e.g., MemPalace mempalace-mcp.exe), the Gateway creates a new process for each MCP call but does not properly terminate them after use. This causes process accumulation over time.

Root Cause

When using MCP servers configured in stdio mode (e.g., MemPalace mempalace-mcp.exe), the Gateway creates a new process for each MCP call but does not properly terminate them after use. This causes process accumulation over time.

Fix Action

Workaround

A cleanup script that kills old mempalace-mcp.exe processes while keeping the newest one:

$processes = Get-Process -Name "mempalace-mcp" | Sort-Object StartTime
if ($processes.Count -gt 1) {
    $toKeep = $processes[-1]
    $processes[0..($processes.Count - 2)] | Stop-Process -Force
}

Code Example

{
  "mcp": {
    "servers": {
      "mempalace": {
        "command": "C:\\path\\to\\mempalace-mcp.exe",
        "args": ["--palace", "C:\\path\\to\\palace"],
        "env": { "PYTHONUTF8": "1" }
      }
    }
  }
}

---

$processes = Get-Process -Name "mempalace-mcp" | Sort-Object StartTime
if ($processes.Count -gt 1) {
    $toKeep = $processes[-1]
    $processes[0..($processes.Count - 2)] | Stop-Process -Force
}
RAW_BUFFERClick to expand / collapse

Description

When using MCP servers configured in stdio mode (e.g., MemPalace mempalace-mcp.exe), the Gateway creates a new process for each MCP call but does not properly terminate them after use. This causes process accumulation over time.

Environment

  • OS: Windows_NT 10.0.26200 (x64)
  • OpenClaw version: [please fill in]
  • Node.js: v22.21.1

Configuration

{
  "mcp": {
    "servers": {
      "mempalace": {
        "command": "C:\\path\\to\\mempalace-mcp.exe",
        "args": ["--palace", "C:\\path\\to\\palace"],
        "env": { "PYTHONUTF8": "1" }
      }
    }
  }
}

Expected Behavior

  • Each MCP stdio process should terminate after completing its call
  • Only the currently active process should remain running

Actual Behavior

  • Multiple mempalace-mcp.exe processes accumulate over time
  • Processes are created at regular intervals (approximately every 30 minutes based on usage)
  • Old processes are never terminated, only new ones are created
  • Memory usage grows linearly with process count (~7MB per process)

Process List Example

PIDStarted
3090405/06/2026 09:17:38
750405/06/2026 09:19:34
3392405/06/2026 09:20:03
...(20+ processes after several hours)

Impact

  • Resource leak: ~7MB per leaked process
  • After 4+ hours of usage: 20+ processes consuming ~140MB memory
  • Each process remains zombie-style, not doing anything

Investigation Notes

  • This is NOT a MemPalace issue - MemPalace MCP server is designed for stdio mode only
  • All leaked processes have the same parent: QClaw.exe (the OpenClaw Gateway)
  • The issue appears to be in how OpenClaw manages stdio MCP subprocess lifecycle

Suggested Fix

  1. Ensure stdio MCP processes are properly terminated after each call
  2. Implement process pool management for frequently-used MCP servers
  3. Add monitoring/logging for MCP process lifecycle events

Workaround

A cleanup script that kills old mempalace-mcp.exe processes while keeping the newest one:

$processes = Get-Process -Name "mempalace-mcp" | Sort-Object StartTime
if ($processes.Count -gt 1) {
    $toKeep = $processes[-1]
    $processes[0..($processes.Count - 2)] | Stop-Process -Force
}

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix MCP stdio server processes not properly cleaned up (process leak) [1 comments, 2 participants]