2
0

1 Commits

Author SHA1 Message Date
4b350fe967 fix(mcp): use Content-Length framing for all responses
All checks were successful
Release / build (amd64, linux) (push) Successful in 38s
Release / build (amd64, windows) (push) Successful in 38s
Release / build (arm64, darwin) (push) Successful in 44s
Release / build (amd64, darwin) (push) Successful in 1m4s
Release / build (arm64, linux) (push) Successful in 1m14s
Release / release (push) Successful in 21s
Adds writeFramed helper to send responses with HTTP-style Content-Length headers instead of raw JSON lines. Ensures compatibility with Claude Code which expects framed messages. Updates both main loop and writeResponse to use consistent framing.
2026-04-05 02:48:24 -04:00

10
main.go
View File

@@ -110,8 +110,8 @@ func main() {
debugLog("Response: %s", string(response)) debugLog("Response: %s", string(response))
// Write response to stdout // Write response to stdout with Content-Length framing
fmt.Println(string(response)) writeFramed(response)
} }
} }
@@ -211,7 +211,11 @@ func readMessage(reader *bufio.Reader) ([]byte, error) {
func writeResponse(resp interface{}) { func writeResponse(resp interface{}) {
data, _ := json.Marshal(resp) data, _ := json.Marshal(resp)
fmt.Println(string(data)) writeFramed(data)
}
func writeFramed(data []byte) {
fmt.Fprintf(os.Stdout, "Content-Length: %d\r\n\r\n%s", len(data), data)
} }
func debugLog(format string, args ...interface{}) { func debugLog(format string, args ...interface{}) {