mcp: use declarative static definitions for tools and resources

This commit is contained in:
Adrià Arrufat
2026-03-01 21:56:48 +09:00
parent 952dfbef36
commit e9c36fd6f8
4 changed files with 108 additions and 117 deletions

View File

@@ -6,11 +6,26 @@ const log = lp.log;
const protocol = @import("protocol.zig");
const Server = @import("Server.zig");
pub const resource_list = [_]protocol.Resource{
.{
.uri = "mcp://page/html",
.name = "Page HTML",
.description = "The serialized HTML DOM of the current page",
.mimeType = "text/html",
},
.{
.uri = "mcp://page/markdown",
.name = "Page Markdown",
.description = "The token-efficient markdown representation of the current page",
.mimeType = "text/markdown",
},
};
pub fn handleList(server: *Server, req: protocol.Request) !void {
const result = struct {
resources: []const protocol.Resource,
}{
.resources = server.resources,
.resources = &resource_list,
};
try server.sendResult(req.id.?, result);