CLI hub mode: MCP server processes are never stopped after /clear or quitting; they accumulate until the hub daemon exits
Cline Surface
CLI
Cline Version
3.0.65
Beta version
- I am using a beta version of Cline
What happened?
In the CLI's hub mode, a session's stdio MCP server processes are never stopped when you leave that session, whether by /clear or by quitting the TUI. Each new session starts its own set of MCP servers, and the old ones stay alive under the --cline-hub-daemon process until the hub daemon itself exits.
With Serena configured (it also spawns clangd and lua-language-server), about a day and a half of normal use left 10 Serena instances plus their language servers running, while only 2 sessions were actually in use.
Expected: when a session is cleared or abandoned, or its last client detaches, the hub stops that session's runtime and its MCP servers. At minimum, an idle session should be reaped after a while.
Cause, from reading the 3.0.65 bundle (@cline/core/dist/hub/daemon/entry.js and the CLI binary):
- MCP servers are loaded per session runtime. They are disposed only by the runtime's
shutdown, which is called fromshutdownSession/releaseSessionRuntime. - Those run only for
session.delete(deleteSession→stopSession), a failed session, a finished non-interactive run (finalizeSingleRun), or the hub stopping (sessionHost.dispose("hub_server_stop")). - Interactive turns end in
completeInteractiveTurn, which never shuts the session down. - In hub mode, the CLI client's
stopSession(),stopRuntimeSession()anddispose()all just sendsession.detach, and the hub has nosession.stopcommand. - The hub's
session.detachhandler anddetachClientFromSessions()(on client disconnect) only remove the participant fromsessionState. They never touch the runtime. - On
/clear, the hub log shows only asession.createfor the new session. Nothing is sent for the previous one. - I found no idle-session reaper in the hub.
So cli_interactive_shutdown / "stop session" in hub mode detaches but never stops anything. The MCP child processes, plus any language servers they started, live as long as the hub daemon does.
Steps to reproduce
- Configure any stdio MCP server in
~/.cline/data/settings/cline_mcp_settings.json, e.g.{"transport":{"type":"stdio","command":"uvx","args":["mcp-server-time"]}}. - Start
cline(interactive TUI, hub mode) and send any prompt so the session starts. - Run
/clearand send another prompt. Repeat a few times, and/or quit and restartcline. pgrep -af <mcp server command>shows one server process per session ever created since the hub started, all still running under thecline --cline-hub-daemonprocess.- Stopping the hub daemon is the only thing that frees them.
This doesn't depend on the model or provider (the bug is in session lifecycle, not in model output).
Provider/Model
Local OpenAI-compatible endpoint via LiteLLM. The bug doesn't depend on the model.
Diagnostics
cline --version → 3.0.65, Node v24.20.0
System Information
OS: Pop!_OS 24.04 LTS (Linux 7.1.5)
Source: cline/cline