You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MCP stdio corruption: AutoCommit logs to stdout break JSON-RPC on PREVC phase completion (v1.1.1) #89
When running as the MCP stdio server (npx @dotcontext/mcp@latest), completing a PREVC phase corrupts the JSON-RPC stream and drops the connection. The MCP client fails with:
Client error: Unexpected token 'A', "[AutoCommit"... is not valid JSON
[V2 FSM] connection:transport_error: conn=connected,auth=valid -> conn=failed,auth=valid
This is the same class of bug as #74 (invalid JSON emitted on stdout). Likely relevant to the #73 / 1.1.2 release.
Root cause
MCP stdio uses stdout exclusively for JSON-RPC framing. In Node, console.info/console.log write to stdout; console.warn/console.error write to stderr.
dist/harness/domain/workflow/plans/planUpdateOrchestrator.js (method autoCommitPhase) logs two auto-commit messages via console.info, which land on stdout and corrupt the protocol:
console.info('[AutoCommit] No files to commit - skipping');
console.info(`[AutoCommit] Created commit ${commitResult.shortHash} for phase ${phaseId}`);
autoCommitOnPhaseComplete defaults to true and there is no env toggle, so this fires on every phase completion that stages .context/**. The console.warn/console.error calls in the same method are fine (stderr).
Reproduction
Configure the MCP server: npx -y @dotcontext/mcp@latest (stdio) in an MCP host (Cursor).
Init/link a PREVC plan in a git repo.
Advance/complete a phase so autoCommitPhase runs with staged .context/**.
Observe the client transport fail with Unexpected token 'A', "[AutoCommit"....
Timestamps of the failures line up exactly with the chore(plan): complete ... auto-commits.
Fix
Route these logs to stderr (they are diagnostics, not protocol data):
- console.info('[AutoCommit] No files to commit - skipping');+ console.error('[AutoCommit] No files to commit - skipping');
@@
- console.info(`[AutoCommit] Created commit ${commitResult.shortHash} for phase ${phaseId}`);+ console.error(`[AutoCommit] Created commit ${commitResult.shortHash} for phase ${phaseId}`);
Broader hardening suggestion
grep -rn "console\.(info|log)" dist shows ~231 occurrences. Most are CLI-only (safe), but any reachable from the MCP server request path is a latent stdout-corruption bug (e.g. sync/import/reverseSync services). Consider a lint rule banning console.log/console.info in server-reachable modules, or a logger that always targets stderr when running under the MCP transport.
Thanks for the thorough report — your diagnosis is right. MCP stdio reserves stdout for JSON-RPC, but autoCommitPhase in planUpdateOrchestrator.ts logged with console.info, which Node writes to stdout, so the client died with Unexpected token 'A', "[AutoCommit"... on PREVC phase completion. Same class of issue as #74.
Fix is up in #95: AutoCommit diagnostics now go to stderr, and the MCP stdio server installs a guard that redirects console.log/info/debug to stderr for the whole transport, with regression tests. It'll ship in the next release.
Activity
vinilana commentedon Nov 22, 2026
Thanks for the thorough report — your diagnosis is right. MCP stdio reserves stdout for JSON-RPC, but
autoCommitPhaseinplanUpdateOrchestrator.tslogged withconsole.info, which Node writes to stdout, so the client died withUnexpected token 'A', "[AutoCommit"...on PREVC phase completion. Same class of issue as #74.Fix is up in #95: AutoCommit diagnostics now go to stderr, and the MCP stdio server installs a guard that redirects
console.log/info/debugto stderr for the whole transport, with regression tests. It'll ship in the next release.