Some checks are pending
CI / Lint and Format (push) Waiting to run
CI / Test Python 3.11 on macos-latest (push) Waiting to run
CI / Test Python 3.12 on macos-latest (push) Waiting to run
CI / Test Python 3.13 on macos-latest (push) Waiting to run
CI / Test Python 3.10 on ubuntu-latest (push) Waiting to run
CI / Test Python 3.11 on ubuntu-latest (push) Waiting to run
CI / Test Python 3.12 on ubuntu-latest (push) Waiting to run
CI / Test Python 3.13 on ubuntu-latest (push) Waiting to run
CI / Security Scan (push) Waiting to run
CI / Build Package (push) Blocked by required conditions
Add intelligent analysis and recommendation tools for KiCad designs: ## New AI Tools (kicad_mcp/tools/ai_tools.py) - suggest_components_for_circuit: Smart component suggestions based on circuit analysis - recommend_design_rules: Automated design rule recommendations for different technologies - optimize_pcb_layout: PCB layout optimization for signal integrity, thermal, and cost - analyze_design_completeness: Comprehensive design completeness analysis ## Enhanced Utilities - component_utils.py: Add ComponentType enum and component classification functions - pattern_recognition.py: Enhanced circuit pattern analysis and recommendations - netlist_parser.py: Implement missing parse_netlist_file function for AI tools ## Key Features - Circuit pattern recognition for power supplies, amplifiers, microcontrollers - Technology-specific design rules (standard, HDI, RF, automotive) - Layout optimization suggestions with implementation steps - Component suggestion system with standard values and examples - Design completeness scoring with actionable recommendations ## Server Integration - Register AI tools in FastMCP server - Integrate with existing KiCad utilities and file parsers - Error handling and graceful fallbacks for missing data Fixes ImportError that prevented server startup and enables advanced AI-powered design assistance for KiCad projects. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
72 lines
2.2 KiB
Python
72 lines
2.2 KiB
Python
"""
|
|
Utility functions for detecting and selecting available KiCad API approaches.
|
|
"""
|
|
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
|
|
from kicad_mcp.config import system
|
|
|
|
|
|
def check_for_cli_api() -> bool:
|
|
"""Check if KiCad CLI API is available.
|
|
|
|
Returns:
|
|
True if KiCad CLI is available, False otherwise
|
|
"""
|
|
try:
|
|
# Check if kicad-cli is in PATH
|
|
if system == "Windows":
|
|
# On Windows, check for kicad-cli.exe
|
|
kicad_cli = shutil.which("kicad-cli.exe")
|
|
else:
|
|
# On Unix-like systems
|
|
kicad_cli = shutil.which("kicad-cli")
|
|
|
|
if kicad_cli:
|
|
# Verify it's a working kicad-cli
|
|
if system == "Windows":
|
|
cmd = [kicad_cli, "--version"]
|
|
else:
|
|
cmd = [kicad_cli, "--version"]
|
|
|
|
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
if result.returncode == 0:
|
|
print(f"Found working kicad-cli: {kicad_cli}")
|
|
return True
|
|
|
|
# Check common installation locations if not found in PATH
|
|
if system == "Windows":
|
|
# Common Windows installation paths
|
|
potential_paths = [
|
|
r"C:\Program Files\KiCad\bin\kicad-cli.exe",
|
|
r"C:\Program Files (x86)\KiCad\bin\kicad-cli.exe",
|
|
]
|
|
elif system == "Darwin": # macOS
|
|
# Common macOS installation paths
|
|
potential_paths = [
|
|
"/Applications/KiCad/KiCad.app/Contents/MacOS/kicad-cli",
|
|
"/Applications/KiCad/kicad-cli",
|
|
]
|
|
else: # Linux
|
|
# Common Linux installation paths
|
|
potential_paths = [
|
|
"/usr/bin/kicad-cli",
|
|
"/usr/local/bin/kicad-cli",
|
|
"/opt/kicad/bin/kicad-cli",
|
|
]
|
|
|
|
# Check each potential path
|
|
for path in potential_paths:
|
|
if os.path.exists(path) and os.access(path, os.X_OK):
|
|
print(f"Found kicad-cli at common location: {path}")
|
|
return True
|
|
|
|
print("KiCad CLI API is not available")
|
|
return False
|
|
|
|
except Exception as e:
|
|
print(f"Error checking for KiCad CLI API: {str(e)}")
|
|
return False
|