klayout-draw-mcp
The klayout-draw-mcp server enables AI assistants to programmatically create, edit, inspect, and validate GDS/OASIS chip layouts using KLayout's Python API.
Layout Management
Create new layouts (
new_layout) with a named top cell and configurable database unitLoad existing GDS/OASIS files (
load_gds) for editing or inspectionSave layouts (
save_gds) to GDS/OASIS format with optional auto-open in KLayoutInspect layouts (
layout_info,inspect_gds) for per-layer shape counts, areas, bounding boxes, and cell lists
Drawing Primitives
Add rectangles (
add_box), polygons (add_polygon), paths (add_path), and text labels (add_label) on specified layers
Advanced Layout Construction
Create and manage cells (
create_cell,use_cell) and place instances or arrays (place_cell) with rotation/mirroringAdd vias (
add_via) — cut arrays with enclosing metal on both connected layersAdd Manhattan wires (
add_wire) — axis-aligned wires with automatic L-corner insertion
Design Rule Checking
Run DRC checks (
drc_check) for spacing, width, overlap, separation, and enclosure rules, reporting violations
GUI Integration
Open layouts in KLayout viewer (
open_layout) or editor mode (open_editor)
Scripting & Extensibility
Execute arbitrary Python code (
run_script) with full access toklayout.dbfor boolean geometry, custom DRC, cell hierarchies, and other advanced operations
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@klayout-draw-mcpdraw a 10um square on layer 1 and save as out.gds"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 |
| Start a new in-memory layout (coordinates in micrometers) |
| Add a rectangle |
| Add a polygon from |
| Add a path with width |
| Add a text label |
| Create/select the active drawing cell |
| Place an instance or array of a cell |
| Via: cut array + enclosing metal |
| Manhattan wire (auto L-corners) |
| Inspect current layout (layers, bbox, shape count) |
| Load an existing GDS/OASIS into the session for editing |
| Per-layer shape count, area and bbox of a file or the session |
| Simple DRC: spacing / width / overlap / separation / enclosure |
| Write GDS/OASIS; optionally open in the editor |
| Open a file in KLayout (viewer) |
| Open KLayout in editor mode, or a blank layout |
| Run arbitrary Python with |
Related MCP server: KiCAD Schematic Manipulation MCP Server
Requirements
Python ≥ 3.10
The
klayoutandmcpPython packages (installed via the steps below)The KLayout application — only needed for
open_layout/open_editor
Install
uv syncRegister with Claude Code
claude mcp add klayout -s user -- "<repo>/.venv/Scripts/python.exe" -m klayout_draw_mcp.serverOn 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.gdsYou 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 |
| The four primitives: box, path, polygon, label |
| A single NMOS (active, poly gate, n+, contacts, M1 S/G/D) |
| A CMOS inverter: PMOS over NMOS, shared gate, Vdd/Vss rails |
| 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.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables AI assistants to perform Electronic Design Automation (EDA) tasks including Verilog synthesis, simulation, ASIC design flows, and waveform analysis through a unified interface.6
- Alicense-qualityDmaintenanceEnables AI tools to create, edit, and inspect KiCAD schematic files, including components, wires, labels, and sheets.MIT
- AlicenseCqualityCmaintenanceEnables LLMs to inspect, edit, analyze, and render PCB layouts in real-time using the KiCad IPC API, providing tools for board configuration, footprints, tracks, zones, nets, text, shapes, dimensions, exports, screenshots, and CLI automation.1001MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to read and modify KiCAD PCB designs through the KiCAD IPC API, providing tools for board queries, footprint placement, track creation, DRC, and export.14MIT
Related MCP Connectors
DXF and PDF/X-4 for AI agents: structured facts, PNG renders, an interactive in-chat viewer.
Agent-first CAD: editable .kcad.ts source, deterministic review, OpenCASCADE kernel.
Electronic component datasheets for AI agents — specs, pinouts, package data on demand.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/geniuskey/klayout-draw-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server