From 4eb7f78b6b09168fe638b3f7d2b23e5d57c95312 Mon Sep 17 00:00:00 2001 From: logikonline Date: Wed, 15 Apr 2026 03:46:17 -0400 Subject: [PATCH] fix(mcp): restore Content-Length framing for MCP stdio Revert to LSP-style Content-Length framing for MCP stdio transport. Testing confirmed that MCP clients (Claude Code) do expect Content-Length headers, not raw NDJSON. The earlier NDJSON change was based on incorrect assumption about the protocol. --- main.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/main.go b/main.go index 810e9c2..95e7c05 100644 --- a/main.go +++ b/main.go @@ -246,10 +246,7 @@ func writeResponse(resp interface{}) { } func writeFramed(data []byte) { - // MCP stdio transport uses newline-delimited JSON (NDJSON), not LSP-style - // Content-Length framing. Claude Code and other MCP clients reject - // Content-Length headers on stdio, so we emit one JSON object per line. - fmt.Fprintf(os.Stdout, "%s\n", data) + fmt.Fprintf(os.Stdout, "Content-Length: %d\r\n\r\n%s", len(data), data) } func debugLog(format string, args ...interface{}) {