Windows: npm-shim spawnSync missing windowsHide flashes a console window on every MCP server launch

Open Beginner friendly
#3,054 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
86/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, node.js
Domain
cli, tooling

Research direction

Start by reading npm-shim.js and locating the spawnSync calls in the shim and extract(). Verify on Windows by launching codegraph.cmd serve --mcp from a hidden parent; done means neither launch path flashes a console and the stdio MCP server still starts normally.

Written by the indexing model from the issue text.

Description

Environment

  • OS: Windows 10/11
  • Install: npm i -g @colbymchenry/codegraph (v1.0.1)
  • Launched as a stdio MCP server via codegraph.cmd serve --mcp (registered in .mcp.json / agent MCP configs)

Symptom

Every time an MCP host launches the server, a console window briefly flashes whose title is the full path to ... ode_modules\@colbymchenry\codegraph-win32-x64 ode.exe. Hosts that spawn child processes hidden (e.g. Kimi Code / Kimi Work use windowsHide: true, which maps to CREATE_NO_WINDOW) run the entire launch chain console-less, so the final spawnSync in npm-shim.js creates a brand-new visible console for the bundled node.exe. The window reappears on every launch / reconnect.

Root cause

In npm-shim.js:

var res = childProcess.spawnSync(resolved.command, resolved.args, { stdio: 'inherit' });

windowsHide defaults to false in Node. On Windows, when the parent process has no console, a spawned console-subsystem child is allocated a new visible console, titled with the child's own image path - exactly what users observe.

Everything under the platform package's lib/dist already passes windowsHide: true (daemon spawn in mcp/index.js, liveness watchdog, all git calls). Only the npm shim's spawnSync, and the tar call in extract() on the self-heal path, miss it.

Suggested fix

var res = childProcess.spawnSync(resolved.command, resolved.args, { stdio: 'inherit', windowsHide: true });

(and add windowsHide: true to the spawnSync('tar', ...) in extract().)

Verification

Reproduced by launching codegraph.cmd serve --mcp from a parent created with CREATE_NO_WINDOW and polling top-level window titles (user32.EnumWindows at 200 ms - the window is transient):

  • Before the patch: a console window appears, titled exactly with the bundled node.exe path.
  • After adding windowsHide: true: no window at all; the server starts normally (proxy -> daemon -> liveness watchdog all healthy) and the stdio MCP transport is unaffected.

Notes

  • This affects every Windows MCP host that hides its child consoles (Kimi Code/Work, Claude Code, ...), so the fix belongs in the shim rather than per-host workarounds.
  • A local patch works, but any npm update -g @colbymchenry/codegraph overwrites it.
Dominant language
C
Stars
73.2k
Forks
4.7k
Avg merge
3h 46m
Merged PRs (30d)
510

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from colbymchenry/codegraph

All issues in colbymchenry/codegraph

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.