pyslang-mcp

io.github.ariklapid由 GitHub 账号 ariklapid 发布v0.1.0更新于 Oct 24, 2026

Compiler-backed read-only Verilog and SystemVerilog project analysis.

已验证STDIO仅桌面开发者工具数据与分析

概览

AI 生成的概览

一个本地、只读的 MCP 服务器,借助 pyslang 为助手提供基于编译器的 Verilog 与 SystemVerilog 项目分析。

可以做什么
加载并解析 HDL 源码,可直接指定文件,也可使用带 include 与 define 的 .f 文件列表,并报告预处理元数据与不支持的文件列表条目。获取解析与语义诊断,按错误码分组,并列出或描述模块、接口与包。遍历展开后的实例层次,导出单个实例的端口连接。查找符号声明与引用、单元内成员以及信号赋值,并追踪有界结构连通性。生成语法树摘要与紧凑的项目概览。
适用场景
当助手需要针对现有 RTL 的编译器前端证据而非文本搜索时适用:排查诊断、确认文件列表展开结果、列出设计单元、定位声明,或获取层次与端口上下文用于审查和调试。对于简单的命名或注释问题,普通文本搜索或直接读文件通常更快。
运行要求
作为本地 stdio 进程运行,需与能看到 RTL 代码库的同一台机器、虚拟机或开发容器。从 PyPI 安装 pyslang-mcp 包(CI 覆盖 Python 3.11 与 3.12),通过控制台脚本或 python -m pyslang_mcp 启动。每次工具调用都必须提供 project_root,路径须位于其下。未声明认证、环境变量或请求头。
安装前请注意
设计上只读:不编辑 RTL、不格式化、不仿真、不综合,project_root 之外的路径会被拒绝。结果仅为编译器前端证据,不代表仿真、形式验证、时序、CDC/RDC 或完整 lint 签核。大型结果集会带元数据被截断。streamable-http 模式为实验性,本身不是完整的托管安全边界;公开 OSS MaaS 路线不适合专有 RTL。项目处于早期阶段,API 尚未冻结。

安装

在 SourceWeft 中

  1. 打开 控制台中的 pyslang-mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

pyslang-mcp

[CI] [PyPI] [Python] [Status] [Transport]

pyslang-mcp is a local Model Context Protocol server that gives AI agents compiler-backed, read-only context for Verilog and SystemVerilog projects.

It wraps pyslang so an MCP client can ask questions against parsed and elaborated HDL instead of plain text:

  • What modules, interfaces, and packages are in this filelist?
  • What diagnostics does the compiler frontend report?
  • What is the instance hierarchy below this top?
  • Where is this symbol declared or referenced?
  • Did my include paths, defines, and nested .f files resolve as expected?

This is not a simulator, synthesizer, waveform viewer, linter replacement, or RTL refactoring tool. It is a small semantic analysis service for local HDL checkouts.

That read-only boundary is intentional. It keeps the server side-effect free, reduces the blast radius in IP-protected workspaces, and makes it safer to use in local and CI environments.

It was decided to keep pyslang-mcp read-only. The LLM handles the actual RTL coding, while pyslang-mcp serves as the compile/elab-backed reader, checker, and explainer for code that already exists. In other words, the model drafts the RTL and the MCP server verifies what the compiler frontend sees.

[!NOTE] The project is currently early-stage and published on PyPI and the MCP Registry for local stdio use.

Why ASIC And EDA Engineers Might Care

Most AI coding tools are good at searching text. HDL usually needs more than that.

In real projects, useful answers often depend on filelists, packages, includes, defines, generate blocks, and hierarchy. pyslang-mcp gives an agent a compact compiler-backed view of that structure, while keeping the server read-only and scoped to a project root you provide.

Good fits:

  • triaging parse and semantic diagnostics before asking an agent to reason about RTL
  • checking what a .f file expands to
  • listing design units in a block or small IP
  • finding a declaration without chasing comments and stale grep hits
  • getting hierarchy and port-connection context for review/debug prompts
  • giving workflow agents HDL context without handing them an EDA runtime

Quickstart

Install the package:

bash
pip install pyslang-mcp

Run the local stdio server:

bash
pyslang-mcp

For contributor setup, clone the repo and install it in editable mode:

bash
git clone https://github.com/ariklapid/pyslang-mcp.gitcd pyslang-mcppython -m venv .venv./.venv/bin/pip install -e '.[dev]'

Run the checkout stdio server:

bash
./.venv/bin/python -m pyslang_mcp

The installed console script works too:

bash
./.venv/bin/pyslang-mcp

Run tests:

bash
./.venv/bin/pytest

MCP Client Config

Use local stdio. The MCP client should launch the server on the same machine, VM, or dev container that can see your RTL checkout.

json
{  "mcpServers": {    "pyslang-mcp": {      "command": "pyslang-mcp",      "args": []    }  }}

For editable checkout installs, point the command at the checkout virtual environment instead:

json
{  "mcpServers": {    "pyslang-mcp": {      "command": "/absolute/path/to/pyslang-mcp/.venv/bin/python",      "args": ["-m", "pyslang_mcp"]    }  }}

Tool calls must provide a project_root. Source paths, filelists, and include directories may be absolute or relative, but they must stay under that root.

Minimal Tool Payloads

Analyze explicit files:

json
{  "project_root": "/path/to/rtl-project",  "files": ["rtl/pkg.sv", "rtl/top.sv"],  "include_dirs": ["include"],  "defines": {    "WIDTH": "32"  },  "top_modules": ["top"]}

Analyze a filelist:

json
{  "project_root": "/path/to/rtl-project",  "filelist": "compile/project.f"}

Find a symbol:

json
{  "project_root": "/path/to/rtl-project",  "filelist": "compile/project.f",  "query": "payload",  "match_mode": "exact",  "include_references": true}

Tools

NeedTool
Load explicit filespyslang_parse_files
Load a .f filelistpyslang_parse_filelist
Get parse and semantic diagnosticspyslang_get_diagnostics
List modules, interfaces, and packagespyslang_list_design_units
Inspect one design unitpyslang_describe_design_unit
Walk the elaborated instance treepyslang_get_hierarchy
Find declarations and referencespyslang_find_symbol
Find a local member in one design unitpyslang_find_member
Find assignments involving a signalpyslang_get_assignments
Trace bounded structural connectivitypyslang_trace_connectivity
Dump one instance's port connectionspyslang_get_instance_connections
Group diagnostics by codepyslang_summarize_diagnostics_by_code
Summarize syntax node shapespyslang_dump_syntax_tree_summary
Check preprocessing metadata and excerptspyslang_preprocess_files
Get a compact project overviewpyslang_get_project_summary

Typical flow:

  1. Start with pyslang_parse_filelist or pyslang_parse_files.
  2. Run pyslang_get_diagnostics.
  3. Use pyslang_list_design_units to see what the compiler frontend found.
  4. Use pyslang_describe_design_unit, pyslang_get_hierarchy, or pyslang_find_symbol for the actual review/debug question.

Verilog/SystemVerilog Analysis And Debugging Flow

  1. Use pyslang_summarize_diagnostics_by_code to separate repeated frontend warnings from unresolved dependency errors.
  2. Use pyslang_find_member to locate local names such as response__vld.
  3. Use pyslang_get_assignments to inspect visible continuous or procedural drivers and loads.
  4. Use pyslang_get_instance_connections for one instance's port binding context.
  5. Use pyslang_trace_connectivity for bounded structural paths through assignments and instance port bindings.

Connectivity tracing is structural frontend evidence. It is not simulation, formal proof, CDC/RDC signoff, timing signoff, or a complete netlist-level driver/load database.

Filelist Support

The current parser intentionally supports a practical subset used by many RTL flows:

  • source file entries
  • nested filelists with -f and -F
  • include directories with +incdir+..., -I dir, and -Idir
  • defines with +define+..., -D NAME, and -DNAME

Unsupported filelist tokens are reported in the tool output instead of being silently ignored.

Example Agent Prompts

Use this server when compiler-backed context matters:

  • "Parse compile/project.f with +define+DEBUG and group diagnostics by source file."
  • "List every design unit in this project and identify the likely top modules."
  • "From top, show the instance hierarchy down to depth 4."
  • "Describe module axi_dma_top: ports, child instances, and declared names."
  • "Find the declaration and references for payload_valid."
  • "Confirm whether legacy_widget is instantiated anywhere the elaborator sees it."
  • "Show the resolved files, include dirs, defines, and unsupported entries from this filelist."

For single-line questions, comments, naming searches, or partial/incomplete source sets, regular rg, editor search, or direct file reading is usually faster and clearer.

Guardrails

  • Read-only MCP tools. No RTL edits, formatting, simulation, or synthesis.
  • Strict project-root scoping. Paths outside project_root are rejected.
  • Compact JSON responses with truncation metadata for large result sets.
  • Process-local cache keyed by project config and tracked file mtimes.
  • pyslang_preprocess_files is summary-oriented. It returns preprocessing metadata and source excerpts, not a guaranteed full standalone preprocessed stream.
  • streamable-http remains experimental. The internal MaaS path wraps it with a bearer token for single-server use, but it is not a complete production hosted security boundary by itself.

Remote MaaS Direction

Remote MaaS is planned as two separate tracks, not as one generic hosted mode:

  • Plan A: public OSS MaaS. A convenience/demo service for public open-source HDL repositories. This is not suitable for proprietary or confidential RTL.
  • Plan B: internal MaaS. A self-hosted deployment pattern for companies to run inside their own network, close to internal repositories, auth, logging, and security controls.

Start with the internal MaaS quickstart for a single internal server. See REMOTE_DEPLOYMENT.md for the full Plan A / Plan B split.

Docker Compose is the recommended bring-up path because it avoids Python setup issues and mounts the RTL checkout read-only. Docker is not required; the quickstart also includes a native Python path for corporate servers where containers are not available.

HDL Example Corpus

The repo includes generated HDL examples under examples/hdl:

  • clean reference projects from single modules to small IP-style examples
  • intentionally buggy variants labeled easy, medium, and hard
  • local validation hooks for both pyslang and verilator --lint-only

Run the full corpus validator:

bash
./.venv/bin/python scripts/validate_hdl_examples.py

Run the CI smoke subset:

bash
./.venv/bin/python scripts/validate_hdl_examples.py --smoke-only

Using With Broader RTL Skills

If your agent environment already has a broad RTL skill such as rtl-analysis, rtl-audit, or llm-based-verilog-analysis, use pyslang-verilog-context as the fine-grained compiler-evidence layer beneath that broader skill.

Recommended setup:

  1. Configure the pyslang-mcp server in your MCP client so the agent can call the read-only pyslang_* tools.
  2. Install or copy the pyslang-verilog-context skill from skills/pyslang-verilog-context.
  3. Add a delegation note like this to your broader RTL skill:
text
For Verilog/SystemVerilog tasks, use $pyslang-verilog-context before makingclaims about diagnostics, design units, ports, hierarchy, declarations,references, includes, defines, or filelist behavior. Treat its output ascompiler frontend evidence only. Do not present it as simulation, synthesis,timing, CDC/RDC, formal, or full lint signoff.

The intended flow is:

text
user RTL request  -> broad RTL analysis/audit skill  -> pyslang-verilog-context  -> pyslang-mcp compiler-backed evidence  -> final answer with evidence and limitations

This keeps high-level RTL review policy in the broad skill while grounding Verilog/SystemVerilog structure, diagnostics, hierarchy, symbols, includes, and filelists in pyslang.

Evaluation Benchmarks

The repo includes a pyslang-verilog-context skill eval suite under skills/pyslang-verilog-context/evals and comparison reports under reports/. The current benchmark compares three local evidence modes:

  • text/no skill: source and filelist text heuristics only
  • MCP/no skill: targeted pyslang-mcp tool calls
  • skill + MCP: pyslang-verilog-context sequencing with pyslang-mcp

Latest local result from 2026-06-14:

BenchmarkText/no skillMCP/no skillSkill + MCP
100 HDL analysis cases60/10095/100100/100

The benchmark mixes deterministic repo-local HDL fixtures with real public RTL source files. The local fixtures exercise targeted behaviors such as filelists, hierarchy, symbols, diagnostics, clean-frontend functional bugs, and RTL coding and bug-audit discipline. The real public RTL cases use source files from lowrisc-ibex, pulp-common-cells, verilog-axis, pulp-axi, pulp-register-interface, and picorv32. They exercise frontend diagnostic status, design-unit inventory, and first-unit port counts on real source files. See docs/evaluation-benchmarks.md for the prompt/task shapes and MCP functions used.

Verification commands used for the reported run:

bash
./.venv/bin/python skills/pyslang-verilog-context/scripts/validate_eval_fixtures.py./.venv/bin/python -m pytest./.venv/bin/python skills/pyslang-verilog-context/scripts/run_comparison_evals.py./.venv/bin/python scripts/run_mcp_comparison.py --output-dir reports/mcp_comparison_comprehensive_20260614./.venv/bin/python reports/real_examples_75/run_real75_comparison.py./.venv/bin/python -m py_compile reports/real_examples_75/run_real75_comparison.py

These are deterministic scalar harnesses, not blind autonomous LLM-judge runs. pyslang-mcp evidence remains frontend/compiler context only, not simulation, synthesis, CDC/RDC, timing, formal, or full lint signoff.

Documentation-only eval/report updates do not require a PyPI release. A PyPI release is warranted when package code, public tool behavior, schemas, runtime dependencies, CLI behavior, or user-facing install/runtime docs change in a way published users need.

Project Status

Implemented:

  • FastMCP stdio server
  • CLI entrypoint via python -m pyslang_mcp and pyslang-mcp
  • project loader with root checks and .f parsing
  • pyslang-backed diagnostics and diagnostic grouping, design-unit and member lookup, assignment and instance-connection analysis, bounded structural connectivity, hierarchy, syntax summaries, and project summaries
  • bounded in-memory cache
  • fixture-backed tests and Ubuntu CI for Python 3.11 and 3.12
  • package smoke CI from a built wheel
  • manual PyPI Trusted Publishing release workflow with release-gate tests
  • PyPI package: pyslang-mcp
  • MCP Registry entry: io.github.ariklapid/pyslang-mcp
  • internal MaaS bring-up artifacts: Dockerfile, Docker Compose config, native Python fallback instructions, systemd template, bearer-token HTTP option, and a single-server quickstart

Not done yet:

  • schema freeze for a more mature API-stable release
  • broad platform validation beyond the current Linux-focused CI path
  • production MaaS hardening for broad team use: SSO, multi-workspace routing, Kubernetes deployment, source-safe metrics, and reverse-proxy examples

Development

Useful commands:

bash
./.venv/bin/ruff check ../.venv/bin/pyright./.venv/bin/pytest

Architecture and contribution docs:

License

Apache-2.0. See LICENSE.

来源:README.md,提交 3effff5

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分