Skip to main content
Glama
circuitjs-mcp

circuitjs-mcp

by Suzu-Gears

circuitjs-mcp

An MCP server that lets AI agents operate the Falstad CircuitJS1 circuit simulator. Since it is a standard stdio MCP server, it works with any MCP-compatible client, including Claude Code, Codex CLI, Claude Desktop, and Cursor.

CircuitJS1 is the name of the HTML5/JavaScript version of Paul Falstad's circuit simulator—long familiar as the Java applet version, "Circuit Simulator Applet", and now running in the browser at falstad.com/circuit. When browsers discontinued Java applet support, Iain Sharp ported it to JavaScript with GWT; both the simulation engine and the circuit text format are shared with the applet version (circuit files from the applet era can be loaded as-is). The JavaScript interface this server uses is a feature added in CircuitJS1 and is not present in the applet version.

The server launches the compiled CircuitJS1 web app (bundled in webapp/, works offline) inside headless Chromium (Playwright) and exposes its JavaScript interface as MCP tools. Simulator state persists across tool calls, so you can interactively load a circuit → run it → take measurements → rewrite the circuit.

Setup

Prerequisites: Node.js 18 or later.

cd circuitjs-mcp
npm install          # postinstall で Playwright の Chromium も入ります
npm test             # スモークテスト(RC回路の過渡応答が理論値と一致するか等を検証)

If playwright install chromium is difficult in your environment, you can use an existing Chrome/Chromium:

export CIRCUITJS_CHROMIUM="/usr/bin/google-chrome"   # 例

Related MCP server: circuit-sim-mcp

Registering with MCP cliients

The launch command is the same for every client: node /絶対パス/circuitjs-mcp/server.mjs

Adding the environment variable CIRCUITJS_HEADFUL=1 displays the browser window, allowing a human to operate the same simulator directly alongside the agent (collaboration mode). All examples below include this variable; remove it if not needed.

Claude Code:

claude mcp add circuitjs -e CIRCUITJS_HEADFUL=1 -- node /絶対パス/circuitjs-mcp/server.mjs

Codex CLI:

codex mcp add circuitjs --env CIRCUITJS_HEADFUL=1 -- node /絶対パス/circuitjs-mcp/server.mjs

Clients that use config files (Claude Desktop's claude_desktop_config.json, Cursor's mcp.json, etc.):

{
  "mcpServers": {
    "circuitjs": {
      "command": "node",
      "args": ["/絶対パス/circuitjs-mcp/server.mjs"],
      "env": { "CIRCUITJS_HEADFUL": "1" }
    }
  }
}

The screenshot tool returns a PNG as MCP image content. On clients that do not support image display, save it to a file with the save_path argument instead.

List of tools

Tool

Description

circuit_load

Loads a circuit in Falstad text format (with validation). Returns the element list

circuit_state

Gets the time, voltage differences / currents / terminal voltages of all elements, and voltages of labeled nodes

run_transient

Runs for the specified simulation time and returns sampled time series from probes (node voltages, element current/voltage/power)

sim_control

run / stop / reset / status, maximum timestep setting, and value setting for external voltage sources

circuit_export

Exports the circuit in Falstad text or SVG

circuit_link

Generates a URL (?ctz= link) that opens the current circuit (or the specified text) directly on falstad.com. Use this when you want to inspect or edit it interactively in a browser

screenshot

PNG screenshot of the current schematic (returned as an image; can also be saved to a file)

eval_js

Escape hatch for operations not covered above. Executes arbitrary JS on the sim object

Usage examples (sample instructions for an agent)

  • "Build an RC low-pass filter with 1kΩ and 1µF, feed it a 1kHz square wave, and capture the output waveform for 5ms."

  • "Load this circuit (paste the text) and list the power dissipation of each resistor."

  • "Show me a screenshot of the circuit."

To measure a point of interest, place a labeled node (element type 207, e.g. 207 336 128 400 128 4 out); the voltage can then be read with a {"node":"out"} probe or via circuit_state's nodes. For per-element current and voltage, use the index returned by circuit_load / circuit_state.

Direct use from scripts

If you want to call the tools from a script without going through an MCP client, use drive.mjs. It starts the server as a child process, executes the JSON files placed in the command directory (cmd-1.json, cmd-2.json, ...) in order, and writes the results to res-N.json:

node drive.mjs /tmp/cjs-commands
# 別プロセスから: echo '{"tool":"circuit_state","args":{}}' > /tmp/cjs-commands/cmd-1.json

Write files under a temporary name and then rename them into place (to avoid reading them mid-write).

Environment variables

Variable

Description

CIRCUITJS_CHROMIUM

Path to the Chrome/Chromium executable to use (default: Playwright-managed Chromium; falls back to system Chrome if it fails)

CIRCUITJS_URL

URL of a CircuitJS1 web app to load instead of the bundled one (e.g., https://www.falstad.com/circuit/circuitjs.html)

IRCUITJS_HEADFUL

Set to 1 to show the browser window (for debugging)

Limitations

  • The simulation speed of run_transient depends on the simulation speed setting in the circuit's $ line and on the CPU. If it takes too long in wall-clock time, it is cut off by wallTimeoutMs and partial data is returned (distinguishable via the reason field).

  • "Editing" a circuit basically means rewriting the Falstad text and calling circuit_load again (importing resets the time).

  • Transient analysis only (CircuitJS1 itself does not have AC small-signal analysis, etc.). Frequency response can be obtained by sweeping the frequency and repeating run_transient.

License

This entire repository is provided under GPL-2.0-or-later (COPYING.txt).

  • CircuitJS1 is GPLv2+ software by Paul Falstad / Iain Sharp. webapp/ is its compiled build (unmodified); the corresponding source code is available at pfalstad/circuitjs1 (the original) and the pages branch of code4fukui/circuitjs1 (where this build was obtained).

  • Server code (server.mjs, drive.mjs, test-client.mjs) © 2026 Suzu(涼鈴), GPL-2.0-or-later.

Available Tools

8 tools
circuit_exportExport circuitB

Export the current circuit as Falstad text format, or as an SVG drawing of the schematic.

Inputs: format.

circuit_loadLoad circuitA

Replace the current circuit with the given circuit definition in Falstad CircuitJS1 text format (the same format produced by File > Export as Text, starting with a "$" line). Resets simulation time to 0. Returns the list of parsed elements so you can verify the circuit and note element indices for probing. The simulator keeps state between tool calls.

Inputs: text (required), run.

circuit_stateRead circuit stateA

Read the current simulation state: time, running flag, timestep, and every element with its voltage difference, current, post voltages and info string. Use the element index values with run_transient probes. Optionally pass node names (of labeled nodes, e.g. from "207 ..." labeled-node elements) to read their voltages.

Inputs: nodes.

eval_jsEvaluate JavaScript against the simulatorA

Advanced escape hatch: run arbitrary JavaScript inside the CircuitJS1 page. The code is the body of an async function receiving sim (the CircuitJS1 object, see https://www.falstad.com/circuit/doc/js-interface.html). Return a JSON-serializable value. Example: "return sim.getElements().filter(e => e.getType()==='ResistorElm').map(e => e.getCurrent())".

Inputs: code (required).

run_transientRun transient simulationA

Run the simulation for a given amount of SIMULATED time while sampling probes, then stop. Returns time-series data {t, }. Probes: {"node":"name"} reads a labeled node voltage; {"element":i,"quantity":"current"|"voltageDiff"|"power"} reads element i (indices from circuit_state/circuit_load). Simulation speed is bounded by the circuit's sim-speed setting and CPU, so wall-clock time may differ from simulated time; the call aborts with partial data if wallTimeoutMs elapses first.

Inputs: probes (required), seconds (required), fromReset, maxSamples, +1 more.

screenshotScreenshot the schematicA

Take a PNG screenshot of the circuit as currently drawn (including scope traces if the circuit defines scopes). Returns the image; optionally also saves it to save_path.

Inputs: save_path.

sim_controlControl simulationB

Start/stop/reset the simulation, set the max timestep, or set the voltage of an external voltage source (an "Extern voltage" element, type ExtVoltageElm, addressed by its name). "reset" reloads the current circuit, zeroing time and all state.

Inputs: action, extVoltage, maxTimeStep.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool has a clear, distinct role: loading/exporting circuits, reading state, controlling simulation, running transient probes, taking screenshots, generating links, and escaping to JS. circuit_state and run_transient are separated clearly as snapshot vs. time-series sampling.

    Naming Consistency3/5

    Four tools use the circuit_ prefix, while sim_control, run_transient, screenshot, and eval_js follow different patterns. The names are still readable, but the convention is not uniformly applied across the server.

    Tool Count5/5

    Eight tools is a well-scoped count for a circuit simulator server. Each tool maps to a meaningful user need without redundancy or bloat.

    Completeness5/5

    The set covers the full simulation workflow: load, export, inspect, control, run transient analysis, capture output, and share. eval_js provides an escape hatch for anything not explicitly exposed, leaving no obvious dead ends.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Generates, simulates, and inspects LTspice circuits via MCP tools and resources, providing structured JSON interfaces for AI agents.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides circuit simulation capabilities via MCP, enabling creation, simulation (DC, AC, transient), and analysis of electronic circuits using PySpice.
      1
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables MCP-compatible agents to generate Qucs circuit schematics, run simulations, and parse results programmatically.
      2
      MIT