KLayout + Python + MCP

klink

An AI-native control plane for KLayout. It turns a running KLayout GUI into a layout kernel driven by external Python, MCP clients, and AI agents — geometry-first: mark intent on geometry, let algorithms complete the wiring, and decide "done" with structured geometry and LVS, not a screenshot that "looks right". It is an early-stage, experimental open-source project — try it and send feedback.

Package: klayout-klink Python 3.10+ KLayout 0.30.x tested Apache-2.0 open source Alpha · early stage

The control path

A thin plugin hugs KLayout; the heavy intelligence runs in external Python. The two sides talk only over RPC. Detail on Architecture.

control path
Agent (Claude Code / Codex)
  → MCP server   (python -m klink.mcp)
  → klink client (NDJSON over TCP)
  → KLayout plugin (in-process RPC)
       RPC:            127.0.0.1:8765+
       klive-compat:   127.0.0.1:8082

Sessions are ports, equal peers

Each KLayout window binds a port (8765, 8766…) as a session. No port has a privileged role — you always say which one.

Process purity

klink holds no process constants. Layers, sizes and devices are passed in from your pdk.py; a missing fact returns an instructive error with a next_action.

Capabilities, by domain

klink is a general geometry-first control plane. Below are some current capabilities grouped by domain, each backed by a runnable example script (all with no private GDS). The project is still early and experimental, so coverage will keep changing. Per-example measured detail on Examples.

122 tools, 11 domains

83 plugin RPCs + 39 MCP local tools, each with function, parameters and examples. The catalogue is generated from the live plugin's method registry — no hand-maintained list that can drift.