From a52c45f309930413a20416c7e9a582a1fe8c06cb Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Tue, 9 Jun 2026 17:40:08 +0200 Subject: [PATCH] mcp: ping's response must be an object not an array The array returned breaks the mcp keep alive feature implemented by the official mcp client in Go. --- src/mcp/Server.zig | 2 +- src/mcp/router.zig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mcp/Server.zig b/src/mcp/Server.zig index 9a5a285e..32781010 100644 --- a/src/mcp/Server.zig +++ b/src/mcp/Server.zig @@ -137,5 +137,5 @@ test "MCP.Server - Integration: ping request returns an empty result" { try router.processRequests(server, &in_reader); - try testing.expectJson(.{ .jsonrpc = "2.0", .id = "ping-1", .result = .{} }, out_alloc.writer.buffered()); + try testing.expectJson(.{ .jsonrpc = "2.0", .id = "ping-1", .result = struct {}{} }, out_alloc.writer.buffered()); } diff --git a/src/mcp/router.zig b/src/mcp/router.zig index d3feec5f..ea5732e6 100644 --- a/src/mcp/router.zig +++ b/src/mcp/router.zig @@ -100,7 +100,7 @@ fn handleInitialize(server: *Server, req: protocol.Request) !void { fn handlePing(server: *Server, req: protocol.Request) !void { const id = req.id orelse return; - try server.sendResult(id, .{}); + try server.sendResult(id, struct {}{}); } const testing = @import("../testing.zig"); @@ -131,7 +131,7 @@ test "MCP.router - handleMessage - synchronous unit tests" { try handleMessage(server, aa, \\{"jsonrpc":"2.0","id":2,"method":"ping"} ); - try testing.expectJson(.{ .jsonrpc = "2.0", .id = 2, .result = .{} }, out_alloc.writer.buffered()); + try testing.expectJson(.{ .jsonrpc = "2.0", .id = 2, .result = struct {}{} }, out_alloc.writer.buffered()); out_alloc.writer.end = 0; // 3. Tools list