Skip to content

Lightpanda: the headless browser designed for AI and automation

Merge branch 'main' into agent

Adrià Arrufat314e3c58ea62
diff --cc src/mcp/router.zig
index 286044343,ea5732e69..64b3206ed
--- a/src/mcp/router.zig
+++ b/src/mcp/router.zig
@@@ -88,20 -81,28 +88,20 @@@ pub fn handleMessage(server: anytype, a
}
}
-fn handleInitialize(server: *Server, req: protocol.Request) !void {
- const id = req.id orelse return;
- const result: protocol.InitializeResult = .{
- .protocolVersion = @tagName(protocol.Version.default),
- .capabilities = .{
- .resources = .{},
- .tools = .{},
- },
- .serverInfo = .{
- .name = "lightpanda",
- .version = "0.1.0",
- },
- };
-
- try server.sendResult(id, result);
+fn handleOptional(server: anytype, req: protocol.Request, comptime method: []const u8, args: anytype) !void {
+ if (@hasDecl(@TypeOf(server.*), method)) {
+ try @call(.auto, @field(@TypeOf(server.*), method), .{server} ++ args);
+ } else if (req.id) |id| {
+ try server.sendError(id, .MethodNotFound, "Method not supported");
+ }
}
-fn handlePing(server: *Server, req: protocol.Request) !void {
+fn handlePing(server: anytype, req: protocol.Request) !void {
const id = req.id orelse return;
- try server.sendResult(id, .{});
+ try server.sendResult(id, struct {}{});
}
+const Server = @import("Server.zig");
const testing = @import("../testing.zig");
test "MCP.router - handleMessage - synchronous unit tests" {