Skip to main content
Glama

Write a PcbLib

write_pcblib
Destructive

Write footprints into an Altium .PcbLib file, letting you create a new library or append pads, tracks, vias, regions and 3D bodies to an existing one so designed parts are stored as reusable library components.

Instructions

Write footprints to an Altium .PcbLib file (set 'append': true to add to an existing library instead of replacing it). Each footprint is defined by its primitives: pads (with position, size, shape, layer), tracks, vias, fills, arcs, regions, text and component_bodies. The AI is responsible for calculating correct positions and sizes based on IPC-7351B or other standards. All coordinates and dimensions must be in millimetres (mm). A footprint authored without a '.Designator' text receives one on the Top Overlay automatically, just above its topmost pad, so every placed part shows its reference designator: supply your own to control its placement, or set 'auto_designator': false to omit it; a footprint echoed back from a read (carrying primitive_order) is never touched. The response 'bodies' array echoes each footprint's 3D body height and source; a footprint with no STEP model and no component body reports source 'none'. Set 'auto_3d_body': true to have an extruded placeholder body (default height 1.0 mm, flagged 'assumed_height': true) added to such footprints, then confirm or override it by supplying 'component_bodies' explicitly. The response also includes a 'warnings' array flagging silkscreen (overlay) tracks that overlap a pad (silk-on-pad) so you can move them clear. No text field may contain '|', the separator of Altium's record format, which cannot hold it.

Input Schema

