From f059b6f458557d3e3312a00189a6da3cbfc88006 Mon Sep 17 00:00:00 2001 From: logikonline Date: Wed, 15 Apr 2026 02:20:20 -0400 Subject: [PATCH] fix(mcp): use NDJSON instead of LSP framing for MCP stdio Replace Content-Length framing with newline-delimited JSON (NDJSON) for MCP stdio transport. MCP clients like Claude Code expect one JSON object per line, not LSP-style Content-Length headers. The previous framing caused clients to reject responses. --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 73a0fac..d5dca2c 100644 --- a/main.go +++ b/main.go @@ -215,7 +215,10 @@ func writeResponse(resp interface{}) { } func writeFramed(data []byte) { - fmt.Fprintf(os.Stdout, "Content-Length: %d\r\n\r\n%s", len(data), data) + // 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) } func debugLog(format string, args ...interface{}) {