mcp: handle missing request IDs safely

This commit is contained in:
Adrià Arrufat
2026-03-27 11:34:06 +09:00
parent c8d8ca5e94
commit de32e5cf34
3 changed files with 6 additions and 3 deletions

View File

@@ -80,6 +80,7 @@ pub fn handleMessage(server: *Server, arena: std.mem.Allocator, msg: []const u8)
}
fn handleInitialize(server: *Server, req: protocol.Request) !void {
const id = req.id orelse return;
const result = protocol.InitializeResult{
.protocolVersion = "2025-11-25",
.capabilities = .{
@@ -92,7 +93,7 @@ fn handleInitialize(server: *Server, req: protocol.Request) !void {
},
};
try server.sendResult(req.id.?, result);
try server.sendResult(id, result);
}
fn handlePing(server: *Server, req: protocol.Request) !void {