Skip to main content
Glama
lamaalrajih

KiCad MCP Server

by lamaalrajih

extract_schematic_netlist

Extract netlist data from KiCad schematic files to analyze components, connections, and labels for circuit design verification.

Instructions

Extract netlist information from a KiCad schematic.

This tool parses a KiCad schematic file and extracts comprehensive netlist information including components, connections, and labels.

Args: schematic_path: Path to the KiCad schematic file (.kicad_sch) ctx: MCP context for progress reporting

Returns: Dictionary with netlist information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schematic_pathYes
ctxYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler for the 'extract_schematic_netlist' tool. Decorated with @mcp.tool(), it handles input validation, progress reporting, calls helper functions extract_netlist and analyze_netlist, and constructs the response dictionary with components, nets, and analysis results.
    @mcp.tool()
    async def extract_schematic_netlist(schematic_path: str, ctx: Context | None) -> Dict[str, Any]:
        """Extract netlist information from a KiCad schematic.
        
        This tool parses a KiCad schematic file and extracts comprehensive
        netlist information including components, connections, and labels.
        
        Args:
            schematic_path: Path to the KiCad schematic file (.kicad_sch)
            ctx: MCP context for progress reporting
            
        Returns:
            Dictionary with netlist information
        """
        print(f"Extracting netlist from schematic: {schematic_path}")
        
        if not os.path.exists(schematic_path):
            print(f"Schematic file not found: {schematic_path}")
            if ctx:
                ctx.info(f"Schematic file not found: {schematic_path}")
            return {"success": False, "error": f"Schematic file not found: {schematic_path}"}
        
        # Report progress
        if ctx:
            await ctx.report_progress(10, 100)
            ctx.info(f"Loading schematic file: {os.path.basename(schematic_path)}")
        
        # Extract netlist information
        try:
            if ctx:
                await ctx.report_progress(20, 100)
                ctx.info("Parsing schematic structure...")
            
            netlist_data = extract_netlist(schematic_path)
            
            if "error" in netlist_data:
                print(f"Error extracting netlist: {netlist_data['error']}")
                if ctx:
                    ctx.info(f"Error extracting netlist: {netlist_data['error']}")
                return {"success": False, "error": netlist_data['error']}
            
            if ctx:
                await ctx.report_progress(60, 100)
                ctx.info(f"Extracted {netlist_data['component_count']} components and {netlist_data['net_count']} nets")
            
            # Analyze the netlist
            if ctx:
                await ctx.report_progress(70, 100)
                ctx.info("Analyzing netlist data...")
            
            analysis_results = analyze_netlist(netlist_data)
            
            if ctx:
                await ctx.report_progress(90, 100)
            
            # Build result
            result = {
                "success": True,
                "schematic_path": schematic_path,
                "component_count": netlist_data["component_count"],
                "net_count": netlist_data["net_count"],
                "components": netlist_data["components"],
                "nets": netlist_data["nets"],
                "analysis": analysis_results
            }
            
            # Complete progress
            if ctx:
                await ctx.report_progress(100, 100)
                ctx.info("Netlist extraction complete")
            
            return result
            
        except Exception as e:
            print(f"Error extracting netlist: {str(e)}")
            if ctx:
                ctx.info(f"Error extracting netlist: {str(e)}")
            return {"success": False, "error": str(e)}
  • Top-level registration call to register_netlist_tools(mcp), which defines and registers the extract_schematic_netlist tool (and others) with the FastMCP server instance.
    register_netlist_tools(mcp)
  • Key helper function extract_netlist that instantiates SchematicParser to parse the .kicad_sch file, extracting components, labels, wires, power symbols, and building basic netlist data.
    def extract_netlist(schematic_path: str) -> Dict[str, Any]:
        """Extract netlist information from a KiCad schematic file.
        
        Args:
            schematic_path: Path to the KiCad schematic file (.kicad_sch)
            
        Returns:
            Dictionary with netlist information
        """
        try:
            parser = SchematicParser(schematic_path)
            return parser.parse()
        except Exception as e:
            print(f"Error extracting netlist: {str(e)}")
            return {
                "error": str(e),
                "components": {},
                "nets": {},
                "component_count": 0,
                "net_count": 0
            }
  • Supporting helper analyze_netlist that processes netlist data to categorize components by type, identify power nets, and compute connection statistics.
    def analyze_netlist(netlist_data: Dict[str, Any]) -> Dict[str, Any]:
        """Analyze netlist data to provide insights.
        
        Args:
            netlist_data: Dictionary with netlist information
            
        Returns:
            Dictionary with analysis results
        """
        results = {
            "component_count": netlist_data.get("component_count", 0),
            "net_count": netlist_data.get("net_count", 0),
            "component_types": defaultdict(int),
            "power_nets": []
        }
        
        # Analyze component types
        for ref, component in netlist_data.get("components", {}).items():
            # Extract component type from reference (e.g., R1 -> R)
            comp_type = re.match(r'^([A-Za-z_]+)', ref)
            if comp_type:
                results["component_types"][comp_type.group(1)] += 1
        
        # Identify power nets
        for net_name in netlist_data.get("nets", {}):
            if any(net_name.startswith(prefix) for prefix in ["VCC", "VDD", "GND", "+5V", "+3V3", "+12V"]):
                results["power_nets"].append(net_name)
        
        # Count pin connections
        total_pins = sum(len(pins) for pins in netlist_data.get("nets", {}).values())
        results["total_pin_connections"] = total_pins
        
        return results
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it mentions parsing and extracting information, it doesn't describe error conditions, performance characteristics, file format requirements beyond the extension, or what happens with malformed schematics. The mention of 'progress reporting' via ctx is helpful but insufficient for comprehensive behavioral understanding.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections: purpose statement, parameter explanations, and return value description. It's appropriately sized at 6 sentences with no redundant information. The Args/Returns formatting helps readability, though the purpose statement could be slightly more front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (file parsing operation), no annotations, and the presence of an output schema, the description is minimally adequate. It explains what the tool does and its parameters but lacks important context about error handling, performance, and differentiation from similar tools. The output schema existence reduces the need to detail return values, but more behavioral context would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates well by explaining both parameters: 'schematic_path' is clearly described as 'Path to the KiCad schematic file (.kicad_sch)' and 'ctx' is explained as 'MCP context for progress reporting'. This provides meaningful semantic information beyond the bare schema, though it doesn't elaborate on path format requirements or ctx usage details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Extract netlist information from a KiCad schematic' with specific details about what it extracts (components, connections, labels). It distinguishes from some siblings like 'analyze_bom' or 'export_bom_csv' but doesn't explicitly differentiate from the closely related 'extract_project_netlist' tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when this tool is appropriate versus 'extract_project_netlist' or 'analyze_schematic_connections', nor does it provide any prerequisites or exclusions for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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