MCP server for drawing, generating, and editing GDS layouts with KLayout.
Project description
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 |
layout_info() |
Inspect current layout (layers, bbox, shape count) |
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
klayoutandmcpPython 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).
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 |
Note
run_script executes arbitrary Python locally, in-process. Only run scripts you trust.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file klayout_draw_mcp-0.1.0.tar.gz.
File metadata
- Download URL: klayout_draw_mcp-0.1.0.tar.gz
- Upload date:
- Size: 167.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0eec682e33eeff2744653e32b0db18636d23714ddff45caa0daf03318df5a9e5
|
|
| MD5 |
c7cef4d9185acc4e006afbc8dc9b567a
|
|
| BLAKE2b-256 |
6aa05e11be9bf7c5bcba57c168769a9855e6022d49d2d0b44f4b49f7a54d4193
|
Provenance
The following attestation bundles were made for klayout_draw_mcp-0.1.0.tar.gz:
Publisher:
publish.yml on geniuskey/klayout-draw-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
klayout_draw_mcp-0.1.0.tar.gz -
Subject digest:
0eec682e33eeff2744653e32b0db18636d23714ddff45caa0daf03318df5a9e5 - Sigstore transparency entry: 1953796729
- Sigstore integration time:
-
Permalink:
geniuskey/klayout-draw-mcp@8ff986a38d9857937afae0a214336fbdc6498171 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/geniuskey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ff986a38d9857937afae0a214336fbdc6498171 -
Trigger Event:
release
-
Statement type:
File details
Details for the file klayout_draw_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: klayout_draw_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e3f04797607140c036f48b6eb9fd904876447ea4833df6965e0ce781b8e1b70
|
|
| MD5 |
50fc399a289aa5fc8e3b5dffac16ed53
|
|
| BLAKE2b-256 |
8bc6ff38904264bf2d963992bf451993e70b3e9f67938f2f84dc90f671a81ec3
|
Provenance
The following attestation bundles were made for klayout_draw_mcp-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on geniuskey/klayout-draw-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
klayout_draw_mcp-0.1.0-py3-none-any.whl -
Subject digest:
0e3f04797607140c036f48b6eb9fd904876447ea4833df6965e0ce781b8e1b70 - Sigstore transparency entry: 1953797079
- Sigstore integration time:
-
Permalink:
geniuskey/klayout-draw-mcp@8ff986a38d9857937afae0a214336fbdc6498171 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/geniuskey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ff986a38d9857937afae0a214336fbdc6498171 -
Trigger Event:
release
-
Statement type: