""" Comprehensive tool schema definitions for all KiCAD MCP commands Following MCP 2025-06-18 specification for tool definitions. Each tool includes: - name: Unique identifier - title: Human-readable display name - description: Detailed explanation of what the tool does - inputSchema: JSON Schema for parameters - outputSchema: Optional JSON Schema for return values (structured content) """ from typing import Any, Dict # ============================================================================= # PROJECT TOOLS # ============================================================================= PROJECT_TOOLS = [ { "name": "create_project", "title": "Create New KiCAD Project", "description": "Creates a new KiCAD project with PCB board file and optional project configuration. Automatically creates project directory and initializes board with default settings.", "inputSchema": { "type": "object", "properties": { "projectName": { "type": "string", "description": "Name of the project (used for file naming)", "minLength": 1, }, "path": { "type": "string", "description": "Directory path where project will be created (defaults to current working directory)", }, "template": { "type": "string", "description": "Optional path to template board file to copy settings from", }, }, "required": ["projectName"], }, }, { "name": "open_project", "title": "Open Existing KiCAD Project", "description": "Opens an existing KiCAD project file (.kicad_pro or .kicad_pcb) and loads the board into memory for manipulation.", "inputSchema": { "type": "object", "properties": { "filename": { "type": "string", "description": "Path to .kicad_pro or .kicad_pcb file", } }, "required": ["filename"], }, }, { "name": "save_project", "title": "Save Current Project", "description": "Saves the current board to disk. Can optionally save to a new location.", "inputSchema": { "type": "object", "properties": { "filename": { "type": "string", "description": "Optional new path to save the board (if not provided, saves to current location)", } }, }, }, { "name": "snapshot_project", "title": "Snapshot Project (Checkpoint)", "description": "Copies the entire project folder to a new timestamped snapshot directory so you can resume from this checkpoint later without redoing earlier steps. Call this after every successfully completed design step (e.g. after Step 1 schematic, after Step 2 PCB layout) before asking for user confirmation to proceed.", "inputSchema": { "type": "object", "properties": { "step": { "type": "string", "description": "Step number or name to include in snapshot folder name, e.g. '1' or '2'", }, "label": { "type": "string", "description": "Optional short label, e.g. 'schematic_ok' or 'layout_ok'", }, "projectPath": { "type": "string", "description": "Project directory path. Auto-detected from loaded board if omitted.", }, }, }, }, { "name": "get_project_info", "title": "Get Project Information", "description": "Retrieves metadata and properties of the currently open project including name, paths, and board status.", "inputSchema": {"type": "object", "properties": {}}, }, ] # ============================================================================= # BOARD TOOLS # ============================================================================= BOARD_TOOLS = [ { "name": "set_board_size", "title": "Set Board Dimensions", "description": "Sets the PCB board dimensions. The board outline must be added separately using add_board_outline.", "inputSchema": { "type": "object", "properties": { "width": { "type": "number", "description": "Board width in millimeters", "minimum": 1, }, "height": { "type": "number", "description": "Board height in millimeters", "minimum": 1, }, }, "required": ["width", "height"], }, }, { "name": "add_board_outline", "title": "Add Board Outline", "description": "Adds a board outline shape (rectangle, rounded_rectangle, circle, or polygon) on the Edge.Cuts layer. By default the board top-left corner is placed at (0, 0) so all coordinates are positive. Use x/y to set a different top-left corner position.", "inputSchema": { "type": "object", "properties": { "shape": { "type": "string", "enum": ["rectangle", "rounded_rectangle", "circle", "polygon"], "description": "Shape type for the board outline", }, "width": { "type": "number", "description": "Width in mm (for rectangle/rounded_rectangle)", "minimum": 1, }, "height": { "type": "number", "description": "Height in mm (for rectangle/rounded_rectangle)", "minimum": 1, }, "x": { "type": "number", "description": "X coordinate of the top-left corner in mm (default: 0). Board extends from x to x+width.", }, "y": { "type": "number", "description": "Y coordinate of the top-left corner in mm (default: 0). Board extends from y to y+height.", }, "radius": { "type": "number", "description": "Corner radius in mm for rounded_rectangle, or radius for circle", "minimum": 0, }, "points": { "type": "array", "description": "Array of {x, y} point objects in mm (for polygon shape only)", "items": { "type": "object", "properties": { "x": {"type": "number"}, "y": {"type": "number"}, }, "required": ["x", "y"], }, "minItems": 3, }, }, "required": ["shape"], }, }, { "name": "add_layer", "title": "Add Custom Layer", "description": "Adds a new custom layer to the board stack (e.g., User.1, User.Comments).", "inputSchema": { "type": "object", "properties": { "layerName": { "type": "string", "description": "Name of the layer to add", }, "layerType": { "type": "string", "enum": ["signal", "power", "mixed", "jumper"], "description": "Type of layer (for copper layers)", }, }, "required": ["layerName"], }, }, { "name": "set_active_layer", "title": "Set Active Layer", "description": "Sets the currently active layer for drawing operations.", "inputSchema": { "type": "object", "properties": { "layerName": { "type": "string", "description": "Name of the layer to make active (e.g., F.Cu, B.Cu, Edge.Cuts)", } }, "required": ["layerName"], }, }, { "name": "get_layer_list", "title": "List Board Layers", "description": "Returns a list of all layers in the board with their properties.", "inputSchema": {"type": "object", "properties": {}}, }, { "name": "get_board_info", "title": "Get Board Information", "description": "Retrieves comprehensive board information including dimensions, layer count, component count, and design rules.", "inputSchema": {"type": "object", "properties": {}}, }, { "name": "get_board_2d_view", "title": "Render Board Preview", "description": "Generates a 2D visual representation of the current board state as a PNG image.", "inputSchema": { "type": "object", "properties": { "width": { "type": "number", "description": "Image width in pixels (default: 800)", "minimum": 100, "default": 800, }, "height": { "type": "number", "description": "Image height in pixels (default: 600)", "minimum": 100, "default": 600, }, }, }, }, { "name": "get_board_extents", "title": "Get Board Bounding Box", "description": "Returns the bounding box extents of the PCB board including all edge cuts, components, and traces.", "inputSchema": { "type": "object", "properties": { "unit": { "type": "string", "enum": ["mm", "inch"], "description": "Unit for returned coordinates (default: mm)", "default": "mm", } }, }, }, { "name": "add_mounting_hole", "title": "Add Mounting Hole", "description": "Adds a mounting hole (non-plated through hole) at the specified position with given diameter.", "inputSchema": { "type": "object", "properties": { "x": {"type": "number", "description": "X coordinate in millimeters"}, "y": {"type": "number", "description": "Y coordinate in millimeters"}, "diameter": { "type": "number", "description": "Hole diameter in millimeters", "minimum": 0.1, }, }, "required": ["x", "y", "diameter"], }, }, { "name": "import_svg_logo", "title": "Import SVG Logo to PCB", "description": "Imports an SVG file as filled graphic polygons onto a KiCAD PCB layer (default F.SilkS). Curves are linearised automatically. Supports path, rect, circle, ellipse, polygon and group transforms.", "inputSchema": { "type": "object", "properties": { "pcbPath": { "type": "string", "description": "Path to the .kicad_pcb file", }, "svgPath": { "type": "string", "description": "Path to the SVG logo file", }, "x": { "type": "number", "description": "X position of the logo top-left corner in mm", }, "y": { "type": "number", "description": "Y position of the logo top-left corner in mm", }, "width": { "type": "number", "description": "Target width of the logo in mm (height scaled to preserve aspect ratio)", "minimum": 0.1, }, "layer": { "type": "string", "description": "PCB layer name, e.g. F.SilkS or B.SilkS (default: F.SilkS)", "default": "F.SilkS", }, "strokeWidth": { "type": "number", "description": "Outline stroke width in mm (0 = no outline, default 0)", "default": 0, }, "filled": { "type": "boolean", "description": "Fill polygons with solid layer colour (default true)", "default": True, }, }, "required": ["pcbPath", "svgPath", "x", "y", "width"], }, }, { "name": "add_board_text", "title": "Add Text to Board", "description": "Adds text annotation to the board on a specified layer (e.g., F.SilkS for top silkscreen).", "inputSchema": { "type": "object", "properties": { "text": { "type": "string", "description": "Text content to add", "minLength": 1, }, "x": {"type": "number", "description": "X coordinate in millimeters"}, "y": {"type": "number", "description": "Y coordinate in millimeters"}, "layer": { "type": "string", "description": "Layer name (e.g., F.SilkS, B.SilkS, F.Cu)", "default": "F.SilkS", }, "size": { "type": "number", "description": "Text size in millimeters", "minimum": 0.1, "default": 1.0, }, "thickness": { "type": "number", "description": "Text thickness in millimeters", "minimum": 0.01, "default": 0.15, }, }, "required": ["text", "x", "y"], }, }, ] # ============================================================================= # COMPONENT TOOLS # ============================================================================= COMPONENT_TOOLS = [ { "name": "place_component", "title": "Place Component", "description": "Places a component with specified footprint at given coordinates on the board.", "inputSchema": { "type": "object", "properties": { "reference": { "type": "string", "description": "Component reference designator (e.g., R1, C2, U3)", }, "footprint": { "type": "string", "description": "Footprint library:name (e.g., Resistor_SMD:R_0805_2012Metric)", }, "x": {"type": "number", "description": "X coordinate in millimeters"}, "y": {"type": "number", "description": "Y coordinate in millimeters"}, "rotation": { "type": "number", "description": "Rotation angle in degrees (0-360)", "minimum": 0, "maximum": 360, "default": 0, }, "layer": { "type": "string", "enum": ["F.Cu", "B.Cu"], "description": "Board layer (top or bottom)", "default": "F.Cu", }, }, "required": ["reference", "footprint", "x", "y"], }, }, { "name": "move_component", "title": "Move Component", "description": "Moves an existing component to a new position on the board.", "inputSchema": { "type": "object", "properties": { "reference": { "type": "string", "description": "Component reference designator", }, "x": { "type": "number", "description": "New X coordinate in millimeters", }, "y": { "type": "number", "description": "New Y coordinate in millimeters", }, }, "required": ["reference", "x", "y"], }, }, { "name": "rotate_component", "title": "Rotate Component", "description": "Rotates a component by specified angle. Rotation is cumulative with existing rotation.", "inputSchema": { "type": "object", "properties": { "reference": { "type": "string", "description": "Component reference designator", }, "angle": { "type": "number", "description": "Rotation angle in degrees (positive = counterclockwise)", }, }, "required": ["reference", "angle"], }, }, { "name": "delete_component", "title": "Delete Component", "description": "Removes a component from the board.", "inputSchema": { "type": "object", "properties": { "reference": { "type": "string", "description": "Component reference designator", } }, "required": ["reference"], }, }, { "name": "edit_component", "title": "Edit Component Properties", "description": "Modifies properties of an existing component (value, footprint, etc.).", "inputSchema": { "type": "object", "properties": { "reference": { "type": "string", "description": "Component reference designator", }, "value": {"type": "string", "description": "New component value"}, "footprint": { "type": "string", "description": "New footprint library:name", }, }, "required": ["reference"], }, }, { "name": "get_component_properties", "title": "Get Component Properties", "description": "Retrieves detailed properties of a specific component.", "inputSchema": { "type": "object", "properties": { "reference": { "type": "string", "description": "Component reference designator", } }, "required": ["reference"], }, }, { "name": "get_component_list", "title": "List All Components", "description": "Returns a list of all components on the board with their properties.", "inputSchema": {"type": "object", "properties": {}}, }, { "name": "find_component", "title": "Find Components", "description": "Searches for components matching specified criteria. Supports partial matching on reference, value, or footprint patterns.", "inputSchema": { "type": "object", "properties": { "reference": { "type": "string", "description": "Reference designator pattern to match (e.g., 'R1', 'U', 'C2')", }, "value": { "type": "string", "description": "Value pattern to match (e.g., '10k', '100nF')", }, "footprint": { "type": "string", "description": "Footprint pattern to match (e.g., '0805', 'SOIC')", }, }, }, }, { "name": "get_component_pads", "title": "Get Component Pads", "description": "Returns all pads for a component with their positions, net connections, sizes, and shapes.", "inputSchema": { "type": "object", "properties": { "reference": { "type": "string", "description": "Component reference designator (e.g., U1, R5)", } }, "required": ["reference"], }, }, { "name": "get_pad_position", "title": "Get Pad Position", "description": "Returns the position and properties of a specific pad on a component.", "inputSchema": { "type": "object", "properties": { "reference": { "type": "string", "description": "Component reference designator", }, "padName": { "type": "string", "description": "Pad name or number (e.g., '1', '2', 'A1')", }, "padNumber": { "type": "string", "description": "Alternative to padName - pad number", }, }, "required": ["reference"], }, }, { "name": "place_component_array", "title": "Place Component Array", "description": "Places multiple copies of a component in a grid or circular pattern.", "inputSchema": { "type": "object", "properties": { "referencePrefix": { "type": "string", "description": "Reference prefix (e.g., 'R' for R1, R2, R3...)", }, "startNumber": { "type": "integer", "description": "Starting number for references", "minimum": 1, "default": 1, }, "footprint": { "type": "string", "description": "Footprint library:name", }, "pattern": { "type": "string", "enum": ["grid", "circular"], "description": "Array pattern type", }, "count": { "type": "integer", "description": "Total number of components to place", "minimum": 1, }, "startX": { "type": "number", "description": "Starting X coordinate in millimeters", }, "startY": { "type": "number", "description": "Starting Y coordinate in millimeters", }, "spacingX": { "type": "number", "description": "Horizontal spacing in mm (for grid pattern)", }, "spacingY": { "type": "number", "description": "Vertical spacing in mm (for grid pattern)", }, "radius": { "type": "number", "description": "Circle radius in mm (for circular pattern)", }, "rows": { "type": "integer", "description": "Number of rows (for grid pattern)", "minimum": 1, }, "columns": { "type": "integer", "description": "Number of columns (for grid pattern)", "minimum": 1, }, }, "required": [ "referencePrefix", "footprint", "pattern", "count", "startX", "startY", ], }, }, { "name": "align_components", "title": "Align Components", "description": "Aligns multiple components horizontally or vertically.", "inputSchema": { "type": "object", "properties": { "references": { "type": "array", "description": "Array of component reference designators to align", "items": {"type": "string"}, "minItems": 2, }, "direction": { "type": "string", "enum": ["horizontal", "vertical"], "description": "Alignment direction", }, "spacing": { "type": "number", "description": "Spacing between components in mm (optional, for even distribution)", }, }, "required": ["references", "direction"], }, }, { "name": "duplicate_component", "title": "Duplicate Component", "description": "Creates a copy of an existing component with new reference designator.", "inputSchema": { "type": "object", "properties": { "sourceReference": { "type": "string", "description": "Reference of component to duplicate", }, "newReference": { "type": "string", "description": "Reference designator for the new component", }, "offsetX": { "type": "number", "description": "X offset from original position in mm", "default": 0, }, "offsetY": { "type": "number", "description": "Y offset from original position in mm", "default": 0, }, }, "required": ["sourceReference", "newReference"], }, }, ] # ============================================================================= # ROUTING TOOLS # ============================================================================= ROUTING_TOOLS = [ { "name": "add_net", "title": "Create Electrical Net", "description": "Creates a new electrical net for signal routing.", "inputSchema": { "type": "object", "properties": { "netName": { "type": "string", "description": "Name of the net (e.g., VCC, GND, SDA)", "minLength": 1, }, "netClass": { "type": "string", "description": "Optional net class to assign (must exist first)", }, }, "required": ["netName"], }, }, { "name": "route_trace", "title": "Route PCB Trace", "description": "Routes a copper trace between two points or pads on a specified layer.", "inputSchema": { "type": "object", "properties": { "netName": {"type": "string", "description": "Net name for this trace"}, "layer": { "type": "string", "description": "Layer to route on (e.g., F.Cu, B.Cu)", "default": "F.Cu", }, "width": { "type": "number", "description": "Trace width in millimeters", "minimum": 0.1, }, "points": { "type": "array", "description": "Array of [x, y] waypoints in millimeters", "items": { "type": "array", "items": {"type": "number"}, "minItems": 2, "maxItems": 2, }, "minItems": 2, }, }, "required": ["points", "width"], }, }, { "name": "add_via", "title": "Add Via", "description": "Adds a via (plated through-hole) to connect traces between layers.", "inputSchema": { "type": "object", "properties": { "x": {"type": "number", "description": "X coordinate in millimeters"}, "y": {"type": "number", "description": "Y coordinate in millimeters"}, "diameter": { "type": "number", "description": "Via diameter in millimeters", "minimum": 0.1, }, "drill": { "type": "number", "description": "Drill diameter in millimeters", "minimum": 0.1, }, "netName": { "type": "string", "description": "Net name to assign to this via", }, }, "required": ["x", "y", "diameter", "drill"], }, }, { "name": "delete_trace", "title": "Delete Trace", "description": "Removes traces from the board. Can delete by UUID, position, or bulk-delete all traces on a net.", "inputSchema": { "type": "object", "properties": { "uuid": { "type": "string", "description": "UUID of a specific trace to delete", }, "position": { "type": "object", "description": "Delete trace nearest to this position", "properties": { "x": {"type": "number", "description": "X coordinate"}, "y": {"type": "number", "description": "Y coordinate"}, "unit": { "type": "string", "enum": ["mm", "inch"], "default": "mm", }, }, "required": ["x", "y"], }, "net": { "type": "string", "description": "Delete all traces on this net (bulk delete)", }, "layer": { "type": "string", "description": "Filter by layer when using net-based deletion", }, "includeVias": { "type": "boolean", "description": "Include vias in net-based deletion", "default": False, }, }, }, }, { "name": "query_traces", "title": "Query Traces", "description": "Queries traces on the board with optional filters by net, layer, or bounding box. Returns trace details including UUID, positions, width, and length.", "inputSchema": { "type": "object", "properties": { "net": { "type": "string", "description": "Filter by net name (e.g., 'GND', 'VCC')", }, "layer": { "type": "string", "description": "Filter by layer name (e.g., 'F.Cu', 'B.Cu')", }, "boundingBox": { "type": "object", "description": "Filter by bounding box region", "properties": { "x1": {"type": "number", "description": "Left X coordinate"}, "y1": {"type": "number", "description": "Top Y coordinate"}, "x2": {"type": "number", "description": "Right X coordinate"}, "y2": {"type": "number", "description": "Bottom Y coordinate"}, "unit": { "type": "string", "enum": ["mm", "inch"], "default": "mm", }, }, }, "includeVias": { "type": "boolean", "description": "Include vias in the result", "default": False, }, }, }, }, { "name": "modify_trace", "title": "Modify Trace", "description": "Modifies properties of an existing trace. Find trace by UUID or position, then change width, layer, or net assignment.", "inputSchema": { "type": "object", "properties": { "uuid": { "type": "string", "description": "UUID of the trace to modify", }, "position": { "type": "object", "description": "Find trace nearest to this position", "properties": { "x": {"type": "number", "description": "X coordinate"}, "y": {"type": "number", "description": "Y coordinate"}, "unit": { "type": "string", "enum": ["mm", "inch"], "default": "mm", }, }, "required": ["x", "y"], }, "width": {"type": "number", "description": "New trace width in mm"}, "layer": { "type": "string", "description": "New layer name (e.g., 'F.Cu', 'B.Cu')", }, "net": {"type": "string", "description": "New net name to assign"}, }, }, }, { "name": "copy_routing_pattern", "title": "Copy Routing Pattern", "description": "Copies routing pattern from source components to target components. Enables routing replication between identical component groups by calculating and applying position offset.", "inputSchema": { "type": "object", "properties": { "sourceRefs": { "type": "array", "items": {"type": "string"}, "description": "Source component references (e.g., ['U1', 'U2', 'U3'])", }, "targetRefs": { "type": "array", "items": {"type": "string"}, "description": "Target component references (e.g., ['U4', 'U5', 'U6'])", }, "includeVias": { "type": "boolean", "description": "Include vias in the pattern copy", "default": True, }, "traceWidth": { "type": "number", "description": "Override trace width in mm (uses original if not specified)", }, }, "required": ["sourceRefs", "targetRefs"], }, }, { "name": "get_nets_list", "title": "List All Nets", "description": "Returns a list of all electrical nets defined on the board.", "inputSchema": {"type": "object", "properties": {}}, }, { "name": "create_netclass", "title": "Create Net Class", "description": "Defines a net class with specific routing rules (trace width, clearance, etc.).", "inputSchema": { "type": "object", "properties": { "name": { "type": "string", "description": "Net class name", "minLength": 1, }, "traceWidth": { "type": "number", "description": "Default trace width in millimeters", "minimum": 0.1, }, "clearance": { "type": "number", "description": "Clearance in millimeters", "minimum": 0.1, }, "viaDiameter": { "type": "number", "description": "Via diameter in millimeters", }, "viaDrill": { "type": "number", "description": "Via drill diameter in millimeters", }, }, "required": ["name", "traceWidth", "clearance"], }, }, { "name": "add_copper_pour", "title": "Add Copper Pour", "description": "Creates a copper pour/zone (typically for ground or power planes).", "inputSchema": { "type": "object", "properties": { "netName": { "type": "string", "description": "Net to connect this copper pour to (e.g., GND, VCC)", }, "layer": { "type": "string", "description": "Layer for the copper pour (e.g., F.Cu, B.Cu)", }, "priority": { "type": "integer", "description": "Pour priority (higher priorities fill first)", "minimum": 0, "default": 0, }, "clearance": { "type": "number", "description": "Clearance from other objects in millimeters", "minimum": 0.1, }, "outline": { "type": "array", "description": "Array of [x, y] points defining the pour boundary", "items": { "type": "array", "items": {"type": "number"}, "minItems": 2, "maxItems": 2, }, "minItems": 3, }, }, "required": ["netName", "layer", "outline"], }, }, { "name": "route_differential_pair", "title": "Route Differential Pair", "description": "Routes a differential signal pair with matched lengths and spacing.", "inputSchema": { "type": "object", "properties": { "positiveName": { "type": "string", "description": "Positive signal net name", }, "negativeName": { "type": "string", "description": "Negative signal net name", }, "layer": {"type": "string", "description": "Layer to route on"}, "width": { "type": "number", "description": "Trace width in millimeters", }, "gap": { "type": "number", "description": "Gap between traces in millimeters", }, "points": { "type": "array", "description": "Waypoints for the pair routing", "items": { "type": "array", "items": {"type": "number"}, "minItems": 2, "maxItems": 2, }, "minItems": 2, }, }, "required": ["positiveName", "negativeName", "width", "gap", "points"], }, }, ] # ============================================================================= # LIBRARY TOOLS # ============================================================================= LIBRARY_TOOLS = [ { "name": "list_libraries", "title": "List Footprint Libraries", "description": "Lists all available footprint libraries accessible to KiCAD.", "inputSchema": {"type": "object", "properties": {}}, }, { "name": "search_footprints", "title": "Search Footprints", "description": "Searches for footprints matching a query string across all libraries.", "inputSchema": { "type": "object", "properties": { "query": { "type": "string", "description": "Search query (e.g., '0805', 'SOIC', 'QFP')", "minLength": 1, }, "library": { "type": "string", "description": "Optional library to restrict search to", }, }, "required": ["query"], }, }, { "name": "list_library_footprints", "title": "List Footprints in Library", "description": "Lists all footprints available in a specific library.", "inputSchema": { "type": "object", "properties": { "library": { "type": "string", "description": "Library name (e.g., Resistor_SMD, Connector_PinHeader)", "minLength": 1, } }, "required": ["library"], }, }, { "name": "get_footprint_info", "title": "Get Footprint Details", "description": "Retrieves detailed information about a specific footprint including pad layout, dimensions, and description.", "inputSchema": { "type": "object", "properties": { "library": {"type": "string", "description": "Library name"}, "footprint": {"type": "string", "description": "Footprint name"}, }, "required": ["library", "footprint"], }, }, ] # ============================================================================= # DESIGN RULE TOOLS # ============================================================================= DESIGN_RULE_TOOLS = [ { "name": "set_design_rules", "title": "Set Design Rules", "description": "Configures board design rules including clearances, trace widths, and via sizes.", "inputSchema": { "type": "object", "properties": { "clearance": { "type": "number", "description": "Minimum clearance between copper in millimeters", "minimum": 0.1, }, "trackWidth": { "type": "number", "description": "Minimum track width in millimeters", "minimum": 0.1, }, "viaDiameter": { "type": "number", "description": "Minimum via diameter in millimeters", }, "viaDrill": { "type": "number", "description": "Minimum via drill diameter in millimeters", }, "microViaD iameter": { "type": "number", "description": "Minimum micro-via diameter in millimeters", }, }, }, }, { "name": "get_design_rules", "title": "Get Current Design Rules", "description": "Retrieves the currently configured design rules from the board.", "inputSchema": {"type": "object", "properties": {}}, }, { "name": "run_drc", "title": "Run Design Rule Check", "description": "Executes a design rule check (DRC) on the current board and reports violations.", "inputSchema": { "type": "object", "properties": { "includeWarnings": { "type": "boolean", "description": "Include warnings in addition to errors", "default": True, } }, }, }, { "name": "get_drc_violations", "title": "Get DRC Violations", "description": "Returns a list of design rule violations from the most recent DRC run.", "inputSchema": {"type": "object", "properties": {}}, }, ] # ============================================================================= # EXPORT TOOLS # ============================================================================= EXPORT_TOOLS = [ { "name": "export_gerber", "title": "Export Gerber Files", "description": "Generates Gerber files for PCB fabrication (industry standard format).", "inputSchema": { "type": "object", "properties": { "outputPath": { "type": "string", "description": "Directory path for output files", }, "layers": { "type": "array", "description": "List of layers to export (if not provided, exports all copper and mask layers)", "items": {"type": "string"}, }, "includeDrillFiles": { "type": "boolean", "description": "Include drill files (Excellon format)", "default": True, }, }, "required": ["outputPath"], }, }, { "name": "export_pdf", "title": "Export PDF", "description": "Exports the board layout as a PDF document for documentation or review.", "inputSchema": { "type": "object", "properties": { "outputPath": { "type": "string", "description": "Path for output PDF file", }, "layers": { "type": "array", "description": "Layers to include in PDF", "items": {"type": "string"}, }, "colorMode": { "type": "string", "enum": ["color", "black_white"], "description": "Color mode for output", "default": "color", }, }, "required": ["outputPath"], }, }, { "name": "export_svg", "title": "Export SVG", "description": "Exports the board as Scalable Vector Graphics for documentation or web display.", "inputSchema": { "type": "object", "properties": { "outputPath": { "type": "string", "description": "Path for output SVG file", }, "layers": { "type": "array", "description": "Layers to include in SVG", "items": {"type": "string"}, }, }, "required": ["outputPath"], }, }, { "name": "export_3d", "title": "Export 3D Model", "description": "Exports a 3D model of the board in STEP or VRML format for mechanical CAD integration.", "inputSchema": { "type": "object", "properties": { "outputPath": { "type": "string", "description": "Path for output 3D file", }, "format": { "type": "string", "enum": ["step", "vrml"], "description": "3D model format", "default": "step", }, "includeComponents": { "type": "boolean", "description": "Include 3D component models", "default": True, }, }, "required": ["outputPath"], }, }, { "name": "export_bom", "title": "Export Bill of Materials", "description": "Generates a bill of materials (BOM) listing all components with references, values, and footprints.", "inputSchema": { "type": "object", "properties": { "outputPath": { "type": "string", "description": "Path for output BOM file", }, "format": { "type": "string", "enum": ["csv", "xml", "html"], "description": "BOM output format", "default": "csv", }, "groupByValue": { "type": "boolean", "description": "Group components with same value together", "default": True, }, }, "required": ["outputPath"], }, }, ] # ============================================================================= # SCHEMATIC TOOLS # ============================================================================= SCHEMATIC_TOOLS = [ { "name": "create_schematic", "title": "Create New Schematic", "description": "Creates a new KiCAD schematic file for circuit design.", "inputSchema": { "type": "object", "properties": { "filename": { "type": "string", "description": "Path for the new schematic file (.kicad_sch)", }, "title": {"type": "string", "description": "Schematic title"}, }, "required": ["filename"], }, }, { "name": "load_schematic", "title": "Load Existing Schematic", "description": "Opens an existing KiCAD schematic file for editing.", "inputSchema": { "type": "object", "properties": { "filename": { "type": "string", "description": "Path to schematic file (.kicad_sch)", } }, "required": ["filename"], }, }, { "name": "add_schematic_component", "title": "Add Component to Schematic", "description": "Places a symbol (resistor, capacitor, IC, etc.) on the schematic.", "inputSchema": { "type": "object", "properties": { "reference": { "type": "string", "description": "Reference designator (e.g., R1, C2, U3)", }, "symbol": { "type": "string", "description": "Symbol library:name (e.g., Device:R, Device:C)", }, "value": { "type": "string", "description": "Component value (e.g., 10k, 0.1uF)", }, "x": {"type": "number", "description": "X coordinate on schematic"}, "y": {"type": "number", "description": "Y coordinate on schematic"}, }, "required": ["reference", "symbol", "x", "y"], }, }, { "name": "add_schematic_wire", "title": "Draw Wire Between Pins", "description": "Draws a wire on the schematic between two or more coordinate points. Always call get_schematic_pin_locations first to get the approximate pin coordinates, then pass them as the first and last waypoints. snapToPins (on by default) will correct any float imprecision by snapping endpoints to the exact nearest pin coordinate. To route around components, add intermediate waypoints between the start and end: e.g. [[x1,y1], [xMid,y1], [xMid,y2], [x2,y2]] routes horizontally then vertically. Intermediate waypoints are never snapped.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to schematic file", }, "waypoints": { "type": "array", "description": "Array of [x, y] coordinates defining the wire path. First and last points are the pin locations (from get_schematic_pin_locations). Add intermediate points to route around obstacles.", "items": { "type": "array", "items": {"type": "number"}, "minItems": 2, "maxItems": 2, }, "minItems": 2, }, "snapToPins": { "type": "boolean", "description": "When true, the first and last waypoints are snapped to the nearest schematic pin within snapTolerance mm. Intermediate waypoints are left unchanged. Enabled by default to correct float coordinate imprecision.", "default": True, }, "snapTolerance": { "type": "number", "description": "Maximum distance in mm to search for a nearby pin when snapToPins is enabled.", "default": 1.0, }, }, "required": ["schematicPath", "waypoints"], }, }, { "name": "add_schematic_net_label", "title": "Add Net Label", "description": ( "Add a net label to a schematic. " "PREFERRED: supply componentRef + pinNumber to snap the label to the exact pin endpoint — " "this guarantees an electrical connection. " "Alternatively supply position [x, y], but the coordinates must match the pin endpoint exactly " "(even a 0.01 mm offset breaks the connection). " "The response includes actual_position (coordinates actually used) and snapped_to_pin " "(present when a pin reference was resolved)." ), "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to schematic file", }, "netName": { "type": "string", "description": "Name of the net (e.g., VCC, GND, SDA)", }, "position": { "type": "array", "items": {"type": "number"}, "minItems": 2, "maxItems": 2, "description": "Position [x, y] for the label. Required when componentRef/pinNumber are not given.", }, "componentRef": { "type": "string", "description": "Component reference to snap label to (e.g. U1, R1). Use with pinNumber.", }, "pinNumber": { "type": "string", "description": "Pin number or name on componentRef (e.g. '1', 'GND'). Use with componentRef.", }, "labelType": { "type": "string", "enum": ["label", "global_label", "hierarchical_label"], "description": "Label type (default: label)", "default": "label", }, "orientation": { "type": "number", "description": "Rotation angle in degrees (0, 90, 180, 270)", "default": 0, }, }, "required": ["schematicPath", "netName"], }, }, { "name": "connect_to_net", "title": "Connect Pin to Net", "description": ( "Connect a component pin to a named net by adding a wire stub and net label at the exact " "pin endpoint. The response includes pin_location (exact pin coords), label_location " "(where the label was placed), and wire_stub (the wire segment added) so you can confirm " "the placement without a separate verification call." ), "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to schematic file", }, "componentRef": { "type": "string", "description": "Component reference designator (e.g., R1, U3)", }, "pinName": { "type": "string", "description": "Pin number or name on the component", }, "netName": { "type": "string", "description": "Name of the net to connect to", }, }, "required": ["schematicPath", "componentRef", "pinName", "netName"], }, }, { "name": "get_net_connections", "title": "Get Net Connections", "description": "Returns all components and pins connected to a specified net.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to schematic file", }, "netName": { "type": "string", "description": "Name of the net to query", }, }, "required": ["schematicPath", "netName"], }, }, { "name": "get_wire_connections", "title": "Get Wire Connections", "description": ( "Returns the net name and all wires and component pins connected at a given point. " "Accepts either a component reference + pin number (e.g. reference='U1', pin='3') " "or a schematic coordinate (x, y in mm). " "The response includes: 'net' (label name or null for unnamed nets), " "'pins' (all component pins on the net), 'wires' (all wire segments on the net), " "and 'query_point' (the resolved coordinate used). " "The query point must be at a wire endpoint or junction — wire midpoints are not matched. " "Use get_schematic_pin_locations or list_schematic_wires to obtain exact endpoint coordinates." ), "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to the schematic file (.kicad_sch)", }, "reference": { "type": "string", "description": "Component reference (e.g. U1, R1). Pair with pin.", }, "pin": { "type": "string", "description": "Pin number or name (e.g. '3', 'SDA'). Pair with reference.", }, "x": { "type": "number", "description": "X coordinate of a wire endpoint in mm. Pair with y.", }, "y": { "type": "number", "description": "Y coordinate of a wire endpoint in mm. Pair with x.", }, }, "required": ["schematicPath"], }, }, { "name": "get_net_at_point", "title": "Get Net At Point", "description": ( "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. " "Checks net label positions first, then wire endpoints. " "Useful for quickly identifying what net occupies a specific coordinate " "without traversing the full wire graph." ), "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to the schematic file (.kicad_sch)", }, "x": { "type": "number", "description": "X coordinate in mm", }, "y": { "type": "number", "description": "Y coordinate in mm", }, }, "required": ["schematicPath", "x", "y"], }, }, { "name": "get_schematic_pin_locations", "title": "Get Schematic Pin Locations", "description": "Returns the exact absolute coordinates of all pins on a schematic component. Use this BEFORE placing net labels with add_schematic_net_label to get the correct x/y position for each pin endpoint.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to the schematic file", }, "reference": { "type": "string", "description": "Component reference designator (e.g., U1, R1, J2)", }, }, "required": ["schematicPath", "reference"], }, }, { "name": "connect_passthrough", "title": "Connect Passthrough (Pin-to-Pin)", "description": "Connects all pins of a source connector to the matching pins of a target connector using shared net labels. Ideal for passthrough adapters where J1 pin N connects directly to J2 pin N. Each pair gets a net label '{netPrefix}_{pinNumber}'. Use this instead of calling connect_to_net 15 times for FFC/ribbon cable passthroughs. NOTE: KiCAD Connector_Generic symbols always have pin 1 at the TOP of the symbol and pin N at the BOTTOM. When assigning named nets (e.g. GND, CAM_SCL) to specific pin numbers, always use the physical pin number as shown in the connector datasheet — pin 1 = top of symbol.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to the schematic file", }, "sourceRef": { "type": "string", "description": "Reference of the source connector (e.g., J1)", }, "targetRef": { "type": "string", "description": "Reference of the target connector (e.g., J2)", }, "netPrefix": { "type": "string", "description": "Prefix for generated net names, e.g. 'CSI' produces CSI_1, CSI_2, ... (default: PIN)", }, "pinOffset": { "type": "integer", "description": "Add this value to the pin number when building net names (default: 0)", }, }, "required": ["schematicPath", "sourceRef", "targetRef"], }, }, { "name": "run_erc", "title": "Run Electrical Rules Check (ERC)", "description": "Runs the KiCAD Electrical Rules Check (ERC) on a schematic via kicad-cli and returns all violations with type, severity, and location. Use this to verify the schematic is electrically correct before generating a netlist or exporting.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to the .kicad_sch schematic file", } }, "required": ["schematicPath"], }, }, { "name": "sync_schematic_to_board", "title": "Sync Schematic to PCB (F8)", "description": "Reads net connections from the schematic and assigns them to matching component pads in the PCB board file. Equivalent to KiCAD Pcbnew F8 'Update PCB from Schematic'. Must be called after placing components and before routing traces, so that pad-to-net assignments are correct.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to .kicad_sch file. If omitted, auto-detected from current board path.", }, "boardPath": { "type": "string", "description": "Path to .kicad_pcb file. If omitted, uses currently loaded board.", }, }, }, }, { "name": "generate_netlist", "title": "Generate Netlist", "description": "Generates a netlist from the schematic showing all components and their net connections.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to schematic file", }, "outputPath": { "type": "string", "description": "Optional path to save netlist file", }, "format": { "type": "string", "enum": ["kicad", "json", "spice"], "description": "Netlist output format", "default": "json", }, }, "required": ["schematicPath"], }, }, { "name": "list_schematic_libraries", "title": "List Symbol Libraries", "description": "Lists all available symbol libraries for schematic design.", "inputSchema": { "type": "object", "properties": { "searchPaths": { "type": "array", "description": "Optional additional paths to search for libraries", "items": {"type": "string"}, } }, }, }, { "name": "export_schematic_pdf", "title": "Export Schematic to PDF", "description": "Exports the schematic as a PDF document for printing or documentation.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to schematic file", }, "outputPath": {"type": "string", "description": "Path for output PDF"}, }, "required": ["schematicPath", "outputPath"], }, }, { "name": "add_schematic_junction", "title": "Add Junction to Schematic", "description": "Adds a junction (connection dot) at the specified coordinates on the schematic. Junctions are required in KiCAD to mark intentional connections where wires cross or where a wire branches off another wire. Without a junction, crossing wires are not electrically connected.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to schematic file", }, "position": { "type": "array", "description": "The [x, y] coordinates where the junction should be placed. Must be on an existing wire intersection or branch point.", "items": {"type": "number"}, "minItems": 2, "maxItems": 2, }, }, "required": ["schematicPath", "position"], }, }, # --- Schematic Analysis Tools (read-only) --- { "name": "get_schematic_view_region", "title": "Get Schematic View Region", "description": "Exports a cropped region of the schematic as an image (PNG or SVG). Specify a bounding box in schematic mm coordinates to zoom into a specific area.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to the .kicad_sch schematic file", }, "x1": { "type": "number", "description": "Left X coordinate of the region in mm", }, "y1": { "type": "number", "description": "Top Y coordinate of the region in mm", }, "x2": { "type": "number", "description": "Right X coordinate of the region in mm", }, "y2": { "type": "number", "description": "Bottom Y coordinate of the region in mm", }, "format": { "type": "string", "enum": ["png", "svg"], "description": "Output image format (default: png)", }, "width": { "type": "integer", "description": "Output image width in pixels (default: 800)", }, "height": { "type": "integer", "description": "Output image height in pixels (default: 600)", }, }, "required": ["schematicPath", "x1", "y1", "x2", "y2"], }, }, { "name": "find_overlapping_elements", "title": "Find Overlapping Elements", "description": "Detects spatially overlapping symbols, wires, and labels in the schematic. Finds: duplicate power symbols at the same position, collinear overlapping wire segments, and labels stacked on top of each other.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to the .kicad_sch schematic file", }, "tolerance": { "type": "number", "description": "Distance threshold in mm for label proximity and wire collinearity checks. Symbol overlap uses bounding-box intersection. (default: 0.5)", }, }, "required": ["schematicPath"], }, }, { "name": "get_elements_in_region", "title": "Get Elements in Region", "description": "Lists all symbols, wires, and labels within a rectangular region of the schematic. Useful for understanding what is in a specific area before modifying it.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to the .kicad_sch schematic file", }, "x1": { "type": "number", "description": "Left X coordinate of the region in mm", }, "y1": { "type": "number", "description": "Top Y coordinate of the region in mm", }, "x2": { "type": "number", "description": "Right X coordinate of the region in mm", }, "y2": { "type": "number", "description": "Bottom Y coordinate of the region in mm", }, }, "required": ["schematicPath", "x1", "y1", "x2", "y2"], }, }, { "name": "find_wires_crossing_symbols", "title": "Find Wires Crossing Symbols", "description": "Find all wires that cross over component symbol bodies. Wires passing over symbols are unacceptable in schematics — they indicate routing mistakes where a wire was drawn across a component instead of around it.", "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to the .kicad_sch schematic file", } }, "required": ["schematicPath"], }, }, { "name": "find_orphaned_wires", "title": "Find Orphaned Wires", "description": ( "Find wire segments with at least one dangling endpoint — an endpoint not connected " "to a component pin, net label, or another wire. " "Orphaned wires cause ERC 'wire end unconnected' errors and indicate routing mistakes. " "Does not require the KiCad UI to be running." ), "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to the .kicad_sch schematic file", } }, "required": ["schematicPath"], }, }, { "name": "list_floating_labels", "title": "List Floating Net Labels", "description": ( "Returns all net labels in the schematic that are not connected to any component pin. " "A label is 'floating' when no component pin's coordinate falls on the wire-network " "reachable from the label's anchor position. " "Floating labels indicate misplaced or off-grid labels that will cause ERC errors. " "Does not require the KiCad UI to be running." ), "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to the .kicad_sch schematic file", } }, "required": ["schematicPath"], }, }, { "name": "snap_to_grid", "title": "Snap Schematic Elements to Grid", "description": ( "Snap schematic element coordinates to the nearest grid point. " "KiCAD eeschema uses exact integer matching (10 000 IU/mm) for connectivity, " "so even a sub-pixel coordinate offset will make wires appear connected visually " "but fail ERC checks. Running this tool before ERC eliminates that class of error. " "Modifies the .kicad_sch file in place. " "Does not require the KiCAD UI to be running." ), "inputSchema": { "type": "object", "properties": { "schematicPath": { "type": "string", "description": "Path to the .kicad_sch schematic file", }, "gridSize": { "type": "number", "description": ( "Grid spacing in mm. " "Standard KiCAD schematic grid is 2.54 mm (0.1 inch). " "Use 1.27 mm for high-density layouts. " "Defaults to 2.54." ), "default": 2.54, }, "elements": { "type": "array", "description": ( "Element types to snap. " 'Valid values: "wires", "junctions", "labels", "components". ' 'Defaults to ["wires", "junctions", "labels"] when omitted. ' '"components" is opt-in because moving a component without re-routing ' "its wires will create new mismatches." ), "items": { "type": "string", "enum": ["wires", "junctions", "labels", "components"], }, }, }, "required": ["schematicPath"], }, }, ] # ============================================================================= # UI/PROCESS TOOLS # ============================================================================= UI_TOOLS = [ { "name": "check_kicad_ui", "title": "Check KiCAD UI Status", "description": "Checks if KiCAD user interface is currently running and returns process information.", "inputSchema": {"type": "object", "properties": {}}, }, { "name": "launch_kicad_ui", "title": "Launch KiCAD Application", "description": "Opens the KiCAD graphical user interface, optionally with a specific project loaded.", "inputSchema": { "type": "object", "properties": { "projectPath": { "type": "string", "description": "Optional path to project file to open in UI", }, "autoLaunch": { "type": "boolean", "description": "Whether to automatically launch if not running", "default": True, }, }, }, }, ] # ============================================================================= # COMBINED TOOL SCHEMAS # ============================================================================= TOOL_SCHEMAS: Dict[str, Any] = {} # Combine all tool categories for tool in ( PROJECT_TOOLS + BOARD_TOOLS + COMPONENT_TOOLS + ROUTING_TOOLS + LIBRARY_TOOLS + DESIGN_RULE_TOOLS + EXPORT_TOOLS + SCHEMATIC_TOOLS + UI_TOOLS ): TOOL_SCHEMAS[tool["name"]] = tool # Total: 46 tools with comprehensive schemas