fix: project-local library resolution + copy_routing_pattern geometric fallback + TypeScript tool

- fix: DynamicSymbolLoader reads project sym-lib-table before global dirs
  add_schematic_component now finds symbols from project-local .kicad_sym files
  project_path derived automatically from schematic file path

- fix: place_component reloads FootprintLibraryManager with project_path
  new boardPath parameter passed to place_component tool (TypeScript + Python)
  _handle_place_component wrapper recreates LibraryManager per project

- fix: copy_routing_pattern geometric fallback when pads have no nets
  primary filter: net-based (when pads are assigned to nets)
  fallback: bounding box of source footprint pads +5mm tolerance
  filterMethod field in response indicates which mode was used

- feat: register copy_routing_pattern as MCP tool in routing.ts
  sourceRefs, targetRefs, includeVias, traceWidth parameters

Live tested: ESP32 + 2x TMC2209 in Test3 project
  13 traces U2 routed, copy_routing_pattern copied all 13 to U3
  offset Y+30mm correct, 26 total traces verified
This commit is contained in:
Tom
2026-03-01 14:42:22 +01:00
parent 2b38796409
commit b33d6e22fd
6 changed files with 186 additions and 9 deletions

View File

@@ -57,6 +57,10 @@ export function registerComponentTools(
.string()
.optional()
.describe("Optional layer (e.g., 'F.Cu', 'B.SilkS')"),
boardPath: z
.string()
.optional()
.describe("Path to the .kicad_pcb file required when using project-local footprint libraries"),
},
async ({
componentId,
@@ -66,6 +70,7 @@ export function registerComponentTools(
footprint,
rotation,
layer,
boardPath,
}) => {
logger.debug(
`Placing component: ${componentId} at ${position.x},${position.y} ${position.unit}`,
@@ -78,6 +83,7 @@ export function registerComponentTools(
footprint,
rotation,
layer,
boardPath,
});
return {

View File

@@ -321,4 +321,39 @@ export function registerRoutingTools(
};
},
);
// Copy routing pattern tool
server.tool(
"copy_routing_pattern",
"Copy routing pattern (traces and vias) from a group of source components to a matching group of target components. The offset is calculated automatically from the position difference between the first source and first target component. Useful for replicating routing between identical circuit blocks.",
{
sourceRefs: z
.array(z.string())
.describe("References of the source components (e.g. ['U1', 'R1', 'C1'])"),
targetRefs: z
.array(z.string())
.describe(
"References of the target components in same order as sourceRefs (e.g. ['U2', 'R2', 'C2'])",
),
includeVias: z
.boolean()
.optional()
.describe("Also copy vias (default: true)"),
traceWidth: z
.number()
.optional()
.describe("Override trace width in mm (default: keep original width)"),
},
async (args: any) => {
const result = await callKicadScript("copy_routing_pattern", args);
return {
content: [
{
type: "text",
text: JSON.stringify(result, null, 2),
},
],
};
},
);
}