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

Aperta Adatta ai principianti
#3,054 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
86/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js
Ambito
cli, tooling

Direzione di ricerca

Inizia leggendo npm-shim.js e individuando le chiamate a spawnSync nello shim e in extract(). Verifica su Windows avviando codegraph.cmd serve --mcp da un processo padre nascosto; il lavoro è completato quando nessuno dei due percorsi di avvio mostra una console e il server MCP stdio continua ad avviarsi normalmente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
C
Stelle
73.2k
Fork
4.7k
Merge medio
3h 39m
PR unite (30g)
528

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di colbymchenry/codegraph

Tutte le issue di colbymchenry/codegraph

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.