circuitsnap

circuitsnap

Enables building and simulating electronic circuits by converting netlist descriptions or drawings into live CircuitJS1 simulation URLs.

Category
访问服务器

README

circuitsnap

Snap it, sim it. Turn a circuit drawing — a photo, a sketch, or just a description — into a live simulation in Falstad's CircuitJS1.

Ships as an MCP server (so Claude and other assistants can build circuits), a CLI, and a library.

$ circuitsnap build rc.json
https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxAUgo...

$ 1 0.000005 10.20027730826997 50 5 50
v 128 64 192 64 0 0 40 5 0 0 0.5
r 384 64 448 64 0 10000
c 128 176 192 176 0 0.000001 0 0
...

Open the URL and the circuit is running.

Why

Asking a language model to write CircuitJS1's file format directly does not work. The format is positional and unforgiving — v 128 64 192 64 0 0 40 5 0 0 0.5 has six trailing parameters whose order, units and flag bits are only discoverable by reading the simulator's Java source. A wrong guess produces a circuit that loads happily and simulates incorrectly, which is the worst possible failure: the user cannot tell.

circuitsnap moves that job into tested code. The model describes what connects to what; this library handles format, geometry, escaping and encoding.

Install

npm install -g circuitsnap

As an MCP server

{
  "mcpServers": {
    "circuitsnap": { "command": "npx", "args": ["-y", "circuitsnap-mcp"] }
  }
}

(circuitsnap is the CLI; circuitsnap-mcp is the stdio server. circuitsnap mcp runs the server too, if you prefer a single binary.)

For Claude Code, also copy skills/circuitsnap/ into .claude/skills/ to get the /circuitsnap workflow, which covers reading a drawing and verifying the result.

Usage

Describe the circuit as a netlist — components and net names, no coordinates:

{
  "title": "RC lowpass",
  "components": [
    { "id": "V1", "kind": "voltage",   "nodes": ["gnd", "in"],  "value": 5 },
    { "id": "R1", "kind": "resistor",  "nodes": ["in", "out"],  "value": "10k" },
    { "id": "C1", "kind": "capacitor", "nodes": ["out", "gnd"], "value": "1uF" }
  ]
}

Terminals sharing a net name are connected. That is the whole model.

circuitsnap build rc.json          # URL + circuit text
circuitsnap build rc.json --url    # just the URL
circuitsnap elements               # pin order and parameters for every kind
circuitsnap decode "<share-url>"   # read someone else's circuit

As a library:

import { snap } from 'circuitsnap';

const { url, text, diagnostics } = snap({
  components: [
    { id: 'V1', kind: 'voltage',  nodes: ['gnd', 'in'], value: 5 },
    { id: 'R1', kind: 'resistor', nodes: ['in', 'gnd'], value: '1k' },
  ],
});
console.log(url.url);

Values

Engineering notation, written the way a person writes it on a schematic:

Input Value
"10k" 10 000
"2.2uF" 2.2e-6
"4k7" 4700
"1M" 1e6 (mega, not milli)
"1R2" 1.2

M is mega and m is milli — the schematic convention. SPICE's M-means-milli would turn a hand-labelled "10M resistor" into 10 milliohms.

Elements

wire, resistor, capacitor, inductor, voltage, rail, ground, switch, diode, led, current, labeledNode, transistor, opamp, output, probe, text.

Run circuitsnap elements for pin order, parameters, units and defaults. Pin order matters: a transistor is [base, collector, emitter], an op-amp is [minus, plus, out].

Ground

Use the net name gnd (or ground, 0, vss). Those terminals get a real ground symbol, not a label — a labeled node named "gnd" carries no 0 V reference and would leave the solver without a datum. circuitsnap warns if a circuit has no ground at all.

How it works

The pipeline is netlist -> validate -> lay out -> emit -> URL, with only the reading a drawing step needing a model. Two decisions are worth knowing about:

  • Nets are wired with named labels, not routed wires. An auto-router that is 95% correct produces circuits that look right and simulate wrong. A label next to a pin is verifiable. Output reads like a hierarchical schematic.
  • We emit the legacy text format, not XML. Current upstream writes XML but still reads text, so text is the only encoding that loads on both old and new builds.

See docs/ARCHITECTURE.md for the reasoning and docs/FORMAT.md for the file-format reference, derived from the upstream source with line citations.

Correctness

The format is reverse-engineered, so correctness is load-bearing:

  • 372 upstream circuits round-trip byte-identically through the parser.
  • Generated output is checked for terminal coincidence, escaping, and the flag bits upstream forces on.
  • Live verification: generated circuits are loaded into the real simulator and node voltages read back. That is how the multi-pin geometry was validated — an op-amp follower must actually follow, and a transistor must report fwd active with Ic/Ib = β.
npm run reference:fetch   # clone upstream (not vendored; see docs/LICENSING.md)
npm test

The test suite makes no network requests.

Licence

circuitsnap is MIT. CircuitJS1 is GPL-2.0-or-later by Paul Falstad and Iain Sharp, and is neither bundled nor modified here — circuitsnap generates files in its format and opens its URL. See docs/LICENSING.md for the full reasoning, including how this project handles falstad.com's AI-crawler signals (short version: no crawling, no scraping, tests are fully offline, and --base-url lets you point at your own self-hosted copy).

Not affiliated with or endorsed by the CircuitJS1 authors.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选