kilocode icon indicating copy to clipboard operation
kilocode copied to clipboard

MCP servers are spawned 12–17 times per start since 7.7.3

Open ricky-riccardo opened this issue 2 months ago • 1 comments

Description

Summary

On every start, kilo serve builds the session context repeatedly — 12 to 17 times at ~5.5 s intervals — before the session finally attaches. Each of those cycles initialises the configured MCP servers, and no previous instance is terminated, so every McpLocalConfig server process survives and accumulates.

Observed on a configuration with 14 local MCP servers: 223 processes, ~16 GB resident. Reduced to 6 servers: 95 processes, 6.9 GB, where a single start would need 11.

Impact

  • Memory exhaustion: free physical memory dropped to 1.9 GB of 31.9 GB.
  • Servers that guard against double starts are broken by this. A wrapper that runs taskkill /F /T /IM mcp-telegram.exe before starting kills the instance the client had just connected to, in the next cycle. The server runs and advertises its full tool list, but the tools do not appear to the model.

Evidence 1 — the cycle count changes with 7.7.3

Cycle count per boot, from ~/.local/share/kilo/log/<timestamp>.log, counting session.turn.open subscribing:

Log Version Cycles
2026-09-16 19:30 7.7.2 1
2026-09-17 05:41 7.7.2 1
2026-09-18 06:53 7.7.2 0
2026-09-18 06:55 7.7.3 13
2026-09-19 10:33 7.7.5 1
2026-09-19 10:34 7.7.5 14
2026-09-20 09:19 7.7.5 14
2026-09-20 19:45 7.7.5 14
2026-09-20 21:30 7.7.5 17
2026-09-20 22:42 7.7.5 14
2026-09-20 23:26 7.7.5 14

The 06:53 and 06:55 logs are two minutes apart on the same machine with an unchanged configuration; the only difference is the extension version. Before 7.7.3: three starts, one cycle each. After: 6 of 7 starts show 13–17 cycles.

Note the one start at 10:33 with a single cycle on 7.7.5 — the failure is intermittent, which suggests a race rather than a configuration error.

Evidence 2 — process measurement

Boot at 23:26, after which the count was stable:

parent kilo.exe   finance    12
parent kilo.exe   firecrawl  12
parent kilo.exe   github     12
parent kilo.exe   markitdown 12  (+ 12 child processes each)
parent kilo.exe   obsidian   12
parent kilo.exe   telegram    1  (start wrapper kills previous instances)

In the same window, with the Cline extension running on the same machine, Cline started each of its servers exactly once (process parent Code.exe). The same server binaries, the same configuration values — one client starts each server once, the other starts each server 12–17 times.

Evidence 3 — the loop is independent of the other extension

Disabling Cline and reloading changed nothing:

Boot Cline Cycles
19.09. 10:34 enabled 14
20.09. 22:42 enabled 14
20.09. 23:26 disabled 14

Log excerpt

INFO  2026-09-20T23:26:42 +1422ms service=bus type=session.turn.open subscribing
WARN  2026-09-20T23:26:42  +437ms service=kilo-sessions error=Error: attachRemoteSession: no remote connection attached-state heartbeat failed
INFO  2026-09-20T23:26:50 +5695ms service=bus type=session.turn.open subscribing
INFO  2026-09-20T23:26:51 +1305ms service=bus type=session.turn.open subscribing
INFO  2026-09-20T23:26:58 +6526ms service=bus type=session.turn.open subscribing
...

Each cycle also emits session.turn.close subscribing, memory.status and memory.updated. Nothing else appears — there is no log line that states why a new session context is being created.

Expected behaviour

Each configured MCP server is started once per application start.

Environment

  • Kilo Code 7.7.5 (kilocode.kilo-code-7.7.5-win32-x64), also observed on 7.7.3
  • Windows, VS Code, single workspace folder
  • Configuration: 6 McpLocalConfig entries, type: "local", stdio, no cwd

What could not be determined from the logs

logLevel: "DEBUG" in the configuration file is accepted (the config validates) but produces zero level=DEBUG lines in the log files; all lines stay at level=INFO. If there is a way to make the session bootstrap and MCP initialisation visible in a log, that hint alone would be worth adding to the documentation.

Plugins

No response

Kilo version

7.7.5

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

No response

ricky-riccardo avatar Sep 21 '26 00:09 ricky-riccardo

This looks addressed by #14809 (merged Oct 9): interrupted startup lookups now expire instead of being cached, and already-started MCP servers are cleaned up when a startup is interrupted. That matches the repeated ~5.5s cycles in your logs. Could you retry on 7.8.x and check the process count?

Beehtrix avatar Nov 17 '26 02:11 Beehtrix