Ryan Malloy 995dfd57c1 Add comprehensive advanced KiCad features and fix MCP compatibility issues
- Implement 3D model analysis and mechanical constraints checking
- Add advanced DRC rule customization for HDI, RF, and automotive applications
- Create symbol library management with analysis and validation tools
- Implement PCB layer stack-up analysis with impedance calculations
- Fix Context parameter validation errors causing client failures
- Add enhanced tool annotations with examples for better LLM compatibility
- Include comprehensive test coverage improvements (22.21% coverage)
- Add CLAUDE.md documentation for development guidance

New Advanced Tools:
• 3D model analysis: analyze_3d_models, check_mechanical_constraints
• Advanced DRC: create_drc_rule_set, analyze_pcb_drc_violations
• Symbol management: analyze_symbol_library, validate_symbol_library
• Layer analysis: analyze_pcb_stackup, calculate_trace_impedance

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 15:57:46 -06:00

48 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, "r") 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)}"