feat: add get_net_at_point tool for coordinate-based net lookup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Eugene Mikhantyev
2026-04-12 15:29:46 +01:00
parent 5f3c20d308
commit e826cf3d32
5 changed files with 564 additions and 0 deletions

View File

@@ -1425,6 +1425,46 @@ Note: operates on .kicad_sch files only. To modify a PCB footprint use edit_comp
},
);
server.tool(
"get_net_at_point",
"Returns the net name at a given (x, y) coordinate in a schematic, or null if no net label " +
"or wire endpoint is present at that position. Faster than get_pin_net when you only need " +
"the net name at a known coordinate and don't need pin traversal.",
{
schematicPath: z.string().describe("Path to the schematic file (.kicad_sch)"),
x: z.number().describe("X coordinate in mm"),
y: z.number().describe("Y coordinate in mm"),
},
async (args: { schematicPath: string; x: number; y: number }) => {
const result = await callKicadScript("get_net_at_point", args);
if (result.success) {
const netName = result.net_name ?? null;
const source = result.source ?? null;
const pos = result.position;
return {
content: [
{
type: "text",
text:
`Net at (${pos?.x ?? args.x}, ${pos?.y ?? args.y}): ` +
(netName !== null ? netName : "(none)") +
(source ? ` [source: ${source}]` : ""),
},
],
};
} else {
return {
content: [
{
type: "text",
text: `Failed to get net at point: ${result.message || "Unknown error"}`,
},
],
};
}
},
);
server.tool(
"get_pin_net",
"Returns the net name and all connected pins for a component pin (reference + pin number) " +