Skip to main content
Glama
lamaalrajih

KiCad MCP Server

by lamaalrajih

validate_project

Validate KiCad electronic design projects to check for errors and ensure proper functionality before manufacturing.

Instructions

Basic validation of a KiCad project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYes

Implementation Reference

  • The core handler function for the 'validate_project' tool. It validates a KiCad project by checking if the path exists, essential files (PCB and schematic) are present, and the project file is valid JSON.
    @mcp.tool()
    def validate_project(project_path: str) -> Dict[str, Any]:
        """Basic validation of a KiCad project."""
        if not os.path.exists(project_path):
            return {"valid": False, "error": f"Project not found: {project_path}"}
        
        issues = []
        files = get_project_files(project_path)
        
        # Check for essential files
        if "pcb" not in files:
            issues.append("Missing PCB layout file")
        
        if "schematic" not in files:
            issues.append("Missing schematic file")
        
        # Validate project file
        try:
            with open(project_path, 'r') as f:
                import json
                json.load(f)
        except json.JSONDecodeError:
            issues.append("Invalid project file format (JSON parsing error)")
        except Exception as e:
            issues.append(f"Error reading project file: {str(e)}")
        
        return {
            "valid": len(issues) == 0,
            "path": project_path,
            "issues": issues if issues else None,
            "files_found": list(files.keys())
        }
  • The registration function that defines and decorates the validate_project tool using @mcp.tool().
    def register_analysis_tools(mcp: FastMCP) -> None:
        """Register analysis and validation tools with the MCP server.
        
        Args:
            mcp: The FastMCP server instance
        """
  • Top-level registration block in the server creation where register_analysis_tools(mcp) is called to register the validate_project tool among others.
    # Register tools
    logging.info(f"Registering tools...")
    register_project_tools(mcp)
    register_analysis_tools(mcp)
    register_export_tools(mcp)
    register_drc_tools(mcp)
    register_bom_tools(mcp)
    register_netlist_tools(mcp)
    register_pattern_tools(mcp)
  • Import of the register_analysis_tools function used to register the validate_project tool.
    from kicad_mcp.tools.analysis_tools import register_analysis_tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lamaalrajih/kicad-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server