feat: add unit parameter to add_schematic_component for multi-unit symbols

Allows placing a specific unit (A=1, B=2, C=3, …) of a multi-unit KiCad
symbol rather than always defaulting to unit 1. Required for quad
optocouplers, dual op-amps, and other multi-unit parts where each channel
must be placed independently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Samuel Price
2026-04-19 10:11:15 -04:00
parent 8ace3e4d24
commit 78e3b8860a
3 changed files with 17 additions and 2 deletions

View File

@@ -49,6 +49,12 @@ export function registerSchematicTools(server: McpServer, callKicadScript: Funct
})
.optional()
.describe("Position on schematic"),
unit: z
.number()
.int()
.min(1)
.optional()
.describe("Unit number for multi-unit symbols (1=A, 2=B, 3=C, …). Defaults to 1."),
},
async (args: {
schematicPath: string;
@@ -57,6 +63,7 @@ export function registerSchematicTools(server: McpServer, callKicadScript: Funct
value?: string;
footprint?: string;
position?: { x: number; y: number };
unit?: number;
}) => {
// Transform to what Python backend expects
const [library, symbolName] = args.symbol.includes(":")
@@ -74,6 +81,7 @@ export function registerSchematicTools(server: McpServer, callKicadScript: Funct
// Python expects flat x, y not nested position
x: args.position?.x ?? 0,
y: args.position?.y ?? 0,
unit: args.unit ?? 1,
},
};