dsvlab-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@dsvlab-mcpload the AND gate circuit and run truth table test"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
dsvlab-mcp — DS-VLAB 电路测试 MCP 服务器
让 AI(MCP 客户端)程序化控制 DS-VLAB v2.0 多思计组原理虚拟实验室中的电路:加载电路、上电、施加输入、单步/连续运行、读取引脚与存储、批量跑真值表,实现自动化测试。
架构
AI 客户端 ─stdio─► dsvlab-mcp(本服务) ─Playwright─► Edge/Chromium(加载 index.html)
│ page.evaluate()
▼
window.mycircuit / cDispatch
/ recovercircuit()(原系统全局)不改动原项目任何源码(18 个 component、dispatch、circuitdiagram、fileoperation 一律不动)。
全部新文件集中在
mcp/dsvlab-mcp/。复用原项目
tools/circuit-validator-core.js(UMD)做加载前校验。默认用系统自带的 Edge(
channel: 'msedge'),无需下载 Chromium。
Related MCP server: EDA Tools MCP Server
安装
cd mcp/dsvlab-mcp
npm install
npm run build # tsc 编译到 dist/
# 可选:跑集成测试(会用 Edge headless 加载 example_bus_demo.txt)
npm test不需要
npx playwright install—— 默认走系统 Edge。若想用 Playwright 自带 Chromium,设环境变量DSVLAB_CHANNEL=chromium后执行npx playwright install chromium。
配置(MCP 客户端)
ZCode / Claude Desktop
把 files/config.sample.json 的内容并入客户端的 MCP 配置(按本机实际路径调整):
{
"mcpServers": {
"dsvlab": {
"command": "node",
"args": ["C:/.../dsvlab2.0/mcp/dsvlab-mcp/dist/index.js"],
"env": {
"DSVLAB_INDEX": "C:/.../dsvlab2.0/index.html",
"DSVLAB_CHANNEL": "msedge",
"DSVLAB_HEADLESS": "0"
}
}
}
}环境变量
变量 | 默认 | 说明 |
|
| index.html 绝对路径 |
|
| 浏览器 channel: |
|
|
|
浏览器是 lazy 启动:MCP 服务连上后不立即弹窗,第一次调用工具时才启动。
工具清单(共 25 个)
电路
工具 | 说明 |
| 加载电路 txt(默认先校验,有 errors 拒绝加载) |
| 清空画布 |
画电路(辅助生成,配合 docs/AI画电路手册.md 流程)
工具 | 说明 |
| 列出全部 23 种元件:名称/类型/引脚数 |
| 查元件引脚表(画电路必查,引脚号禁止臆测) |
| 由结构化描述生成合法 txt(带校验),可直接 load_circuit 加载 |
电源
工具 | 说明 |
| 开/关/复位电源 |
仿真
工具 | 说明 |
| 单步:跑空一次就绪队列(一次稳定传播) |
| 连续运行:启动 ContinuousPulse 跑 N 毫秒后停 |
| 停止所有连续脉冲(清 timer) |
| 翻转开关(toggle) |
| 设置开关到 0/1(处理初值高阻,自动判断是否需要翻转) |
| 触发单脉冲(须先 power_on) |
| 给指定引脚施加 0/1 并传播 |
| 设置时钟周期(ms,默认 800,测试建议 50) |
读取
工具 | 说明 |
| 所有元件概览 |
| 元件全部引脚(pinName/pinFunction/pinValue) |
| 读引脚值(0低 / 1高 / 2高阻) |
| 读写 RAM6116/EPROM memory(运行时,不随 txt 保存) |
| 全电路所有引脚快照 |
批量测试
工具 | 说明 |
| 批量跑真值表(自动遍历 2^n 或自定义 cases) |
| 一次性断言多引脚值,返回 pass/fail |
使用示例(AI 视角)
1. load_circuit(text=<电路txt全文>) → 加载并校验
2. power_on()
3. set_switch(id="CP8", value=0) → 使能 74LS245
4. for each 输入组合: set_switch + step + read_pin
或直接: run_truth_table(switch_ids=["CP0",...], outputs=[{id,pin}])
5. assert_pins(expected=[{id,pin,value},...])关键技术点
桥接层(
src/inject.ts):注入到页面的一段window.__bridge脚本,把对原系统cDispatch/mycircuit/recovercircuit的调用集中封装,Node 侧通过page.evaluate一次性调用,返回可序列化 JSON。减少跨进程往返。调用对照(均已查源码确认):
加载:
recovercircuit('demo', mycircuit, txt)(fileoperation.js:136)上电/断电:
cDispatch.powerOn()/powerOff()(dispatch.js:93/99)单步:
cDispatch.runCircuit()(dispatch.js:75)触发源器件:
cDispatch.sourceTrigger(c|id)(dispatch.js:86)读引脚:
comp.pinValue[pinNo](0低/1高/2高阻)
pinValue 三态:0 低 / 1 高 / 2 高阻未驱动,断言要区分。
Switch 初值坑:原系统
new Array([0])产生[[0]],pinValue[0]实际是数组[0],[0]==0成立但[0]===0不成立。故setSwitch用宽松比较!=,与原系统一律==的语义一致。memory 限制:RAM6116/EPROM 的 memory 硬编码在源码(
js/component/ram6116.js等),不随电路 txt 保存;运行时component.memory可读写,但刷新页面会重置回源码值。异步脉冲:
ContinuousPulse/SinglePulse用setTimeout自驱动(默认 800ms);run(duration)用真实等待,stop()清 timer。测试时set_pulse_width(50)加速。MCP 用 stdio:禁用
console.log(破坏协议流),用console.error。TS + zod + MCP SDK 的 TS2589:zod
ZodRawShape与 SDK 泛型组合会触发 "Type instantiation excessively deep"。本项目统一用server.registerTool<any, any>+ handler(args:any, _extra:any): Promise<any>规避。
调试
# MCP Inspector:浏览器里查看所有工具、手动调用
npx @modelcontextprotocol/inspector node dist/index.js
# 跑集成测试
npm test已知限制
不改原项目源码,因此 RAM/EPROM memory 初值仍需改
js/component/*.js(本工具只在运行时改component.memory,刷新即失)。run(duration)基于真实时钟等待,大批量时序测试较慢;组合逻辑用step/run_truth_table即可。单步无 GUI 按钮,
step=cDispatch.runCircuit()(跑空就绪队列)。
集成测试结果
tests/integration.test.ts 用 files/examples/example_bus_demo.txt(8 开关 → 74LS245 → 8 LED)端到端验证:
✅ 加载 18 个元件
✅
-E=0使能时 A→B 透传,8 个 LED 全亮✅
-E=1禁能时 B 侧高阻,LED 不亮
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/tunmhub/dsvlab-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server