Observer-first MCP server for KLayout layout inspection.
Project description
klayout-mcp
Read-only MCP server for KLayout. It opens GDS/OAS layouts, inspects hierarchy and geometry, renders deterministic PNG views, and runs batch DRC with structured JSON results.
Install In 60 Seconds
Fastest one-off run:
uvx klayout-mcp
Install once and keep the command on your machine:
uv tool install klayout-mcp
klayout-mcp
Traditional Python install:
python -m pip install klayout-mcp
klayout-mcp depends on the klayout Python package. For batch DRC, you also need the klayout executable on PATH or KLAYOUT_BIN set explicitly.
Common macOS app path:
export KLAYOUT_BIN=/Applications/klayout.app/Contents/MacOS/klayout
Quick Start
Set KLAYOUT_BIN if the klayout executable is not already on PATH:
export KLAYOUT_BIN=/Applications/klayout.app/Contents/MacOS/klayout
The server speaks MCP over stdio. The most common launcher is:
command: uvx
args: klayout-mcp
If your host cannot use uvx, install once with uv tool install klayout-mcp and point the client at the installed klayout-mcp binary instead.
Choose Your Client
Ready-to-copy config files live in examples/mcp/README.md.
Codex
Codex supports user-scoped ~/.codex/config.toml and project-scoped .codex/config.toml.
[mcp_servers.klayout]
command = "uvx"
args = ["klayout-mcp"]
[mcp_servers.klayout.env]
KLAYOUT_BIN = "/Applications/klayout.app/Contents/MacOS/klayout"
Codex CLI also supports adding stdio servers directly:
codex mcp add klayout \
--env KLAYOUT_BIN=/Applications/klayout.app/Contents/MacOS/klayout \
-- uvx klayout-mcp
Claude Code
Claude Code supports project-scoped .mcp.json and user-scoped MCP configuration.
{
"mcpServers": {
"klayout": {
"command": "uvx",
"args": ["klayout-mcp"],
"env": {
"KLAYOUT_BIN": "/Applications/klayout.app/Contents/MacOS/klayout"
}
}
}
}
CLI form:
claude mcp add klayout --scope project \
--env KLAYOUT_BIN=/Applications/klayout.app/Contents/MacOS/klayout \
-- uvx klayout-mcp
Cursor
Cursor reads MCP servers from .cursor/mcp.json for a project or ~/.cursor/mcp.json globally.
{
"mcpServers": {
"klayout": {
"command": "uvx",
"args": ["klayout-mcp"],
"env": {
"KLAYOUT_BIN": "/Applications/klayout.app/Contents/MacOS/klayout"
}
}
}
}
OpenCode
OpenCode reads MCP servers from opencode.json under the mcp key.
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"klayout": {
"type": "local",
"command": ["uvx", "klayout-mcp"],
"enabled": true,
"environment": {
"KLAYOUT_BIN": "/Applications/klayout.app/Contents/MacOS/klayout"
}
}
}
}
Other MCP Hosts And Agents
Use this stdio shape:
command:uvxargs:["klayout-mcp"]env:KLAYOUT_BINwhen needed
This server works well with agents because it is read-only with respect to layout content, but it still writes artifacts for renders, reports, and marker crops.
Typical Workflow
open_layoutlist_layerslist_cellsordescribe_cellquery_regionmeasure_geometryrender_viewrun_drc_scriptextract_markersclose_session
Available Tools
Session
open_layoutclose_session
Structure
list_layerslist_cellsdescribe_cell
Geometry
query_regionmeasure_geometry
View
set_viewrender_view
DRC
run_drc_scriptextract_markers
Configuration
Supported environment variables:
| 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 |
Important 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
Runtime artifacts are stored under:
.artifacts/
sessions/
<session_id>/
session.json
renders/
drc/
Typical outputs include:
- rendered PNGs
- DRC reports (
.lyrdb) markers.jsonstdout.txtandstderr.txt- crop images for extracted markers
Error Model
Tool failures return structured JSON objects:
{
"code": "FILE_NOT_FOUND",
"message": "Layout file does not exist",
"details": {
"path": "/abs/path/to/missing.gds"
}
}
Common codes include:
FILE_NOT_FOUNDSESSION_NOT_FOUNDINVALID_BOXINVALID_LAYERINVALID_TARGETDRC_RUN_FAILED
Security Notes
- This server is read-only with respect to layout content
- any absolute local layout path or DRC script path may be used
- tool parameters are treated as data, not shell fragments
Source Checkout
For local development or unreleased builds:
uv sync --extra dev
uv run klayout-mcp
If an MCP client needs to launch a source checkout directly:
command: uv
args: --directory /abs/path/to/klayout-mcp run klayout-mcp
Contributor workflow, branch policy, and release expectations are documented in CONTRIBUTING.md.
CI And Releases
GitHub Actions workflows included in this repo:
.github/workflows/ci.yml.github/workflows/release.yml.github/workflows/github-release.yml
Human-readable release notes live in CHANGELOG.md.
Release flow:
- Update
versioninpyproject.toml - Move
Unreleasednotes into a new version section inCHANGELOG.md - Merge to
main - Run the
Releaseworkflow fortestpypi - Verify the package from TestPyPI
- Run the
Releaseworkflow forpypi - Push the matching tag, for example
v0.1.0
Reference Docs
- docs/specs/2026-03-05-klayout-observer-mcp-contract.md
- docs/plans/2026-03-05-klayout-observer-mcp-implementation-plan.md
- docs/plans/2026-03-05-klayout-observer-mcp-design.md
If those documents disagree, follow the contract.
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_mcp-0.1.1.tar.gz.
File metadata
- Download URL: klayout_mcp-0.1.1.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17325f743f6ff185bf0a94f473b2b5ddb95e3c4828d470ef5b417b9936699ddc
|
|
| MD5 |
b04b70176162f4ce3f2cebcb98761733
|
|
| BLAKE2b-256 |
c113e889a90eb098dcff62c3624f21638f4aa0a7a112506b994e9d3a863a2c0a
|
Provenance
The following attestation bundles were made for klayout_mcp-0.1.1.tar.gz:
Publisher:
release.yml on aycandv/klayout-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
klayout_mcp-0.1.1.tar.gz -
Subject digest:
17325f743f6ff185bf0a94f473b2b5ddb95e3c4828d470ef5b417b9936699ddc - Sigstore transparency entry: 1050611936
- Sigstore integration time:
-
Permalink:
aycandv/klayout-mcp@ad4c945bad5bd270beb5eb9b7deffb2e579656bf -
Branch / Tag:
refs/heads/main - Owner: https://github.com/aycandv
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ad4c945bad5bd270beb5eb9b7deffb2e579656bf -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file klayout_mcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: klayout_mcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f2d89f2972b05227dc6d056849e558a22692f9ec13eb0c6b7a2598022bf0a79
|
|
| MD5 |
804983cc58fe824a5d65e25f20418b28
|
|
| BLAKE2b-256 |
6e57bac3db05afc33a028a4931d18af8ff68d9ab4bd095c8ba22b56aa023e78c
|
Provenance
The following attestation bundles were made for klayout_mcp-0.1.1-py3-none-any.whl:
Publisher:
release.yml on aycandv/klayout-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
klayout_mcp-0.1.1-py3-none-any.whl -
Subject digest:
7f2d89f2972b05227dc6d056849e558a22692f9ec13eb0c6b7a2598022bf0a79 - Sigstore transparency entry: 1050611957
- Sigstore integration time:
-
Permalink:
aycandv/klayout-mcp@ad4c945bad5bd270beb5eb9b7deffb2e579656bf -
Branch / Tag:
refs/heads/main - Owner: https://github.com/aycandv
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ad4c945bad5bd270beb5eb9b7deffb2e579656bf -
Trigger Event:
workflow_dispatch
-
Statement type: