
Implements a more reliable PCB thumbnail generation feature using two methods: - Primary: pcbnew Python module for high-quality rendering - Fallback: pcbnew_cli for environments without Python modules Adds detailed progress reporting and comprehensive error handling. Includes documentation in docs/thumbnail_guide.md.
KiCad MCP Server
⚠️ WARNING: This project was quickly hacked together and is largely untested. Expect things to break. Use at your own risk. I plan on improving it over time, but if you find bugs, please open an issue or submit a pull request to fix them (see Contributing section below).
This guide will help you set up a Model Context Protocol (MCP) server for KiCad on macOS, allowing you to interact with KiCad projects through Claude Desktop or other MCP-compatible clients.
Table of Contents
- Prerequisites
- Project Structure
- Installation Steps
- Understanding MCP Components
- Available Features
- Development Guide
- Troubleshooting
- Contributing
- Future Development Ideas
- License
Prerequisites
- macOS with KiCad installed
- Python 3.10 or higher
- Claude Desktop (or another MCP client)
- Basic familiarity with the terminal
Project Structure
The KiCad MCP Server is organized into a modular structure for better maintainability:
kicad-mcp/
├── README.md # Project documentation
├── main.py # Entry point that runs the server
├── config.py # Configuration constants and settings
├── requirements.txt # Python dependencies
├── kicad_mcp/ # Main package directory
│ ├── __init__.py # Package initialization
│ ├── server.py # MCP server setup
│ ├── resources/ # Resource handlers
│ ├── tools/ # Tool handlers
│ ├── prompts/ # Prompt templates
│ └── utils/ # Utility functions
└── tests/ # Unit tests
Installation Steps
1. Set Up Your Python Environment
First, let's install pip
and set up our environment:
# Create a new directory for our project
mkdir -p ~/Projects/kicad-mcp
cd ~/Projects/kicad-mcp
# Create a virtual environment and activate it
python3 -m venv venv
source venv/bin/activate
# Install the MCP SDK and other dependencies
pip install -r requirements.txt
2. Run the Server
Once the environment is set up, you can run the server:
# Run in development mode
python -m mcp.dev main.py
# Or run directly
python main.py
3. Configure Claude Desktop
Now, let's configure Claude Desktop to use our MCP server:
- Create or edit the Claude Desktop configuration file:
# Create the directory if it doesn't exist
mkdir -p ~/Library/Application\ Support/Claude
# Edit the configuration file (or create it if it doesn't exist)
vim ~/Library/Application\ Support/Claude/claude_desktop_config.json
- Add the KiCad MCP server to the configuration:
{
"mcpServers": {
"kicad": {
"command": "/ABSOLUTE/PATH/TO/YOUR/PROJECT/kicad-mcp/venv/bin/python",
"args": [
"/ABSOLUTE/PATH/TO/YOUR/PROJECT/kicad-mcp/main.py"
]
}
}
}
Replace /ABSOLUTE/PATH/TO/YOUR/PROJECT/kicad-mcp
with the actual path to your project directory (e.g., /Users/yourusername/Projects/kicad-mcp
).
- Save the file and exit the editor.
4. Restart Claude Desktop
Close and reopen Claude Desktop to load the new configuration.
Understanding MCP Components
The Model Context Protocol (MCP) defines three primary ways to provide capabilities:
Resources vs Tools vs Prompts
Resources are read-only data sources that LLMs can reference:
- Similar to GET endpoints in REST APIs
- Provide data without performing significant computation
- Used when the LLM needs to read information
- Typically accessed programmatically by the client application
- Example:
kicad://projects
returns a list of all KiCad projects
Tools are functions that perform actions or computations:
- Similar to POST/PUT endpoints in REST APIs
- Can have side effects (like opening applications or generating files)
- Used when the LLM needs to perform actions in the world
- Typically invoked directly by the LLM (with user approval)
- Example:
open_project()
launches KiCad with a specific project
Prompts are reusable templates for common interactions:
- Pre-defined conversation starters or instructions
- Help users articulate common questions or tasks
- Invoked by user choice (typically from a menu)
- Example: The
debug_pcb_issues
prompt helps users troubleshoot PCB problems
Available Features
The KiCad MCP Server provides several capabilities:
Resources
kicad://projects
- List all KiCad projectskicad://project/{path}
- Get details about a specific projectkicad://schematic/{path}
- Extract information from a schematic filekicad://drc/{path}
- Get a detailed Design Rule Check report for a PCBkicad://drc/history/{path}
- Get DRC history report with trend analysis
Tools
- Project management tools (find projects, get structure, open in KiCad)
- Analysis tools (validate projects, generate thumbnails)
- Export tools (extract bill of materials)
- Design Rule Check tools (run DRC checks, get detailed violation reports, track DRC history and improvements over time)
- PCB Visualization - Generate thumbnails of PCB layouts for easy project identification (see guide)
Prompts
- Create new component guide
- Debug PCB issues guide
- PCB manufacturing checklist
Development Guide
Adding New Features
To add new features to the KiCad MCP Server, follow these steps:
- Identify the category for your feature (resource, tool, or prompt)
- Add your implementation to the appropriate module
- Register your feature in the corresponding register function
- Test your changes with the development tools
Example for adding a new tool:
# kicad_mcp/tools/analysis_tools.py
@mcp.tool()
def new_analysis_tool(project_path: str) -> Dict[str, Any]:
"""Description of your new tool."""
# Implementation goes here
return {"result": "success"}
Running Tests
This project uses pytest for testing:
# Install development dependencies
pip install pytest
# Run tests
pytest
Troubleshooting
If you encounter issues:
-
Server Not Appearing in Claude Desktop:
- Check your
claude_desktop_config.json
file for errors - Make sure the path to your project and Python interpreter is correct
- Ensure Python can access the
mcp
package
- Check your
-
Server Errors:
- Check the terminal output when running the server in development mode
- Make sure all required Python packages are installed
- Verify that your KiCad installation is in the standard location
Contributing
Want to contribute to the KiCad MCP Server? Here's how you can help improve this project:
- Fork the repository
- Create a feature branch
- Add your changes
- Submit a pull request
Future Development Ideas
Interested in contributing? Here are some ideas for future development:
- Implement 3D model visualization tools
- Create PCB review tools with annotations
- Add support for generating manufacturing files
- Implement component search tools
- Add tests!
License
This project is open source under the MIT license.