feat: Week 1 complete - Linux support + IPC API prep

🎉 Major v2.0 rebuild kickoff - Week 1 accomplished!

## Highlights

### Cross-Platform Support 🌍
-  Linux primary platform (Ubuntu/Debian tested)
-  Windows fully supported
-  macOS experimental support
-  Platform-agnostic path handling (XDG spec)
-  Auto-detection of KiCAD installation

### Infrastructure 🏗️
-  GitHub Actions CI/CD pipeline
-  Pytest framework with 20+ tests
-  Pre-commit hooks (Black, MyPy, ESLint)
-  Automated Linux installation script
-  Enhanced npm scripts

### IPC API Migration Prep 🚀
-  Comprehensive migration plan (30 pages)
-  Backend abstraction layer (800+ lines)
-  Factory pattern with auto-detection
-  SWIG backward compatibility wrapper
-  IPC backend skeleton ready

### Documentation 📚
-  Updated README (Linux installation)
-  CONTRIBUTING.md guide
-  Linux compatibility audit
-  IPC API migration plan
-  Session summaries
-  Platform-specific config templates

## Files Changed

- 27 files created
- ~3,000 lines of code/docs
- 8 comprehensive documentation pages
- 20+ unit tests
- 5 abstraction layer modules

## Next Steps

- Week 2: IPC API migration (project.py → component.py → routing.py)
- Migrate from deprecated SWIG to official IPC API
- JLCPCB/Digikey integration prep

🤖 Generated with Claude Code
https://claude.com/claude-code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
KiCAD MCP Bot
2025-10-25 20:48:00 -04:00
commit e4c7119c51
81 changed files with 16003 additions and 0 deletions

231
src/prompts/component.ts Normal file
View File

@@ -0,0 +1,231 @@
/**
* Component prompts for KiCAD MCP server
*
* These prompts guide the LLM in providing assistance with component-related tasks
* in KiCAD PCB design.
*/
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';
import { logger } from '../logger.js';
/**
* Register component prompts with the MCP server
*
* @param server MCP server instance
*/
export function registerComponentPrompts(server: McpServer): void {
logger.info('Registering component prompts');
// ------------------------------------------------------
// Component Selection Prompt
// ------------------------------------------------------
server.prompt(
"component_selection",
{
requirements: z.string().describe("Description of the circuit requirements and constraints")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping to select components for a circuit design. Given the following requirements:
{{requirements}}
Suggest appropriate components with their values, ratings, and footprints. Consider factors like:
- Power and voltage ratings
- Current handling capabilities
- Tolerance requirements
- Physical size constraints and package types
- Availability and cost considerations
- Thermal characteristics
- Performance specifications
For each component type, recommend specific values and provide a brief explanation of your recommendation. If appropriate, suggest alternatives with different trade-offs.`
}
}
]
})
);
// ------------------------------------------------------
// Component Placement Strategy Prompt
// ------------------------------------------------------
server.prompt(
"component_placement_strategy",
{
components: z.string().describe("List of components to be placed on the PCB")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping with component placement for a PCB layout. Here are the components to place:
{{components}}
Provide a strategy for optimal placement considering:
1. Signal Integrity:
- Group related components to minimize signal path length
- Keep sensitive signals away from noisy components
- Consider appropriate placement for bypass/decoupling capacitors
2. Thermal Management:
- Distribute heat-generating components
- Ensure adequate spacing for cooling
- Placement near heat sinks or vias for thermal dissipation
3. EMI/EMC Concerns:
- Separate digital and analog sections
- Consider ground plane partitioning
- Shield sensitive components
4. Manufacturing and Assembly:
- Component orientation for automated assembly
- Adequate spacing for rework
- Consider component height distribution
Group components functionally and suggest a logical arrangement. If possible, provide a rough sketch or description of component zones.`
}
}
]
})
);
// ------------------------------------------------------
// Component Replacement Analysis Prompt
// ------------------------------------------------------
server.prompt(
"component_replacement_analysis",
{
component_info: z.string().describe("Information about the component that needs to be replaced")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping to find a replacement for a component that is unavailable or needs to be updated. Here's the original component information:
{{component_info}}
Consider these factors when suggesting replacements:
1. Electrical Compatibility:
- Match or exceed key electrical specifications
- Ensure voltage/current/power ratings are compatible
- Consider parametric equivalents
2. Physical Compatibility:
- Footprint compatibility or adaptation requirements
- Package differences and mounting considerations
- Size and clearance requirements
3. Performance Impact:
- How the replacement might affect circuit performance
- Potential need for circuit adjustments
4. Availability and Cost:
- Current market availability
- Cost comparison with original part
- Lead time considerations
Suggest suitable replacement options and explain the advantages and disadvantages of each. Include any circuit modifications that might be necessary.`
}
}
]
})
);
// ------------------------------------------------------
// Component Troubleshooting Prompt
// ------------------------------------------------------
server.prompt(
"component_troubleshooting",
{
issue_description: z.string().describe("Description of the component or circuit issue being troubleshooted")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping to troubleshoot an issue with a component or circuit section in a PCB design. Here's the issue description:
{{issue_description}}
Use the following systematic approach to diagnose the problem:
1. Component Verification:
- Check component values, footprints, and orientation
- Verify correct part numbers and specifications
- Examine for potential manufacturing defects
2. Circuit Analysis:
- Review the schematic for design errors
- Check for proper connections and signal paths
- Verify power and ground connections
3. Layout Review:
- Examine component placement and orientation
- Check for adequate clearances
- Review trace routing and potential interference
4. Environmental Factors:
- Consider temperature, humidity, and other environmental impacts
- Check for potential EMI/RFI issues
- Review mechanical stress or vibration effects
Based on the available information, suggest likely causes of the issue and recommend specific steps to diagnose and resolve the problem.`
}
}
]
})
);
// ------------------------------------------------------
// Component Value Calculation Prompt
// ------------------------------------------------------
server.prompt(
"component_value_calculation",
{
circuit_requirements: z.string().describe("Description of the circuit function and performance requirements")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping to calculate appropriate component values for a specific circuit function. Here's the circuit description and requirements:
{{circuit_requirements}}
Follow these steps to determine the optimal component values:
1. Identify the relevant circuit equations and design formulas
2. Consider the design constraints and performance requirements
3. Calculate initial component values based on ideal behavior
4. Adjust for real-world factors:
- Component tolerances
- Temperature coefficients
- Parasitic effects
- Available standard values
Present your calculations step-by-step, showing your work and explaining your reasoning. Recommend specific component values, explaining why they're appropriate for this application. If there are multiple valid approaches, discuss the trade-offs between them.`
}
}
]
})
);
logger.info('Component prompts registered');
}

