summaryrefslogtreecommitdiffhomepage
path: root/packages/mcp/src/rpc.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/mcp/src/rpc.test.ts')
-rw-r--r--packages/mcp/src/rpc.test.ts5
1 files changed, 2 insertions, 3 deletions
diff --git a/packages/mcp/src/rpc.test.ts b/packages/mcp/src/rpc.test.ts
index dc295af..34b6af4 100644
--- a/packages/mcp/src/rpc.test.ts
+++ b/packages/mcp/src/rpc.test.ts
@@ -87,11 +87,10 @@ describe("JsonRpcClient", () => {
client.request("c");
expect(written.length).toBe(3);
- // Extract JSON body from Content-Length framed messages
+ // Outgoing messages are newline-delimited JSON (current MCP spec framing).
const parse = (bytes: Uint8Array): { id: number } => {
const text = new TextDecoder().decode(bytes);
- const bodyStart = text.indexOf("\r\n\r\n") + 4;
- return JSON.parse(text.slice(bodyStart)) as { id: number };
+ return JSON.parse(text.replace(/\r?\n$/, "")) as { id: number };
};
const msg1 = parse(written[0]);
const msg2 = parse(written[1]);