NameRequiredDescriptionDefault
appendNoIf true, append to existing file; if false, create new file
filepathYesPath to the .PcbLib file to create/modify
footprintsYesArray of footprint definitions
auto_3d_bodyNoIf true, footprints with pads but no STEP model and no component body get a placeholder extruded 3D body (1.0 mm tall, flagged assumed_height). Default false: nothing is added unless you ask, since many footprints (fiducials, test points, mounting holes) legitimately have no body. Prefer supplying real heights via component_bodies.
auto_designatorNoIf true (default), a footprint authored without a '.Designator' text gets one on the Top Overlay just above its topmost pad, so the placed part shows its reference designator. Never applied to a footprint echoed back from read_pcblib/get_component (one carrying primitive_order): Altium's own library footprints carry no designator text, and a read-modify-write must not add primitives. Set false to author a footprint without one.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.3.1
    • addedInput schema / properties / footprints / items / properties / component_bodies / items / properties / mil_values_as_read
      Added value: +{
      +  "description": "The body's mil-valued parameters as [key, value] string pairs exactly as read_pcblib emitted them (OVERALLHEIGHT=11.8898mil, say), so a length goes back in Altium's text while it holds the same value; the millimetre fields round to 6 decimals, which would otherwise come back as 11.889803mil. Pass back unchanged; omit when authoring.",
      +  "items": {
      +    "items": {
      +      "type": "string"
      +    },
      +    "maxItems": 2,
      +    "minItems": 2,
      +    "type": "array"
      +  },
      +  "type": "array"
      +}
    • addedInput schema / properties / footprints / items / properties / primitive_guids_as_read
      Added value: +{
      +  "description": "Base64 of the footprint's PrimitiveGuids/Data stream exactly as read_pcblib emitted it. Altium orders its records its own way; the stream goes back in that order while it holds exactly the records the primitives carry, and is rebuilt in primitive order otherwise. Pass back unchanged; omit when authoring.",
      +  "type": "string"
      +}
    • changedInput schema / properties / footprints / items / properties / text / items / properties / stroke_font / description
      Previous value: -"Stroke font selection (only meaningful when kind is \"stroke\"). Default: default (Altium's built-in stroke font)"New value: +"Stroke font selection: it draws the text while kind is \"stroke\", and a TrueType or barcode text keeps the one it switches back to (read_pcblib reports it for every kind; pass it back unchanged). Default: default (Altium's built-in stroke font)"
  2. Changed6 schema fields changedv1.3.0
    • addedInput schema / properties / footprints / items / properties / carried_streams
      Added value: +{
      +  "description": "Streams of the footprint's storage this tool does not model (PrimitiveParameters with the footprint's Pin Count / Pitch / Mount parameters, ExtendedPrimitiveInformation/Data with region mask expansions, CornerRadiusChamfer, CustomMaskShapes, SharedUnion, …) as [path, base64] pairs, exactly as read_pcblib emitted them. They go back as read while the footprint keeps the primitive sequence in carried_streams_sequence (they name primitives by position); otherwise they are dropped with a warning. Pass back unchanged; omit when authoring.",
      +  "items": {
      +    "items": {
      +      "type": "string"
      +    },
      +    "maxItems": 2,
      +    "minItems": 2,
      +    "type": "array"
      +  },
      +  "type": "array"
      +}
    • addedInput schema / properties / footprints / items / properties / carried_streams_sequence
      Added value: +{
      +  "description": "The primitive kinds, in stream order, the footprint held when carried_streams were read. Pass back unchanged; omit when authoring.",
      +  "items": {
      +    "enum": [
      +      "arc",
      +      "pad",
      +      "via",
      +      "track",
      +      "text",
      +      "region",
      +      "fill",
      +      "component_body"
      +    ],
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedInput schema / properties / footprints / items / properties / component_bodies / items / properties / flags
      Added value: +{
      +  "description": "Primitive flags (optional). Accepts the name string read_pcblib emits (e.g. \"LOCKED\") or a raw bitmask integer (1=locked, 2=polygon, 4=keepout, 8=tenting-top, 16=tenting-bottom, 32=testpoint-top, 64=testpoint-bottom; 128 and above are on-disk bits read_pcblib carries verbatim as DISK_BIT_n — pass them back unchanged). A locked body is one Altium will not let you move. Default: none",
      +  "minimum": 0,
      +  "type": [
      +    "string",
      +    "integer"
      +  ]
      +}
    • addedInput schema / properties / footprints / items / properties / component_bodies / items / properties / model_type
      Added value: +{
      +  "description": "MODEL.MODELTYPE as read_pcblib emitted it: 0 extruded, 1 a model file, 2 a cylinder, 3 a sphere (a cylinder's or sphere's dimensions travel in additional_parameters). Pass back unchanged; omit when authoring (0 for a body with no model file, 1 otherwise).",
      +  "maximum": 255,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • addedInput schema / properties / footprints / items / properties / pads / items / properties / raw_size_shape_basis
      Added value: +{
      +  "description": "16 hex digits: the fingerprint of the size/shape block the pad built when read (see raw_size_shape_block). Pass back unchanged; omit when authoring.",
      +  "type": "string"
      +}
    • addedInput schema / properties / footprints / items / properties / pads / items / properties / raw_size_shape_block
      Added value: +{
      +  "description": "Base64 of a simple pad's size/shape block exactly as read_pcblib emitted it. It goes back as read while the pad still builds the block it was read with (raw_size_shape_basis), keeping per-layer entries this tool does not model; an edited pad writes the block it builds. Pass back unchanged; omit when authoring.",
      +  "type": "string"
      +}
  3. Changed4 schema fields changedv1.1.0
    • changedInput schema / properties / footprints / items / properties / component_bodies / items / properties / identifier / description
      Previous value: -"The body's IDENTIFIER, a user-visible name (any Unicode; stored as code points on disk). Default: empty"New value: +"The body's IDENTIFIER, a user-visible name (any Unicode; stored as UTF-16 code units on disk). Default: empty"
    • addedInput schema / properties / footprints / items / properties / pads / items / properties / polygon_connect
      Added value: +{
      +  "description": "The pad's own polygon-connect style (Altium: Pad Stack > Thermal Relief), overriding the design rules for how a polygon pour joins the pad. Omit to follow the rules (the default); a key left out takes Altium's default.",
      +  "properties": {
      +    "air_gap": {
      +      "description": "Gap between the pad and the pour in mm. Default: 0.254 (10 mil)",
      +      "minimum": 0,
      +      "type": "number"
      +    },
      +    "auto_conductors": {
      +      "description": "Let Altium choose the conductor count. Default: false",
      +      "type": "boolean"
      +    },
      +    "conductor_width": {
      +      "description": "Width of each relief conductor in mm. Default: 0.254 (10 mil)",
      +      "minimum": 0,
      +      "type": "number"
      +    },
      +    "conductors": {
      +      "description": "Number of relief conductors. Default: 4",
      +      "enum": [
      +        2,
      +        4
      +      ],
      +      "maximum": 4,
      +      "minimum": 2,
      +      "type": "integer"
      +    },
      +    "min_distance": {
      +      "description": "Minimum distance used with auto_conductors when min_distance_enabled is set, in mm. Default: 0.381 (15 mil)",
      +      "minimum": 0,
      +      "type": "number"
      +    },
      +    "min_distance_enabled": {
      +      "description": "Apply min_distance (Altium's Min Distance checkbox). Default: false",
      +      "type": "boolean"
      +    },
      +    "rotation": {
      +      "description": "Conductor angle in degrees. Default: 90",
      +      "enum": [
      +        45,
      +        90
      +      ],
      +      "maximum": 90,
      +      "minimum": 45,
      +      "type": "integer"
      +    },
      +    "style": {
      +      "description": "How the pour joins the pad. Default: relief",
      +      "enum": [
      +        "relief",
      +        "direct",
      +        "no_connect"
      +      ],
      +      "type": "string"
      +    }
      +  },
      +  "type": "object"
      +}
    • addedInput schema / properties / footprints / items / properties / regions / items / properties / raw_contours
      Added value: +{
      +  "description": "Base64 of the region's contour bytes exactly as read_pcblib emitted them (outline and hole vertices). Altium stores a vertex as a double in internal units and a poured polygon's copper sits on fractional ones, so the bytes are replayed while they still describe the vertices above; an edited outline drops them. Pass back unchanged; omit when authoring.",
      +  "type": "string"
      +}
    • addedInput schema / properties / footprints / items / properties / vias / items / properties / polygon_connect
      Added value: +{
      +  "description": "The via's own polygon-connect style (Altium: Pad Stack > Thermal Relief), overriding the design rules for how a polygon pour joins the via. Omit to follow the rules (the default); a key left out takes Altium's default.",
      +  "properties": {
      +    "air_gap": {
      +      "description": "Gap between the via and the pour in mm. Default: 0.254 (10 mil)",
      +      "minimum": 0,
      +      "type": "number"
      +    },
      +    "auto_conductors": {
      +      "description": "Let Altium choose the conductor count. Default: false",
      +      "type": "boolean"
      +    },
      +    "conductor_width": {
      +      "description": "Width of each relief conductor in mm. Default: 0.254 (10 mil)",
      +      "minimum": 0,
      +      "type": "number"
      +    },
      +    "conductors": {
      +      "description": "Number of relief conductors. Default: 4",
      +      "enum": [
      +        2,
      +        4
      +      ],
      +      "maximum": 4,
      +      "minimum": 2,
      +      "type": "integer"
      +    },
      +    "min_distance": {
      +      "description": "Minimum distance used with auto_conductors when min_distance_enabled is set, in mm. Default: 0.381 (15 mil)",
      +      "minimum": 0,
      +      "type": "number"
      +    },
      +    "min_distance_enabled": {
      +      "description": "Apply min_distance (Altium's Min Distance checkbox). Default: false",
      +      "type": "boolean"
      +    },
      +    "rotation": {
      +      "description": "Conductor angle in degrees. Default: 90",
      +      "enum": [
      +        45,
      +        90
      +      ],
      +      "maximum": 90,
      +      "minimum": 45,
      +      "type": "integer"
      +    },
      +    "style": {
      +      "description": "How the pour joins the via. Default: relief",
      +      "enum": [
      +        "relief",
      +        "direct",
      +        "no_connect"
      +      ],
      +      "type": "string"
      +    }
      +  },
      +  "type": "object"
      +}
  4. Changed3 schema fields changedv1.0.5
    • addedInput schema / properties / footprints / items / properties / additional_parameters
      Added value: +{
      +  "description": "The footprint's Parameters keys other than HEIGHT, captured verbatim on read whenever the block is not the plain five-key block this tool writes from scratch: the PATTERN and DESCRIPTION bytes, the UNICODE twins that carry a name or description outside ASCII, the item and revision GUIDs of a managed footprint, a UI-authored AREA, and any key a newer Altium version writes. Each entry is a [key, value] string pair. Pass back unchanged on a read-modify-write so nothing is dropped (a PATTERN, DESCRIPTION or twin that no longer matches the name or description is rebuilt from it); omit when authoring, or to have the block rebuilt in Altium's current shape.",
      +  "items": {
      +    "items": {
      +      "type": "string"
      +    },
      +    "maxItems": 2,
      +    "minItems": 2,
      +    "type": "array"
      +  },
      +  "type": "array"
      +}
    • addedInput schema / properties / footprints / items / properties / height
      Added value: +{
      +  "description": "Overall component height in mm — Altium's HEIGHT parameter, written as its mil string. Default: 0",
      +  "minimum": 0,
      +  "type": "number"
      +}
    • addedInput schema / properties / footprints / items / properties / param_key_order
      Added value: +{
      +  "description": "The footprint's Parameters keys in stored order, as read_pcblib emitted them; the writer replays this order so the block stays byte-faithful. Pass back unchanged; omit when authoring (canonical order).",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
  5. Changed1 schema field changed
    • addedInput schema / properties / footprints / items / properties / storage_name
      Added value: +{
      +  "description": "The CFB storage the component was read from, as read_pcblib/read_schlib emit it. Pass it back unchanged on a read-modify-write so the component stays where Altium looks for it (Altium re-derives a short name's storage and maps a long one through SectionKeys, so a moved storage is a component it cannot load); omit when authoring or renaming, and the storage name is derived as Altium would: / \\ : ! * become _, then a cut at 31 characters.",
      +  "type": "string"
      +}
  6. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

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

Beyond the annotations (which already flag destructiveHint=true), the description discloses that the default is a full replace, that a designator is auto-created above the topmost pad (with an opt-out), that read echoes are never modified, that auto_3d_body inserts an 'assumed_height' placeholder, that a warnings array flags silk-on-pad overlap, and that '|' is forbidden in text. This is rich behavioral disclosure the structured fields do not carry.

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?

Purpose is front-loaded in the first clause, and every sentence adds information (units, designator logic, bodies echo, warnings, character restriction). The final paragraph is dense and runs together several distinct behaviors, which slightly hurts scanability but not substance.

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?

For a complex 5-parameter writer with a deep nested schema and no output schema, the description covers the AI's authoring responsibility (IPC-7351B), the unit contract, the auto-added primitives, and the relevant response fields (bodies, warnings). An agent has enough to invoke it correctly without guessing.

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?

Schema coverage is 100%, so the baseline is 3; the description adds value by mandating millimetres for all coordinates and dimensions (a real authoring constraint), explaining the append default precisely, and clarifying the auto_designator/auto_3d_body toggles. It leaves the deep nested pad/via fields entirely to the schema.

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 opens with a specific verb and resource ('Write footprints to an Altium .PcbLib file') and enumerates exactly what a footprint comprises (pads, tracks, vias, fills, arcs, regions, text, component_bodies). The resource (.PcbLib) clearly separates it from write_schlib and read_pcblib, so an agent can select it without opening the schema.

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

Usage Guidelines4/5

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

It gives clear operational context: 'append': true adds rather than replaces, and the auto_3d_body default is explained with a rationale ('many footprints ... legitimately have no body'). However it never names an alternative sibling (e.g. update_pad, update_component, validate_library) or states prerequisites for choosing this over an incremental-update tool.

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