MCP server for AI-assisted PCB design with KiCad
Project description
KiCad MCP Server
A Model Context Protocol (MCP) server for KiCad 9.x, enabling AI-assisted PCB design through Claude Code or other MCP clients.
✨ What's New in v3.5.0
- 🏗️ Modular Architecture - Refactored from 987-line monolithic script to clean package structure
- 🔒 Security Hardening - Path validation, injection prevention, restricted file access
- ⚙️ Environment Configuration - All settings configurable via environment variables
- 🧹 Task Cleanup - New
cleanup_taskstool for managing old async tasks - ✅ Unit Tests - 55 comprehensive tests covering core functionality
- 📝 Type Annotations - Full type hints throughout codebase
- 📊 Proper Logging - Structured logging framework replacing stderr prints
Features
- DRC/ERC Check - Design Rule Check and Electrical Rule Check
- Zone Fill - Automatic copper zone filling
- Auto-routing - FreeRouting integration with async support (bypass 10-min timeout)
- 3D Rendering - Native KiCad 9 3D render (top/bottom/iso views)
- Export - Gerber, Drill, BOM, Netlist, PDF, SVG, STEP
- JLCPCB Package - Complete manufacturing files for JLCPCB/PCBWay
Architecture
Local Machine VPS (KiCad 9.x)
┌─────────────────┐ ┌─────────────────────┐
│ Claude Code │ MCP │ MCP Server v3.5.0 │
│ or MCP Clients │◄────SSH─────►│ kicad-cli + pcbnew │
└─────────────────┘ │ + FreeRouting │
└─────────────────────┘
Requirements
VPS
- Ubuntu 22.04+ or Debian 12+
- KiCad 9.0.6+
- Python 3.10+
- Java 17+ (for FreeRouting)
- xvfb (for headless rendering)
Local
- Claude Code with MCP support
- SSH access to VPS
Quick Install
On VPS
# Clone repository
git clone https://github.com/bunnyf/pcb-mcp.git
cd pcb-mcp
# Run install script
chmod +x scripts/install.sh
./scripts/install.sh
Or manual install:
# Install KiCad 9
sudo add-apt-repository ppa:kicad/kicad-9.0-releases -y
sudo apt update
sudo apt install kicad xvfb -y
# Install FreeRouting
sudo apt install openjdk-17-jre -y
sudo wget -q https://github.com/freerouting/freerouting/releases/download/v1.9.0/freerouting-1.9.0.jar -O /opt/freerouting.jar
# Setup MCP Server
mkdir -p /root/pcb/{mcp,projects,tasks}
cp kicad_mcp_server.py /root/pcb/mcp/
chmod +x /root/pcb/mcp/kicad_mcp_server.py
Claude Code Configuration
Add to your Claude Code MCP settings (~/.claude/claude_desktop_config.json):
{
"mcpServers": {
"kicad": {
"command": "ssh",
"args": [
"your-vps-host",
"python3 /root/pcb/mcp/kicad_mcp_server.py"
]
}
}
}
Available Tools (23)
Check
| Tool | Description |
|---|---|
run_drc |
PCB Design Rule Check |
run_erc |
Schematic Electrical Rule Check |
Operations
| Tool | Description |
|---|---|
fill_zones |
Fill all copper zones |
auto_route |
Auto-routing with FreeRouting (async) |
Async Tasks
| Tool | Description |
|---|---|
get_task_status |
Query async task status |
list_tasks |
List all async tasks |
cleanup_tasks |
Clean up old completed/failed tasks |
Info
| Tool | Description |
|---|---|
list_projects |
List all projects |
get_board_info |
Board dimensions, layers, components |
get_output_files |
List output files |
get_version |
Version info |
PCB Export
| Tool | Description |
|---|---|
export_gerber |
Gerber + Drill files |
export_3d |
3D render (top/bottom/iso/all) |
export_svg |
PCB SVG images |
export_pdf |
PCB PDF |
export_step |
STEP 3D model |
Schematic Export
| Tool | Description |
|---|---|
export_bom |
Bill of Materials (CSV) |
export_netlist |
Netlist (KiCad XML/SPICE) |
export_sch_pdf |
Schematic PDF |
export_sch_svg |
Schematic SVG |
Manufacturing
| Tool | Description |
|---|---|
export_jlcpcb |
Complete JLCPCB package |
export_all |
Export all files |
File
| Tool | Description |
|---|---|
read_file |
Read file content |
Complete Example Project
🎯 USB NVMe Adapter
A production-ready PCB design created entirely using KiCad MCP Server + Claude Code:
- Design: USB-C to M.2 NVMe adapter (4-layer PCB)
- Workflow: 100% AI-assisted design, no local EDA software
- Components: ASM2362 bridge, TPS62913 DC-DC, USB-C connector
- Outputs: Manufacturing files, 3D renders, complete documentation
See the complete example: examples/usb_nvme_adapter
Usage Examples
Basic Workflow
User: List projects
AI: [calls list_projects]
User: Run DRC on my_board
AI: [calls run_drc with project="my_board"]
User: Generate 3D renders
AI: [calls export_3d with project="my_board", view="all"]
User: Export for JLCPCB
AI: [calls export_jlcpcb with project="my_board"]
Auto-routing (Async)
User: Auto-route my_board
AI: [calls auto_route]
→ Returns task_id: "route_my_board_20241231_101530"
User: Check routing status
AI: [calls get_task_status with task_id]
→ {"status": "started", "log_tail": "..."}
# After completion:
AI: [calls get_task_status]
→ {"status": "completed", "message": "Auto-routing complete!"}
Output Directory Structure
project/output/
├── gerber/ # Gerber + Drill files
├── bom/ # BOM CSV
├── netlist/ # Netlist files
├── 3d/ # 3D renders (PNG) + STEP model
├── images/ # SVG images
├── docs/ # PDF documents
├── reports/ # DRC/ERC reports (JSON)
├── jlcpcb/ # Complete JLCPCB package
└── backup/ # Pre-autoroute backups
Project Sync
Use rsync to sync projects between local and VPS:
# Upload to VPS
rsync -avz ~/pcb/my_board/ vps:/root/pcb/projects/my_board/
# Download from VPS
rsync -avz vps:/root/pcb/projects/my_board/output/ ~/pcb/my_board/output/
Configuration
All server settings can be configured via environment variables. See .env.example for details.
Key Environment Variables
# Base directories
KICAD_MCP_PROJECTS_BASE=/root/pcb/projects
KICAD_MCP_TASKS_DIR=/root/pcb/tasks
# External tools
KICAD_MCP_KICAD_CLI=kicad-cli
KICAD_MCP_FREEROUTING_JAR=/opt/freerouting.jar
# Timeouts (seconds)
KICAD_MCP_DEFAULT_TIMEOUT=300
KICAD_MCP_AUTOROUTE_TIMEOUT=600
# File limits
KICAD_MCP_MAX_FILE_SIZE=10485760 # 10MB
# Render settings
KICAD_MCP_RENDER_WIDTH=1920
KICAD_MCP_RENDER_HEIGHT=1080
# Task cleanup
KICAD_MCP_TASK_MAX_AGE_DAYS=7
Security Features
v3.5.0 includes comprehensive security hardening:
- Path Validation - Prevents directory traversal attacks
- Restricted File Access -
read_filetool limited to projects/tasks directories - Shell Injection Prevention - Uses
shlex.quote()for all dynamic script generation - Input Validation - Project names sanitized to prevent path manipulation
- Safe Command Execution - Proper subprocess handling with timeout protection
Development
Running Tests
# Install dev dependencies
pip3 install -r requirements.txt
# Run tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=kicad_mcp_server --cov-report=html
Code Quality
# Type checking
mypy kicad_mcp_server/
# Linting
ruff check kicad_mcp_server/
License
GNU General Public License v3.0 or later - see LICENSE
Contributing
Issues and PRs welcome!
Acknowledgments
- KiCad - Open source EDA
- FreeRouting - Open source PCB auto-router
- Anthropic - Claude AI and MCP protocol
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kicad_mcp_server-3.5.0.tar.gz.
File metadata
- Download URL: kicad_mcp_server-3.5.0.tar.gz
- Upload date:
- Size: 68.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d95c86bb92b4c52c71e10c1fa1f58d52a5f23d6b4b47427d6524006447742be0
|
|
| MD5 |
83fd3bcf8fd8ba44660ff6761a30d389
|
|
| BLAKE2b-256 |
0923ee6a368cedb06a669b854d41e05c314b2b03d938c94e89d927c4a8440270
|
File details
Details for the file kicad_mcp_server-3.5.0-py3-none-any.whl.
File metadata
- Download URL: kicad_mcp_server-3.5.0-py3-none-any.whl
- Upload date:
- Size: 54.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04eb8f594ec824f6c524e72872f937d7bb0045b570aeeb792337774f00a0bf1b
|
|
| MD5 |
313970cd6c0ef2ec5f996f9c95456dc1
|
|
| BLAKE2b-256 |
3e127927d620c49543c16e894bab845abf34d6449192b7053aa7d20ad691ac63
|