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.
Getting Started
User Guide
- API Reference
- Table of Contents
- Creating Schematics
- Component Operations
- Wire Operations
- Connectivity Analysis
- Hierarchy Management
- Label Operations
- Collections API
- Configuration
- File Operations
- Hierarchical Sheets
- Junctions
- No-Connect Symbols
- Text Elements
- Validation
- Utilities
- Type Hints
- Error Handling
- Complete Example
- Common Recipes and Patterns
- Advanced Hierarchy Management
- Orthogonal Routing Guide
- Architecture Overview
- Electrical Rules Check (ERC) User Guide
MCP Server (AI Agents)
Developer Documentation
API Documentation
Project Info
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)