Skip to main content
Glama
lamaalrajih

KiCad MCP Server

by lamaalrajih

extract_project_netlist

Extract netlist information from KiCad schematic files to analyze circuit connections and component relationships in electronic design projects.

Instructions

Extract netlist from a KiCad project's schematic.

This tool finds the schematic associated with a KiCad project and extracts its netlist information.

Args: project_path: Path to the KiCad project file (.kicad_pro) ctx: MCP context for progress reporting

Returns: Dictionary with netlist information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYes
ctxYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the extract_project_netlist tool. It finds the schematic in the project, extracts the netlist using extract_schematic_netlist, and returns the results.
    @mcp.tool()
    async def extract_project_netlist(project_path: str, ctx: Context | None) -> Dict[str, Any]:
        """Extract netlist from a KiCad project's schematic.
        
        This tool finds the schematic associated with a KiCad project
        and extracts its netlist information.
        
        Args:
            project_path: Path to the KiCad project file (.kicad_pro)
            ctx: MCP context for progress reporting
            
        Returns:
            Dictionary with netlist information
        """
        print(f"Extracting netlist for project: {project_path}")
        
        if not os.path.exists(project_path):
            print(f"Project not found: {project_path}")
            if ctx:
                ctx.info(f"Project not found: {project_path}")
            return {"success": False, "error": f"Project not found: {project_path}"}
        
        # Report progress
        if ctx:
            await ctx.report_progress(10, 100)
        
        # Get the schematic file
        try:
            files = get_project_files(project_path)
            
            if "schematic" not in files:
                print("Schematic file not found in project")
                if ctx:
                    ctx.info("Schematic file not found in project")
                return {"success": False, "error": "Schematic file not found in project"}
            
            schematic_path = files["schematic"]
            print(f"Found schematic file: {schematic_path}")
            if ctx:
                ctx.info(f"Found schematic file: {os.path.basename(schematic_path)}")
            
            # Extract netlist
            if ctx:
                await ctx.report_progress(20, 100)
            
            # Call the schematic netlist extraction
            result = await extract_schematic_netlist(schematic_path, ctx)
            
            # Add project path to result
            if "success" in result and result["success"]:
                result["project_path"] = project_path
            
            return result
            
        except Exception as e:
            print(f"Error extracting project netlist: {str(e)}")
            if ctx:
                ctx.info(f"Error extracting project netlist: {str(e)}")
            return {"success": False, "error": str(e)}
  • The call to register_netlist_tools(mcp) in the server creation, which registers all netlist tools including extract_project_netlist.
    register_netlist_tools(mcp)

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