Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f059b6f458 | |||
| 4b350fe967 |
13
main.go
13
main.go
@@ -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,14 @@ 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) {
|
||||||
|
// 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{}) {
|
func debugLog(format string, args ...interface{}) {
|
||||||
|
|||||||
Reference in New Issue
Block a user