klayout-draw-mcp
Enables AI assistants to create, edit, and view GDS layout files using KLayout, with tools for basic shapes and scripting.
README
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
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).
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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。