mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-28 15:40:04 +00:00
mcp: handle missing request IDs safely
This commit is contained in:
@@ -22,7 +22,8 @@ pub const resource_list = [_]protocol.Resource{
|
||||
};
|
||||
|
||||
pub fn handleList(server: *Server, req: protocol.Request) !void {
|
||||
try server.sendResult(req.id.?, .{ .resources = &resource_list });
|
||||
const id = req.id orelse return;
|
||||
try server.sendResult(id, .{ .resources = &resource_list });
|
||||
}
|
||||
|
||||
const ReadParams = struct {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -172,7 +172,8 @@ pub const tool_list = [_]protocol.Tool{
|
||||
|
||||
pub fn handleList(server: *Server, arena: std.mem.Allocator, req: protocol.Request) !void {
|
||||
_ = arena;
|
||||
try server.sendResult(req.id.?, .{ .tools = &tool_list });
|
||||
const id = req.id orelse return;
|
||||
try server.sendResult(id, .{ .tools = &tool_list });
|
||||
}
|
||||
|
||||
const GotoParams = struct {
|
||||
|
||||
Reference in New Issue
Block a user