Skip to main content
Glama
Digital MCP Server

Digital MCP Server

by NeuronCState

Digital MCP 服务

这是一个用于 Digital 逻辑电路模拟器的 stdio MCP 服务。它让 MCP 客户端可以直接创建、检查、验证、仿真和导出 .dig 电路文件,不需要手动操作窗口或截图。

能做什么

  • 根据结构化设计生成 Digital .dig 电路文件。

  • 检查电路元件、坐标、属性和连接线。

  • 调用 Digital 的无头 CLI 验证内置测试用例。

  • 导出静态电路图为 SVG 或高分辨率 PNG。

  • 设置 In 输入或 Button 按钮状态,导出真实仿真状态图片。

  • 从 .dig 中读取 Testcase,生成带 PASS/FAIL 结果的真值表图片。

  • 将电路安全加载到 macOS Digital.app。

仿真图片不依赖 GUI 鼠标点击,而是创建 Digital 模型、写入输入状态并重新计算, 因此可以稳定复现“一个按钮激活”“两个按钮激活”等状态。

Related MCP server: Logisim Live MCP

安装和运行

在 MCP 仓库根目录运行:

python3 digital_mcp_server.py

MCP 客户端配置示例:

{
  "mcpServers": {
    "digital": {
      "command": "python3",
      "args": ["/绝对路径/digital-mcp-server/digital_mcp_server.py"],
      "env": {
        "DIGITAL_PROJECT_ROOT": "/绝对路径/Digital",
        "DIGITAL_JAR": "/绝对路径/Digital/source/target/Digital.jar",
        "DIGITAL_APP": "/绝对路径/Digital/modern/dist/Digital.app"
      }
    }
  }
}

如果 MCP 服务和 Digital 不在同一个目录,可使用以下环境变量:

DIGITAL_PROJECT_ROOT       Digital 项目根目录,可选
DIGITAL_JAR                Digital.jar 路径,建议明确设置
DIGITAL_JAVA               Java 21 可执行文件路径,可选
DIGITAL_APP                Digital.app 路径,用于加载电路
DIGITAL_SVG_CONVERTER      SVG 转 PNG 程序,可选
DIGITAL_MCP_OUTPUT_DIR     默认生成文件目录,可选

PNG 导出需要以下任意一种程序:rsvg-convert、magick、convert 或 inkscape。也可以通过 DIGITAL_SVG_CONVERTER 指定路径。

主要 MCP 工具

digital_build_circuit

根据 design 对象生成 .dig 文件。可选参数:

  • run_tests: true:运行内置测试。

  • render_svg: true:同时导出 SVG。

  • open: true:在 macOS 中加载到 Digital。

最小设计示例:

{
  "elements": [
    {"id": "a", "type": "In", "label": "A", "x": 200, "y": 100},
    {"id": "g", "type": "And", "x": 280, "y": 100},
    {"id": "y", "type": "Out", "label": "Y", "x": 380, "y": 100}
  ],
  "wires": [
    {"from": "a", "to": "g", "input": 0},
    {"from": "g", "to": "y"}
  ],
  "tests": [
    {"inputs": {"A": 0}, "outputs": {"Y": 0}},
    {"inputs": {"A": 1}, "outputs": {"Y": 1}}
  ]
}

支持的常用元件包括 In、Out、And、Or、XOr、XNOr、NAnd、 NOr、Not、Clock、Const、Ground、VDD 和 Testcase。 需要完整字段或引脚规则时,先调用 digital_design_schema。

digital_inspect_circuit 和 digital_run_tests

{"path": "/绝对路径/example.dig"}

digital_inspect_circuit 返回元件和连线信息;digital_run_tests 调用 Digital 模拟器运行测试,并返回 passed、退出码和命令输出。

digital_export_rendered_image

导出静态电路图:

{
  "path": "/绝对路径/motor_fault_indicator.dig",
  "format": "png",
  "output_path": "/绝对路径/motor_fault_indicator.png",
  "pixel_width": 4096
}
  • format:svg 或 png,默认是 png。

  • pixel_width:PNG 宽度,默认 2048,可设置为 4096 或更高。

  • output_path:建议使用绝对路径;相对路径只能写入输入文件所在目录。

SVG 直接由 Digital CLI 导出;PNG 先生成 SVG,再用 SVG 转换器按指定宽度渲染。

digital_export_simulation_image

设置输入或按钮状态后导出仿真图片:

{
  "path": "/绝对路径/motor_fault_indicator.dig",
  "inputs": {"A": 1, "B": 0},
  "format": "png",
  "pixel_width": 4096,
  "scale": 30
}

输入值支持数字、布尔值和字符串。In 元件使用信号名匹配,Button 元件使用 按钮标签匹配:

  • A=1,B=0:一个电机工作,黄灯应亮。

  • A=1,B=1:两个电机工作,绿灯应亮。

  • A=0,B=0:两个电机故障,红灯应亮。

也可以将 inputs 写成字符串:"A=1,B=0"。scale 控制 SVG 的逻辑尺寸, hide_test 默认隐藏 Testcase 框。

digital_export_truth_table_image

读取 .dig 中的 Testcase 数据,先执行 Digital 测试,再生成真值表 SVG/PNG:

{
  "path": "/绝对路径/motor_fault_indicator.dig",
  "format": "png",
  "output_path": "/绝对路径/motor_fault_indicator_truth_table.png",
  "pixel_width": 4096
}

