Skip to main content

klayout-draw-mcp

An MCP server for drawing GDS layouts with KLayout — generate, edit, and view layouts from an AI assistant such as Claude Code or Claude Desktop.

Layout geometry is built in-process with the standalone klayout Python module (no GUI needed). The installed KLayout application is launched only for viewing or manual editing.

Tools

Tool Purpose
new_layout(top_cell, dbu) Start a new in-memory layout (coordinates in micrometers)
add_box(layer, x1, y1, x2, y2, datatype) Add a rectangle
add_polygon(layer, points, datatype) Add a polygon from [x, y] vertices
add_path(layer, points, width, datatype) Add a path with width
add_label(layer, x, y, text, datatype) Add a text label
create_cell(name) / use_cell(name) Create/select the active drawing cell
place_cell(cell, x, y, orient, nx, ny, dx, dy) Place an instance or array of a cell
add_via(x, y, bottom_layer, top_layer, cut_layer, …) Via: cut array + enclosing metal
add_wire(layer, points, width) Manhattan wire (auto L-corners)
layout_info() Inspect current layout (layers, bbox, shape count)
load_gds(path, top_cell?) Load an existing GDS/OASIS into the session for editing
inspect_gds(path?) Per-layer shape count, area and bbox of a file or the session
drc_check(rules, path?) Simple DRC: spacing / width / overlap / separation / enclosure
save_gds(path, open_after) Write GDS/OASIS; optionally open in the editor
open_layout(file_path) Open a file in KLayout (viewer)
open_editor(file_path?) Open KLayout in editor mode, or a blank layout
run_script(code) Run arbitrary Python with klayout.db (cell hierarchy, arrays, booleans, DRC, ...)

Requirements

  • Python ≥ 3.10
  • The klayout and mcp Python packages (installed via the steps below)
  • The KLayout application — only needed for open_layout / open_editor

Install

uv sync

Register with Claude Code

claude mcp add klayout -s user -- "<repo>/.venv/Scripts/python.exe" -m klayout_draw_mcp.server

On macOS/Linux use .venv/bin/python.

Usage

"Draw a 5×5 µm box on layer 1 and a 2 µm-wide path, then save to out.gds and open it."

Claude calls new_layout → add_box / add_path → save_gds(open_after=True).

You can also open and check an existing layout:

"Load chip.gds, check that M1 spacing ≥ 0.15 µm and that OD never overlaps POLY, and report violations."

Claude calls load_gds → inspect_gds → drc_check([...]), then edits and save_gds. See Editing & DRC.

For anything beyond the basic shapes, run_script exposes the full klayout.db API.

Examples

Self-contained scripts in examples/. Each builds a layout with the standalone klayout.db module and writes a GDS:

uv run python examples/cis_aps_pixel.py out.gds

You can also paste the body of a script's build() function into the run_script tool. The scripts share one layer map (OD 3/0, POLY 6/0, NPLUS 4/0, METAL1 9/0, ...).

Example What it draws
basic_shapes.py The four primitives: box, path, polygon, label
nmos_transistor.py A single NMOS (active, poly gate, n+, contacts, M1 S/G/D)
cmos_inverter.py A CMOS inverter: PMOS over NMOS, shared gate, Vdd/Vss rails
cis_aps_pixel.py A 1 µm 4T CMOS image-sensor pixel, tiled as a 2×2 array

Place & route skill

skills/klayout-pnr/ packages place-and-route recipes — row placement, power rails, and an obstacle-aware maze (Lee) router — plus a SKILL.md workflow guide for assistants. Copy it to your skills directory to have it auto-discovered:

cp -r skills/klayout-pnr ~/.claude/skills/

Documentation

Full docs (Getting Started walkthrough, examples, editing/DRC, place & route) are at https://geniuskey.github.io/klayout-draw-mcp/.

Note

run_script executes arbitrary Python locally, in-process. Only run scripts you trust.

Metadata

Release files for klayout-draw-mcp 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for klayout-draw-mcp 0.1.2
File Size Uploaded
klayout_draw_mcp-0.1.2.tar.gz 235.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for klayout-draw-mcp 0.1.2
File Interpreter ABI Platform
klayout_draw_mcp-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 247.4 kB

Release files / klayout_draw_mcp-0.1.2.tar.gz

Download URL klayout_draw_mcp-0.1.2.tar.gz
Size 235.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c62475d4808f7e69c0aad97f2917364276dae9899dd7d36456ea5cca35137e88
BLAKE2b-256 checksum
How to use checksums
35c63914497de4bfa95266b32334eb030bf2785238aabc9b9e35dfd744dbd155
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 25, 2026.

Transparency log

Release files / klayout_draw_mcp-0.1.2-py3-none-any.whl

Download URL klayout_draw_mcp-0.1.2-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f972f2211b0530977553e408e5c541613e216d7285a25803299feea9b93ea530
BLAKE2b-256 checksum
How to use checksums
8ed2838c04961ae8886ea7ac02320df088a82638eb36ec93ed3ac2c66ff2752e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page