Add query_zones tool for auditing copper pours (#174)

query_traces silently omits PCB_ZONE_T objects, so layer-usage audits
miss power planes and GND pours entirely. query_zones complements it by
iterating board.Zones() and returning each zone's net, layers, priority,
fill state, min thickness, bounding box, and filled area, with the same
net/layer/boundingBox filter surface as query_traces.
This commit is contained in:
kevargaso
2026-05-18 13:40:18 -05:00
committed by GitHub
parent 4e845f24ce
commit 40d6d6bba1
5 changed files with 182 additions and 0 deletions

View File

@@ -225,6 +225,40 @@ export function registerRoutingTools(server: McpServer, callKicadScript: Functio
},
);
// Query zones tool
server.tool(
"query_zones",
"Query copper zones (filled pours) on the board with optional filters by net, layer, or bounding box. Returns zone net, layers, priority, fill state, and bounding box. Useful for auditing power planes and GND pours that query_traces does not include.",
{
net: z.string().optional().describe("Filter by net name"),
layer: z
.string()
.optional()
.describe("Filter by layer name (matches zones that include this layer)"),
boundingBox: z
.object({
x1: z.number(),
y1: z.number(),
x2: z.number(),
y2: z.number(),
unit: z.enum(["mm", "inch"]).optional(),
})
.optional()
.describe("Filter to zones whose bounding box overlaps this region"),
},
async (args: any) => {
const result = await callKicadScript("query_zones", args);
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2),
},
],
};
},
);
// Get nets list tool
server.tool(
"get_nets_list",