返回值同时包含 columns、rows 和 validation,图片标题会显示 PASS 或 FAIL。如果电路没有嵌入 Testcase 数据,工具会返回明确错误。

digital_load_circuit

{
  "path": "/绝对路径/motor_fault_indicator.dig",
  "app_path": "/绝对路径/Digital.app"
}

MCP 不再直接执行 Digital.app/Contents/MacOS/Digital。macOS 上该原生启动器 由 Python 拉起时可能在 Java/AWT 注册阶段触发 SIGABRT。现在工具只使用已经 验证过的外部 Java runtime,并进行启动存活检查;runtime 不可用时会返回错误, 不会再次尝试高风险启动路径。成功返回 loaded: true 和 launcher: "managed-runtime"。

生成文件位置

独立 MCP 仓库运行时默认写入服务目录下的 generated/。也可以用 DIGITAL_MCP_OUTPUT_DIR 自定义目录。

本地验证

运行 Python 测试:

python3 -m py_compile digital_mcp_server.py

仿真快照的底层 CLI 也可以直接运行:

java -Djava.awt.headless=true \
  -cp source/target/Digital.jar CLI snapshot \
  -dig /绝对路径/Digital/mcp/generated/motor_fault_indicator.dig \
  -svg /tmp/motor_fault_indicator_A1_B0.svg \
  -inputs A=1,B=0 -scale 30

Available Tools

10 tools
digital_build_circuitB

Build a Digital .dig file from a structured circuit design, optionally test, render and open it. The host AI should translate text or an attached image into this design object.

Inputs: design (required), open, file_name, run_tests, +2 more.

digital_design_schemaA

Return the structured design schema and supported common gate pin conventions.

Inputs: no named parameters.

digital_export_rendered_imageA

Export a rendered image of a .dig circuit. format=svg reuses Digital's CLI SVG export; format=png (default) generates the SVG first, then converts it at the requested pixel width with DIGITAL_SVG_CONVERTER or rsvg-convert/magick/convert/inkscape from PATH.

Inputs: path (required), format, output_path, pixel_width, +1 more.

digital_export_simulation_imageB

Apply input/button states such as {A: 1, B: 0}, render the live Digital model, and export a high-resolution SVG or PNG snapshot. The circuit is simulated headlessly; the GUI is not driven.

Inputs: path (required), scale, format, inputs, +4 more.

digital_export_truth_table_imageA

Read embedded Digital Testcase data, validate it with Digital's simulator, and export a polished truth-table/results image as SVG or high-resolution PNG.

Inputs: path (required), format, output_path, pixel_width, +1 more.

digital_inspect_circuitB

Read a Digital .dig file and return its elements, positions, attributes and wires.

Inputs: path (required).

digital_load_circuitC

Load a .dig file into the modern Digital.app on macOS using the safest available launcher; returns loaded, app, path and launcher.

Inputs: path (required), app_path.

digital_open_circuitC

Open a .dig file in the modern Digital.app on macOS.

Inputs: path (required), app_path.

digital_render_circuitA

Render a Digital .dig file using Digital's CLI. Kept for compatibility; use digital_export_rendered_image for the explicit SVG/PNG interface.

Inputs: path (required), format, output_path, timeout_seconds.

digital_run_testsB

Run the test cases embedded in a Digital .dig file through Digital's headless CLI.

Inputs: path (required), verbose, timeout_seconds.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 10 tools

    Disambiguation2/5

    digital_open_circuit and digital_load_circuit both launch the same GUI app with only subtle differences in return metadata, and digital_render_circuit is an explicit legacy duplicate of digital_export_rendered_image. These overlapping pairs create real misselection risk, even though the build/inspect/test/export tools are otherwise distinct.

    Naming Consistency4/5

    The tools consistently use a digital_ prefix with snake_case action phrases such as run_tests, build_circuit, and export_*_image. digital_design_schema is slightly off-pattern because it reads as a noun phrase rather than verb+object, but there is no mixed casing or chaotic style.

    Tool Count4/5

    Ten tools is a reasonable size for a circuit design/simulation server, and most tools correspond to a meaningful step in the workflow. The set is slightly padded by redundant legacy/GUI variants, so it is not perfectly minimal.

    Completeness4/5

    The server covers the core workflow from design schema to build, inspect, test, simulate, and export images, so agents can complete end-to-end tasks. There is no tool for updating/deleting an existing circuit, but rebuilding from a structured design largely mitigates that gap.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      Not graded
      maintenance
      Enables AI assistants to perform Electronic Design Automation (EDA) tasks including Verilog synthesis, simulation, ASIC design flows, and waveform analysis through a unified interface.
      6
      ISC
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to build, wire, inspect and simulate digital circuits directly in a running Logisim Evolution window, with every edit appearing live and undoable. Agents work from exact ports, real netlists and truth tables rather than screenshots, and can verify designs through simulation.
      5
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables Claude to draw, simulate, and verify Logisim-evolution 5 circuits directly from natural-language descriptions, without opening the GUI — it lays out components, routes wires, and returns images of the resulting .circ files. It also synthesizes circuits from formulas or truth tables (minimizing to MDNF/MKNF and converting to NAND/NOR bases), detects wiring faults, and checks behavior against expected outputs or clock sequences.
      9
      2
      GPL 3.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP clients to build Logisim circuits from natural language by adding pins, gates, LEDs and wires through tools that return exact port coordinates, then saving the result as a .circ file. It also runs Logisim's own loader to read the file back and report dangling wire ends and multi-driver shorts.
      MIT