321
src/prompts/design.ts Normal file
View File

@@ -0,0 +1,321 @@
/**
* Design prompts for KiCAD MCP server
*
* These prompts guide the LLM in providing assistance with general PCB design tasks
* in KiCAD.
*/
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';
import { logger } from '../logger.js';
/**
* Register design prompts with the MCP server
*
* @param server MCP server instance
*/
export function registerDesignPrompts(server: McpServer): void {
logger.info('Registering design prompts');
// ------------------------------------------------------
// PCB Layout Review Prompt
// ------------------------------------------------------
server.prompt(
"pcb_layout_review",
{
pcb_design_info: z.string().describe("Information about the current PCB design, including board dimensions, layer stack-up, component placement, and routing details")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping to review a PCB layout for potential issues and improvements. Here's information about the current PCB design:
{{pcb_design_info}}
When reviewing the PCB layout, consider these key areas:
1. Component Placement:
- Logical grouping of related components
- Orientation for efficient routing
- Thermal considerations for heat-generating components
- Mechanical constraints (mounting holes, connectors at edges)
- Accessibility for testing and rework
2. Signal Integrity:
- Trace lengths for critical signals
- Differential pair routing quality
- Potential crosstalk issues
- Return path continuity
- Decoupling capacitor placement
3. Power Distribution:
- Adequate copper for power rails
- Power plane design and continuity
- Decoupling strategy effectiveness
- Voltage regulator thermal management
4. EMI/EMC Considerations:
- Ground plane integrity
- Potential antenna effects
- Shielding requirements
- Loop area minimization
- Edge radiation control
5. Manufacturing and Assembly:
- DFM (Design for Manufacturing) issues
- DFA (Design for Assembly) considerations
- Testability features
- Silkscreen clarity and usefulness
- Solder mask considerations
Based on the provided information, identify potential issues and suggest specific improvements to enhance the PCB design.`
}
}
]
})
);
// ------------------------------------------------------
// Layer Stack-up Planning Prompt
// ------------------------------------------------------
server.prompt(
"layer_stackup_planning",
{
design_requirements: z.string().describe("Information about the PCB design requirements, including signal types, speed/frequency, power requirements, and any special considerations")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping to plan an appropriate layer stack-up for a PCB design. Here's information about the design requirements:
{{design_requirements}}
When planning a PCB layer stack-up, consider these important factors:
1. Signal Integrity Requirements:
- Controlled impedance needs
- High-speed signal routing
- EMI/EMC considerations
- Crosstalk mitigation
2. Power Distribution Needs:
- Current requirements for power rails
- Power integrity considerations
- Decoupling effectiveness
- Thermal management
3. Manufacturing Constraints:
- Fabrication capabilities and limitations
- Cost considerations
- Available materials and their properties
- Standard vs. specialized processes
4. Layer Types and Arrangement:
- Signal layers
- Power and ground planes
- Mixed signal/plane layers
- Microstrip vs. stripline configurations
5. Material Selection:
- Dielectric constant (Er) requirements
- Loss tangent considerations for high-speed
- Thermal properties
- Mechanical stability
Based on the provided requirements, recommend an appropriate layer stack-up, including the number of layers, their arrangement, material specifications, and thickness parameters. Explain the rationale behind your recommendations.`
}
}
]
})
);
// ------------------------------------------------------
// Design Rule Development Prompt
// ------------------------------------------------------
server.prompt(
"design_rule_development",
{
project_requirements: z.string().describe("Information about the PCB project requirements, including technology, speed/frequency, manufacturing capabilities, and any special considerations")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping to develop appropriate design rules for a PCB project. Here's information about the project requirements:
{{project_requirements}}
When developing PCB design rules, consider these key areas:
1. Clearance Rules:
- Minimum spacing between copper features
- Different clearance requirements for different net classes
- High-voltage clearance requirements
- Polygon pour clearances
2. Width Rules:
- Minimum trace widths for signal nets
- Power trace width requirements based on current
- Differential pair width and spacing
- Net class-specific width rules
3. Via Rules:
- Minimum via size and drill diameter
- Via annular ring requirements
- Microvias and buried/blind via specifications
- Via-in-pad rules
4. Manufacturing Constraints:
- Minimum hole size
- Aspect ratio limitations
- Soldermask and silkscreen constraints
- Edge clearances
5. Special Requirements:
- Impedance control specifications
- High-speed routing constraints
- Thermal relief parameters
- Teardrop specifications
Based on the provided project requirements, recommend a comprehensive set of design rules that will ensure signal integrity, manufacturability, and reliability of the PCB. Provide specific values where appropriate and explain the rationale behind critical rules.`
}
}
]
})
);
// ------------------------------------------------------
// Component Selection Guidance Prompt
// ------------------------------------------------------
server.prompt(
"component_selection_guidance",
{
circuit_requirements: z.string().describe("Information about the circuit requirements, including functionality, performance needs, operating environment, and any special considerations")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping with component selection for a PCB design. Here's information about the circuit requirements:
{{circuit_requirements}}
When selecting components for a PCB design, consider these important factors:
1. Electrical Specifications:
- Voltage and current ratings
- Power handling capabilities
- Speed/frequency requirements
- Noise and precision considerations
- Operating temperature range
2. Package and Footprint:
- Space constraints on the PCB
- Thermal dissipation requirements
- Manual vs. automated assembly
- Inspection and rework considerations
- Available footprint libraries
3. Availability and Sourcing:
- Multiple source options
- Lead time considerations
- Lifecycle status (new, mature, end-of-life)
- Cost considerations
- Minimum order quantities
4. Reliability and Quality:
- Industrial vs. commercial vs. automotive grade
- Expected lifetime of the product
- Environmental conditions
- Compliance with relevant standards
5. Special Considerations:
- EMI/EMC performance
- Thermal characteristics
- Moisture sensitivity
- RoHS/REACH compliance
- Special handling requirements
Based on the provided circuit requirements, recommend appropriate component types, packages, and specific considerations for this design. Provide guidance on critical component selections and explain the rationale behind your recommendations.`
}
}
]
})
);
// ------------------------------------------------------
// PCB Design Optimization Prompt
// ------------------------------------------------------
server.prompt(
"pcb_design_optimization",
{
design_info: z.string().describe("Information about the current PCB design, including board dimensions, layer stack-up, component placement, and routing details"),
optimization_goals: z.string().describe("Specific goals for optimization, such as performance improvement, cost reduction, size reduction, or manufacturability enhancement")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping to optimize a PCB design. Here's information about the current design and optimization goals:
{{design_info}}
{{optimization_goals}}
When optimizing a PCB design, consider these key areas based on the stated goals:
1. Performance Optimization:
- Critical signal path length reduction
- Impedance control improvement
- Decoupling strategy enhancement
- Thermal management improvement
- EMI/EMC reduction techniques
2. Manufacturability Optimization:
- DFM rule compliance
- Testability improvements
- Assembly process simplification
- Yield improvement opportunities
- Tolerance and variation management
3. Cost Optimization:
- Board size reduction opportunities
- Layer count optimization
- Component consolidation
- Alternative component options
- Panelization efficiency
4. Reliability Optimization:
- Stress point identification and mitigation
- Environmental robustness improvements
- Failure mode mitigation
- Margin analysis and improvement
- Redundancy considerations
5. Space/Size Optimization:
- Component placement density
- 3D space utilization
- Flex and rigid-flex opportunities
- Alternative packaging approaches
- Connector and interface optimization
Based on the provided information and optimization goals, suggest specific, actionable improvements to the PCB design. Prioritize your recommendations based on their potential impact and implementation feasibility.`
}
}
]
})
);
logger.info('Design prompts registered');
}

9
src/prompts/index.ts Normal file
View File

@@ -0,0 +1,9 @@
/**
* Prompts index for KiCAD MCP server
*
* Exports all prompt registration functions
*/
export { registerComponentPrompts } from './component.js';
export { registerRoutingPrompts } from './routing.js';
export { registerDesignPrompts } from './design.js';

288
src/prompts/routing.ts Normal file
View File

@@ -0,0 +1,288 @@
/**
* Routing prompts for KiCAD MCP server
*
* These prompts guide the LLM in providing assistance with routing-related tasks
* in KiCAD PCB design.
*/
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';
import { logger } from '../logger.js';
/**
* Register routing prompts with the MCP server
*
* @param server MCP server instance
*/
export function registerRoutingPrompts(server: McpServer): void {
logger.info('Registering routing prompts');
// ------------------------------------------------------
// Routing Strategy Prompt
// ------------------------------------------------------
server.prompt(
"routing_strategy",
{
board_info: z.string().describe("Information about the PCB board, including dimensions, layer stack-up, and components")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping to develop a routing strategy for a PCB design. Here's information about the board:
{{board_info}}
Consider the following aspects when developing your routing strategy:
1. Signal Integrity:
- Group related signals and keep them close
- Minimize trace length for high-speed signals
- Consider differential pair routing for appropriate signals
- Avoid right-angle bends in traces
2. Power Distribution:
- Use appropriate trace widths for power and ground
- Consider using power planes for better distribution
- Place decoupling capacitors close to ICs
3. EMI/EMC Considerations:
- Keep digital and analog sections separated
- Consider ground plane partitioning
- Minimize loop areas for sensitive signals
4. Manufacturing Constraints:
- Adhere to minimum trace width and spacing requirements
- Consider via size and placement restrictions
- Account for soldermask and silkscreen limitations
5. Layer Stack-up Utilization:
- Determine which signals go on which layers
- Plan for layer transitions (vias)
- Consider impedance control requirements
Provide a comprehensive routing strategy that addresses these aspects, with specific recommendations for this particular board design.`
}
}
]
})
);
// ------------------------------------------------------
// Differential Pair Routing Prompt
// ------------------------------------------------------
server.prompt(
"differential_pair_routing",
{
differential_pairs: z.string().describe("Information about the differential pairs to be routed, including signal names, source and destination components, and speed/frequency requirements")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping with routing differential pairs on a PCB. Here's information about the differential pairs:
{{differential_pairs}}
When routing differential pairs, follow these best practices:
1. Length Matching:
- Keep both traces in each pair the same length
- Maintain consistent spacing between the traces
- Use serpentine routing (meanders) for length matching when necessary
2. Impedance Control:
- Maintain consistent trace width and spacing to control impedance
- Consider the layer stack-up and dielectric properties
- Avoid changing layers if possible; when necessary, use symmetrical via pairs
3. Coupling and Crosstalk:
- Keep differential pairs tightly coupled to each other
- Maintain adequate spacing between different differential pairs
- Route away from single-ended signals that could cause interference
4. Reference Planes:
- Route over continuous reference planes
- Avoid splits in reference planes under differential pairs
- Consider the return path for the signals
5. Termination:
- Plan for proper termination at the ends of the pairs
- Consider the need for series or parallel termination resistors
- Place termination components close to the endpoints
Based on the provided information, suggest specific routing approaches for these differential pairs, including recommended trace width, spacing, and any special considerations for this particular design.`
}
}
]
})
);
// ------------------------------------------------------
// High-Speed Routing Prompt
// ------------------------------------------------------
server.prompt(
"high_speed_routing",
{
high_speed_signals: z.string().describe("Information about the high-speed signals to be routed, including signal names, source and destination components, and speed/frequency requirements")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping with routing high-speed signals on a PCB. Here's information about the high-speed signals:
{{high_speed_signals}}
When routing high-speed signals, consider these critical factors:
1. Impedance Control:
- Maintain consistent trace width to control impedance
- Use controlled impedance calculations based on layer stack-up
- Consider microstrip vs. stripline routing depending on signal requirements
2. Signal Integrity:
- Minimize trace length to reduce propagation delay
- Avoid sharp corners (use 45° angles or curves)
- Minimize vias to reduce discontinuities
- Consider using teardrops at pad connections
3. Crosstalk Mitigation:
- Maintain adequate spacing between high-speed traces
- Use ground traces or planes for isolation
- Cross traces at 90° when traces must cross on adjacent layers
4. Return Path Management:
- Ensure continuous return path under the signal
- Avoid reference plane splits under high-speed signals
- Use ground vias near signal vias for return path continuity
5. Termination and Loading:
- Plan for proper termination (series, parallel, AC, etc.)
- Consider transmission line effects
- Account for capacitive loading from components and vias
Based on the provided information, suggest specific routing approaches for these high-speed signals, including recommended trace width, layer assignment, and any special considerations for this particular design.`
}
}
]
})
);
// ------------------------------------------------------
// Power Distribution Prompt
// ------------------------------------------------------
server.prompt(
"power_distribution",
{
power_requirements: z.string().describe("Information about the power requirements, including voltage rails, current needs, and components requiring power")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping with designing the power distribution network for a PCB. Here's information about the power requirements:
{{power_requirements}}
Consider these key aspects of power distribution network design:
1. Power Planes vs. Traces:
- Determine when to use power planes versus wide traces
- Consider current requirements and voltage drop
- Plan the layer stack-up to accommodate power distribution
2. Decoupling Strategy:
- Place decoupling capacitors close to ICs
- Use appropriate capacitor values and types
- Consider high-frequency and bulk decoupling needs
- Plan for power entry filtering
3. Current Capacity:
- Calculate trace widths based on current requirements
- Consider thermal issues and heat dissipation
- Plan for current return paths
4. Voltage Regulation:
- Place regulators strategically
- Consider thermal management for regulators
- Plan feedback paths for regulators
5. EMI/EMC Considerations:
- Minimize loop areas
- Keep power and ground planes closely coupled
- Consider filtering for noise-sensitive circuits
Based on the provided information, suggest a comprehensive power distribution strategy, including specific recommendations for plane usage, trace widths, decoupling, and any special considerations for this particular design.`
}
}
]
})
);
// ------------------------------------------------------
// Via Usage Prompt
// ------------------------------------------------------
server.prompt(
"via_usage",
{
board_info: z.string().describe("Information about the PCB board, including layer count, thickness, and design requirements")
},
() => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `You're helping with planning via usage in a PCB design. Here's information about the board:
{{board_info}}
Consider these important aspects of via usage:
1. Via Types:
- Through-hole vias (span all layers)
- Blind vias (connect outer layer to inner layer)
- Buried vias (connect inner layers only)
- Microvias (small diameter vias for HDI designs)
2. Manufacturing Constraints:
- Minimum via diameter and drill size
- Aspect ratio limitations (board thickness to hole diameter)
- Annular ring requirements
- Via-in-pad considerations and special processing
3. Signal Integrity Impact:
- Capacitive loading effects of vias
- Impedance discontinuities
- Stub effects in through-hole vias
- Strategies to minimize via impact on high-speed signals
4. Thermal Considerations:
- Using vias for thermal relief
- Via patterns for heat dissipation
- Thermal via sizing and spacing
5. Design Optimization:
- Via fanout strategies
- Sharing vias between signals vs. dedicated vias
- Via placement to minimize trace length
- Tenting and plugging options
Based on the provided information, recommend appropriate via strategies for this PCB design, including specific via types, sizes, and placement guidelines.`
}
}
]
})
);
logger.info('Routing prompts registered');
}