klayout-mcp
Read-only MCP server for KLayout. It opens GDS/OAS layouts, inspects geometry and hierarchy, renders deterministic PNGs, and runs batch DRC with structured JSON output.
Install
Fastest one-off run:
uvx klayout-mcp@latest
Install once:
uv tool install klayout-mcp
Traditional Python install:
python -m pip install klayout-mcp
For batch DRC, the klayout executable must be on PATH or exposed through KLAYOUT_BIN.
export KLAYOUT_BIN=/Applications/klayout.app/Contents/MacOS/klayout
Quick Start
klayout-mcp is a stdio MCP server. The default launch shape is:
command: uvx
args: klayout-mcp@latest
If your client cannot use uvx, install the tool once and launch klayout-mcp directly.
Typical workflow:
open_layoutlist_layerslist_cellsordescribe_cellquery_regionmeasure_geometryanalyze_waveguiderender_viewrun_drc_scriptextract_markersclose_session
Client Setup
More copy-paste examples live in examples/mcp/README.md.
Codex
[mcp_servers.klayout]
command = "uvx"
args = ["klayout-mcp@latest"]
[mcp_servers.klayout.env]
KLAYOUT_BIN = "/Applications/klayout.app/Contents/MacOS/klayout"
Or add it with the CLI:
codex mcp add klayout \
--env KLAYOUT_BIN=/Applications/klayout.app/Contents/MacOS/klayout \
-- uvx klayout-mcp@latest
Claude Code
{
"mcpServers": {
"klayout": {
"command": "uvx",
"args": ["klayout-mcp@latest"],
"env": {
"KLAYOUT_BIN": "/Applications/klayout.app/Contents/MacOS/klayout"
}
}
}
}
Or add it with the CLI:
claude mcp add --transport stdio klayout \
--scope project \
--env KLAYOUT_BIN=/Applications/klayout.app/Contents/MacOS/klayout \
-- uvx klayout-mcp@latest
Cursor
Cursor is file-config based:
{
"mcpServers": {
"klayout": {
"command": "uvx",
"args": ["klayout-mcp@latest"],
"env": {
"KLAYOUT_BIN": "/Applications/klayout.app/Contents/MacOS/klayout"
}
}
}
}
OpenCode
OpenCode is file-config based:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"klayout": {
"type": "local",
"command": ["uvx", "klayout-mcp@latest"],
"enabled": true,
"environment": {
"KLAYOUT_BIN": "/Applications/klayout.app/Contents/MacOS/klayout"
}
}
}
}
Other MCP Hosts
Use:
command:uvxargs:["klayout-mcp@latest"]env:KLAYOUT_BINwhen needed
Tools
- Session:
open_layout,close_session - Structure:
list_layers,list_cells,describe_cell - Geometry:
query_region,measure_geometry,analyze_waveguide - View:
set_view,render_view - DRC:
run_drc_script,extract_markers
Configuration
| Variable | Purpose | Default |
|---|---|---|
KLAYOUT_MCP_ARTIFACT_ROOT |
Root directory for runtime artifacts | <repo>/.artifacts |
KLAYOUT_MCP_SESSION_TTL_SECONDS |
Session inactivity timeout | 3600 |
KLAYOUT_BIN |
KLayout batch executable for DRC | klayout |
Behavior:
- any absolute local path can be used for layouts and DRC scripts
- artifact paths returned by tools are absolute
- sessions expire lazily after inactivity
close_sessionremoves the session artifact directory
Artifacts And Errors
Artifacts are stored under .artifacts/sessions/<session_id>/ and include renders, DRC reports, marker crops, and logs.
Tool failures return structured JSON such as:
{
"code": "FILE_NOT_FOUND",
"message": "Layout file does not exist",
"details": {
"path": "/abs/path/to/missing.gds"
}
}
Common codes: FILE_NOT_FOUND, SESSION_NOT_FOUND, INVALID_BOX, INVALID_LAYER, INVALID_TARGET, DRC_RUN_FAILED.
Development
For a source checkout:
uv sync --extra dev
uv run klayout-mcp
If an MCP client needs to launch the checkout directly:
command: uv
args: --directory /abs/path/to/klayout-mcp run klayout-mcp
Contributor workflow is in CONTRIBUTING.md. Release notes are in CHANGELOG.md.
Releases
Normal releases are automated with release-please.
- merge Conventional Commits to
main release-pleaseopens or updates a release PR- merging that release PR updates
pyproject.toml,CHANGELOG.md, creates the tag and GitHub release, and publishes to PyPI
To let the release PR run normal CI under branch protection, configure a repository secret named RELEASE_PLEASE_TOKEN with a GitHub token that can open pull requests. Without it, release-please falls back to github.token, which may not trigger PR workflows.
The manual release.yml workflow remains available for TestPyPI validation and recovery publishing.
Reference
- docs/specs/2026-03-05-klayout-observer-mcp-contract.md
- docs/plans/2026-03-05-klayout-observer-mcp-design.md
- docs/plans/2026-03-05-klayout-observer-mcp-implementation-plan.md
Documentation Site
The repository is configured for Read the Docs with MkDocs.
Build the docs locally:
uv run --extra docs mkdocs build --strict
Serve the docs locally:
uv run --extra docs mkdocs serve
After importing the GitHub repository into Read the Docs, it can build directly from the default branch using .readthedocs.yaml.
Metadata
Release files for klayout-mcp 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| klayout_mcp-0.2.3.tar.gz | 33.1 kB | With provenance | Details for klayout_mcp-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| klayout_mcp-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for klayout_mcp-0.2.3-py3-none-any.whl |
Total release size: 65.1 kB
Release files / klayout_mcp-0.2.3.tar.gz
| Download URL | klayout_mcp-0.2.3.tar.gz |
|---|---|
| Size | 33.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f35df31b329c1a2246b3e03725e28ed218d1e7f09017510abee6a214e9f2de6
|
|
BLAKE2b-256 checksum How to use checksums |
13a9d24db7907d8258f76e48e2eb93e830c972a97f3f98b9fa7e29aaf841c3d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 25, 2026.
Transparency logRelease files / klayout_mcp-0.2.3-py3-none-any.whl
| Download URL | klayout_mcp-0.2.3-py3-none-any.whl |
|---|---|
| Size | 32.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3b7c41102d3c0f9bb21c3296091ce9d7594f018739cf4df24ddaab7c7427fc2a
|
|
BLAKE2b-256 checksum How to use checksums |
66910c954ca701ba0a2b1ad117affe6d927ad89fb6c385cd144610ba2c341832
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 25, 2026.
Transparency logSecurity for klayout-mcp 0.2.3
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for klayout_mcp-0.2.3.tar.gz
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 Mar 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.