kicad-sch-api Documentation

KiCAD Schematic Manipulation Library

kicad-sch-api is a Python library for programmatic creation and manipulation of KiCAD schematic files with exact format preservation.

User Guide

Key Features

βœ… Exact Format Preservation - Byte-perfect KiCAD output

Generated schematics are indistinguishable from hand-drawn ones

βœ… Real KiCAD Library Integration - Works with your KiCAD installation

Automatic component validation and pin position calculation

βœ… Object-Oriented API - Modern Python with full type hints

Clean, intuitive interface with comprehensive validation

βœ… Automatic Wire Routing - Manhattan-style orthogonal routing

L-shaped wire paths generated automatically between components

βœ… Performance Optimized - O(1) lookups, bulk operations, symbol caching

Handles large schematics with hundreds of components efficiently

βœ… MCP Server - 15 tools for programmatic schematic manipulation

Enables circuit generation through natural language with AI agents Build circuits from text prompts using Claude or other MCP clients

Quick Example

import kicad_sch_api as ksa

# Create new schematic
sch = ksa.create_schematic('My Circuit')

# Add components
led = sch.components.add('Device:LED', 'D1', 'RED', (100, 100))
resistor = sch.components.add('Device:R', 'R1', '330', (100, 80))

# Wire them together
sch.add_wire_between_pins('R1', '2', 'D1', '1')

# Save with exact KiCAD format
sch.save('led_circuit.kicad_sch')

MCP Server (AI Agents)

Build circuits from natural language using the integrated MCP server:

# Start the MCP server
uv run kicad-sch-mcp

# Or configure in Claude Desktop
# See MCP_EXAMPLES for complete setup guide

AI agents can now create complete circuits:

"Create a voltage divider with R1=10k and R2=20k, fully wired with VCC and GND"

The AI agent will automatically: - Create schematic and add components - Calculate pin positions and route wires - Add net labels and junctions - Save the complete, functional circuit

15 MCP Tools Available: - Component management (add, list, update, remove, filter) - Connectivity (wires, labels, junctions) - Pin discovery (by name, type, complete info) - Schematic management (create, load, save, query)

See MCP Server Usage Examples for complete documentation.

Installation

pip install kicad-sch-api
Requirements:
  • Python 3.10 or higher

  • KiCAD 7 or 8 installation (for component libraries)

Indices and tables