Skip to main content
Glama
lamaalrajih

KiCad MCP Server

by lamaalrajih

open_project

Open a KiCad project to access and work with electronic design files for PCB development and analysis.

Instructions

Open a KiCad project in KiCad.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYes

Implementation Reference

  • The handler function for the 'open_project' tool, decorated with @mcp.tool() and delegating to the helper function open_kicad_project.
    @mcp.tool()
    def open_project(project_path: str) -> Dict[str, Any]:
        """Open a KiCad project in KiCad."""
        return open_kicad_project(project_path)
  • Top-level registration call in the main server creation that registers all project tools, including 'open_project', via register_project_tools.
    register_project_tools(mcp)
  • Supporting utility function that executes the subprocess command to open the KiCad project in the appropriate application based on the operating system.
    def open_kicad_project(project_path: str) -> Dict[str, Any]:
        """Open a KiCad project using the KiCad application.
        
        Args:
            project_path: Path to the .kicad_pro file
            
        Returns:
            Dictionary with result information
        """
        if not os.path.exists(project_path):
            return {"success": False, "error": f"Project not found: {project_path}"}
        
        try:
            cmd = []
            if sys.platform == "darwin":  # macOS
                # On MacOS, use the 'open' command to open the project in KiCad
                cmd = ["open", "-a", config.KICAD_APP_PATH, project_path]
            elif sys.platform == "linux": # Linux
                # On Linux, use 'xdg-open'
                cmd = ["xdg-open", project_path]
            else:
                # Fallback or error for unsupported OS
                return {"success": False, "error": f"Unsupported operating system: {sys.platform}"}
    
            result = subprocess.run(cmd, capture_output=True, text=True)
            
            return {
                "success": result.returncode == 0,
                "command": " ".join(cmd),
                "output": result.stdout,
                "error": result.stderr if result.returncode != 0 else None
            }
        
        except Exception as e:
            return {"success": False, "error": str(e)}

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