Skip to main content
Glama
lamaalrajih

KiCad MCP Server

by lamaalrajih

get_drc_history_tool

Retrieve Design Rule Check history for a KiCad project to track PCB design compliance and identify recurring issues.

Instructions

Get the DRC check history for a KiCad project.

Args: project_path: Path to the KiCad project file (.kicad_pro)

Returns: Dictionary with DRC history entries

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the get_drc_history_tool MCP tool. It fetches the DRC history using the helper function and computes a trend analysis.
    @mcp.tool()
    def get_drc_history_tool(project_path: str) -> Dict[str, Any]:
        """Get the DRC check history for a KiCad project.
        
        Args:
            project_path: Path to the KiCad project file (.kicad_pro)
            
        Returns:
            Dictionary with DRC history entries
        """
        print(f"Getting DRC history for project: {project_path}")
        
        if not os.path.exists(project_path):
            print(f"Project not found: {project_path}")
            return {"success": False, "error": f"Project not found: {project_path}"}
        
        # Get history entries
        history_entries = get_drc_history(project_path)
        
        # Calculate trend information
        trend = None
        if len(history_entries) >= 2:
            first = history_entries[-1]  # Oldest entry
            last = history_entries[0]    # Newest entry
            
            first_violations = first.get("total_violations", 0)
            last_violations = last.get("total_violations", 0)
            
            if first_violations > last_violations:
                trend = "improving"
            elif first_violations < last_violations:
                trend = "degrading"
            else:
                trend = "stable"
        
        return {
            "success": True,
            "project_path": project_path,
            "history_entries": history_entries,
            "entry_count": len(history_entries),
            "trend": trend
        }
  • The registration call that invokes register_drc_tools to add the get_drc_history_tool to the MCP server.
    register_drc_tools(mcp)
  • Helper function get_drc_history that loads the JSON history file for a project and returns sorted list of entries. Directly called by the tool handler.
    def get_drc_history(project_path: str) -> List[Dict[str, Any]]:
        """Get the DRC history for a project.
        
        Args:
            project_path: Path to the KiCad project file
            
        Returns:
            List of DRC history entries, sorted by timestamp (newest first)
        """
        history_path = get_project_history_path(project_path)
        
        if not os.path.exists(history_path):
            print(f"No DRC history found for {project_path}")
            return []
        
        try:
            with open(history_path, 'r') as f:
                history = json.load(f)
            
            # Sort entries by timestamp (newest first)
            entries = sorted(
                history.get("entries", []),
                key=lambda x: x.get("timestamp", 0),
                reverse=True
            )
            
            return entries
        except (json.JSONDecodeError, IOError) as e:
            print(f"Error reading DRC history: {str(e)}")
            return []
  • Import statement for the register_drc_tools function.
    from kicad_mcp.tools.drc_tools import register_drc_tools
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions returning a dictionary with entries, which adds some behavioral context, but fails to disclose critical traits like whether this is a read-only operation, if it requires specific permissions, or any rate limits. For a tool with no annotations, this is a significant gap.

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 appropriately sized and front-loaded, starting with the core purpose followed by structured sections for args and returns. Every sentence adds value, though it could be slightly more streamlined by integrating the args/returns into a single paragraph.

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 (one parameter) and the presence of an output schema (which handles return values), the description is mostly complete. It covers the purpose and parameter semantics adequately, but lacks usage guidelines and behavioral details, which holds it back from a perfect score.

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?

The description adds meaningful context beyond the input schema, which has 0% description coverage. It specifies that 'project_path' refers to a 'KiCad project file (.kicad_pro)', clarifying the file type and format, which compensates well for the schema's lack of details. With only one parameter, this is effective.

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 action ('Get') and resource ('DRC check history for a KiCad project'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'run_drc_check' or 'validate_project', which might also relate to DRC functionality, so it doesn't reach the highest score.

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?

No guidance is provided on when to use this tool versus alternatives. With siblings like 'run_drc_check' and 'validate_project' available, the description lacks context on whether this tool retrieves past results, complements real-time checks, or serves a distinct purpose, leaving usage unclear.

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