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>
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""
|
|
File content resources for KiCad files.
|
|
"""
|
|
|
|
import os
|
|
|
|
from mcp.server.fastmcp import FastMCP
|
|
|
|
|
|
def register_file_resources(mcp: FastMCP) -> None:
|
|
"""Register file-related resources with the MCP server.
|
|
|
|
Args:
|
|
mcp: The FastMCP server instance
|
|
"""
|
|
|
|
@mcp.resource("kicad://schematic/{schematic_path}")
|
|
def get_schematic_info(schematic_path: str) -> str:
|
|
"""Extract information from a KiCad schematic file."""
|
|
if not os.path.exists(schematic_path):
|
|
return f"Schematic file not found: {schematic_path}"
|
|
|
|
# KiCad schematic files are in S-expression format (not JSON)
|
|
# This is a basic extraction of text-based information
|
|
try:
|
|
with open(schematic_path) as f:
|
|
content = f.read()
|
|
|
|
# Basic extraction of components
|
|
components = []
|
|
for line in content.split("\n"):
|
|
if "(symbol " in line and "lib_id" in line:
|
|
components.append(line.strip())
|
|
|
|
result = f"# Schematic: {os.path.basename(schematic_path)}\n\n"
|
|
result += f"## Components (Estimated Count: {len(components)})\n\n"
|
|
|
|
# Extract a sample of components
|
|
for i, comp in enumerate(components[:10]):
|
|
result += f"{comp}\n"
|
|
|
|
if len(components) > 10:
|
|
result += f"\n... and {len(components) - 10} more components\n"
|
|
|
|
return result
|
|
|
|
except Exception as e:
|
|
return f"Error reading schematic file: {str(e)}"
|