Skip to content

Commit eda9e6b

Browse files
authored
fix: update MCP test to use newline-delimited JSON-RPC (#102)
Patchloom v0.1.2+ uses raw newline-delimited JSON-RPC for its MCP server, not Content-Length framing. The test was sending Content-Length headers and asserting Content-Length in the response, which no longer matches the CLI behavior. Updated to send a raw JSON line and assert on parsed JSON-RPC response fields (jsonrpc version, id, result.serverInfo). Closes #101 Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent 6cf1a64 commit eda9e6b

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

test/unit/patchloomCli.test.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ describe("patchloom CLI integration", async () => {
440440
let stdout = "";
441441
child.stdout!.on("data", (data: Buffer) => { stdout += data.toString(); });
442442

443-
// Send a JSON-RPC initialize request using the MCP wire format
443+
// Send a JSON-RPC initialize request as newline-delimited JSON
444+
// (patchloom v0.1.2+ uses raw JSON-RPC lines, not Content-Length framing)
444445
const initRequest = JSON.stringify({
445446
jsonrpc: "2.0",
446447
id: 1,
@@ -451,8 +452,7 @@ describe("patchloom CLI integration", async () => {
451452
clientInfo: { name: "test", version: "0.0.1" }
452453
}
453454
});
454-
const header = `Content-Length: ${Buffer.byteLength(initRequest)}\r\n\r\n`;
455-
child.stdin!.write(header + initRequest);
455+
child.stdin!.write(initRequest + "\n");
456456

457457
// Wait for the server to respond (it needs to start the tokio runtime)
458458
const deadline = Date.now() + 5000;
@@ -462,10 +462,15 @@ describe("patchloom CLI integration", async () => {
462462

463463
child.kill();
464464

465-
// Should have received a JSON-RPC response with Content-Length header
465+
// Should have received a newline-delimited JSON-RPC response
466466
assert.ok(stdout.length > 0, "mcp-server should produce output");
467-
assert.match(stdout, /Content-Length/i, "response should use Content-Length framing");
468-
assert.match(stdout, /jsonrpc/, "response body should be JSON-RPC");
467+
const response = JSON.parse(stdout.trim().split("\n")[0]) as Record<string, unknown>;
468+
assert.equal(response.jsonrpc, "2.0", "response should be JSON-RPC 2.0");
469+
assert.equal(response.id, 1, "response id should match request id");
470+
const result = response.result as Record<string, unknown>;
471+
assert.ok(result, "response should have a result (not an error)");
472+
const serverInfo = result.serverInfo as Record<string, string>;
473+
assert.ok(serverInfo?.name, "response should include serverInfo.name");
469474
});
470475

471476
test("MCP config written for real binary is structurally valid", async () => {

0 commit comments

Comments
 (0)