Skip to main content
Glama
lamaalrajih

KiCad MCP Server

by lamaalrajih

identify_circuit_patterns

Analyze KiCad schematics to recognize common circuit patterns like power supplies, amplifiers, filters, and digital interfaces for design understanding and verification.

Instructions

Identify common circuit patterns in a KiCad schematic.

This tool analyzes a schematic to recognize common circuit blocks such as:

  • Power supply circuits (linear regulators, switching converters)

  • Amplifier circuits (op-amps, transistor amplifiers)

  • Filter circuits (RC, LC, active filters)

  • Digital interfaces (I2C, SPI, UART)

  • Microcontroller circuits

  • And more

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

Returns: Dictionary with identified circuit patterns

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schematic_pathYes
ctxYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function implementing the 'identify_circuit_patterns' tool logic. Parses schematic, extracts netlist data, identifies multiple circuit patterns using specialized helper functions, reports progress via context, and returns a dictionary of findings.
    async def identify_circuit_patterns(schematic_path: str, ctx: Context | None) -> Dict[str, Any]:
        """Identify common circuit patterns in a KiCad schematic.
        
        This tool analyzes a schematic to recognize common circuit blocks such as:
        - Power supply circuits (linear regulators, switching converters)
        - Amplifier circuits (op-amps, transistor amplifiers)
        - Filter circuits (RC, LC, active filters)
        - Digital interfaces (I2C, SPI, UART)
        - Microcontroller circuits
        - And more
        
        Args:
            schematic_path: Path to the KiCad schematic file (.kicad_sch)
            ctx: MCP context for progress reporting
            
        Returns:
            Dictionary with identified circuit patterns
        """
        if not os.path.exists(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)}")
        
        try:
            # Extract netlist information
            if ctx:
                await ctx.report_progress(20, 100)
                ctx.info("Parsing schematic structure...")
            
            netlist_data = extract_netlist(schematic_path)
            
            if "error" in netlist_data:
                if ctx:
                    ctx.info(f"Error extracting netlist: {netlist_data['error']}")
                return {"success": False, "error": netlist_data['error']}
            
            # Analyze components and nets
            if ctx:
                await ctx.report_progress(30, 100)
                ctx.info("Analyzing components and connections...")
            
            components = netlist_data.get("components", {})
            nets = netlist_data.get("nets", {})
            
            # Start pattern recognition
            if ctx:
                await ctx.report_progress(50, 100)
                ctx.info("Identifying circuit patterns...")
            
            identified_patterns = {
                "power_supply_circuits": [],
                "amplifier_circuits": [],
                "filter_circuits": [],
                "oscillator_circuits": [],
                "digital_interface_circuits": [],
                "microcontroller_circuits": [],
                "sensor_interface_circuits": [],
                "other_patterns": []
            }
            
            # Identify power supply circuits
            if ctx:
                await ctx.report_progress(60, 100)
            identified_patterns["power_supply_circuits"] = identify_power_supplies(components, nets)
            
            # Identify amplifier circuits
            if ctx:
                await ctx.report_progress(70, 100)
            identified_patterns["amplifier_circuits"] = identify_amplifiers(components, nets)
            
            # Identify filter circuits
            if ctx:
                await ctx.report_progress(75, 100)
            identified_patterns["filter_circuits"] = identify_filters(components, nets)
            
            # Identify oscillator circuits
            if ctx:
                await ctx.report_progress(80, 100)
            identified_patterns["oscillator_circuits"] = identify_oscillators(components, nets)
            
            # Identify digital interface circuits
            if ctx:
                await ctx.report_progress(85, 100)
            identified_patterns["digital_interface_circuits"] = identify_digital_interfaces(components, nets)
            
            # Identify microcontroller circuits
            if ctx:
                await ctx.report_progress(90, 100)
            identified_patterns["microcontroller_circuits"] = identify_microcontrollers(components)
            
            # Identify sensor interface circuits
            if ctx:
                await ctx.report_progress(95, 100)
            identified_patterns["sensor_interface_circuits"] = identify_sensor_interfaces(components, nets)
            
            # Build result
            result = {
                "success": True,
                "schematic_path": schematic_path,
                "component_count": netlist_data["component_count"],
                "identified_patterns": identified_patterns
            }
            
            # Count total patterns
            total_patterns = sum(len(patterns) for patterns in identified_patterns.values())
            result["total_patterns_found"] = total_patterns
            
            # Complete progress
            if ctx:
                await ctx.report_progress(100, 100)
                ctx.info(f"Pattern recognition complete. Found {total_patterns} circuit patterns.")
            
            return result
            
        except Exception as e:
            if ctx:
                ctx.info(f"Error identifying circuit patterns: {str(e)}")
            return {"success": False, "error": str(e)}
  • The @mcp.tool() decorator within register_pattern_tools that registers the identify_circuit_patterns function with the MCP server.
    @mcp.tool()
    async def identify_circuit_patterns(schematic_path: str, ctx: Context | None) -> Dict[str, Any]:
  • Invocation of register_pattern_tools(mcp) in the main server setup, which triggers registration of the pattern tools including 'identify_circuit_patterns'.
    register_pattern_tools(mcp)
  • The register_pattern_tools function that defines and registers the pattern identification tools via @mcp.tool() decorators.
    def register_pattern_tools(mcp: FastMCP) -> None:
        """Register circuit pattern recognition tools with the MCP server.
        
        Args:
            mcp: The FastMCP server instance
        """
Behavior2/5

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

With no annotations provided, the description carries full burden but provides minimal behavioral information. It mentions 'analyzes a schematic' and 'recognizes common circuit blocks' but doesn't disclose performance characteristics, error conditions, what happens with invalid inputs, or whether this is a read-only operation. The mention of 'ctx: MCP context for progress reporting' hints at potentially long-running analysis but doesn't elaborate.

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, examples of recognized patterns, parameter explanations, and return value description. It's appropriately sized with no redundant information, though the bulleted list of circuit patterns could be slightly condensed.

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

Completeness4/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 (pattern recognition in schematics), no annotations, and the presence of an output schema (which handles return value documentation), the description provides adequate context. It explains what the tool does, what it analyzes, and what parameters it needs, though more behavioral transparency would improve completeness.

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: Path to the KiCad schematic file (.kicad_sch)' and 'ctx: MCP context for progress reporting'. This adds meaningful context beyond the bare schema, though it doesn't specify file path format requirements or constraints.

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

Purpose5/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: 'Identify common circuit patterns in a KiCad schematic' with specific examples of what it recognizes (power supply circuits, amplifier circuits, etc.). It distinguishes itself from siblings like 'analyze_schematic_connections' or 'find_component_connections' by focusing on pattern recognition rather than connection analysis.

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

Usage Guidelines3/5

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

The description implies usage context through the parameter description (requires a KiCad schematic file) but doesn't explicitly state when to use this tool versus alternatives like 'analyze_project_circuit_patterns' or 'analyze_schematic_connections'. No explicit guidance on prerequisites or exclusions is provided.

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