Skip to main content
Glama
ProductOfAmerica

mcp-server-kicad

flatten_hierarchy

Destructive

Flatten a hierarchical schematic into a single sheet whose netlist is the hierarchy's.

Instructions

Flatten a hierarchical schematic into a single sheet whose netlist is the hierarchy's.

The flat file is the root schematic with each sub-sheet's content copied below it, one
cell per use of a sheet file (a file used twice is copied twice). Each part keeps the
reference and unit KiCad reads for it at its sheet's path. A sheet pin becomes a
local label at its place when its sheet has a hierarchical label of its name, and nothing
otherwise. A local or hierarchical label of a sub-sheet becomes a local label named after
the sheet's path, so nets keep their joins and no others; net names change to those
labels. A label whose own sheet has a global label, a power symbol or a hidden power input
pin of its text keeps that text, so it keeps joining it. Text variables that name the
sheet are not rewritten.

The tool refuses, writing nothing, where the flat file could not keep the netlist: a
sheet pin or sub-sheet label that may be a bus, a file older than format 20221002, a
local power symbol, a bus_alias in a sub-sheet, a root label named like a global net
that only another sheet has, a library symbol whose pins differ between two files, a
sheet marked DNP, out of the BOM, off the board or out of simulation,
two sheets of one name, more than 4096 sheet instances, or a sheet file that cannot be
read. A sheet file that is missing is flattened as an empty sheet, as KiCad loads it.

Creates a new file and does not modify the hierarchy.

Args:
    schematic_path: Path to root .kicad_sch file. Optional; omit to use the configured default.
    output_path: Path for flattened output (defaults to *_flat.kicad_sch)

Input Schema

NameRequiredDescriptionDefault
output_pathNo
schematic_pathNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.9.1

TDQS

A4.4/5.0
Behavior5/5

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

Far beyond the annotations: it spells out exactly what is copied (one cell per sheet use, references/units preserved), how labels and net names are rewritten, which conditions cause a refusal with nothing written, and that missing sheet files flatten as empty. It also clarifies the write footprint ('Creates a new file and does not modify the hierarchy'), reconciling the destructiveHint=true annotation with a safe-on-source behavior.

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?

Front-loaded with the core operation and the output contract; the failure conditions are grouped into one scannable paragraph. It runs long for a two-parameter tool and the middle paragraph on label/global-net preservation is heavy detail an agent can rarely act on, but no sentence is filler.

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

Completeness5/5

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

Inputs, transformation semantics, refusal cases, and write behavior are all covered, and an output schema exists so return values need not be described. Nothing an agent needs in order to succeed or predict failure is missing.

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 coverage and bare 'title'-only properties, the Args block carries the full burden and does so: schematic_path is a root .kicad_sch, optional with a configured default; output_path defaults to *_flat.kicad_sch. Minor gap: it does not say what the configured default is or whether an existing output_path is overwritten.

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?

Opens with a specific verb and resource plus a definition of the output: flatten a hierarchical schematic into a single sheet preserving the netlist. No sibling performs this operation, and the phrase 'whose netlist is the hierarchy's' makes the contract unambiguous.

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?

Usage is implied rather than stated: an agent can infer you call this when you need one flat sheet, but the description never contrasts it with siblings like export_hierarchical_netlist, list_hierarchy, or duplicate_sheet, nor does it state prerequisites (e.g., root schematic must be identified, format requirements beyond a refusal condition).

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

Deploy Server

Other Tools