klayout-mcp
Read-only MCP server for KLayout that opens GDS/OAS layouts, inspects geometry and hierarchy, renders deterministic PNGs, and runs batch DRC with structured JSON output.
README
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.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。