multisim-spice-mcp
by Sharkeeeeeee
README.md
# multisim-spice-mcp
**Let your AI assistant design, simulate and measure circuits on any OS, without a Multisim license, and hand the result to NI Multisim.**
[](https://github.com/Sharkeeeeeee/multisim-spice-mcp/actions/workflows/ci.yml)
[](LICENSE)



English · [繁體中文](README.zh-TW.md)
```
You: Design an RC low-pass with a 1 kHz cut-off, check it, and give me something I can paste into Multisim.
AI: get_template("rc_lowpass", {r: "1.6k", c: "100n"})
simulate(..., {"type": "ac"}) -> -3 dB at 995 Hz, phase -45° there
sweep_parameter(C1 = 68n, 100n, 150n) -> 1.46 kHz / 995 Hz / 663 Hz
monte_carlo(R ±5 %, C ±10 %) -> 995 Hz ± 38 Hz (1σ), 99 % inside 900 Hz–1.1 kHz
plot(...) -> Bode plot image with the -3 dB point marked
to_multisim(...) -> Arbitrary SPICE Block text + .cir file
```
Most Multisim MCP servers drive the Multisim GUI, so they only work on Windows with a licensed Multisim 14 installed. This one runs the circuit in **[ngspice](https://ngspice.sourceforge.io/)**, the open-source SPICE engine, so it works on a Mac, on Linux, in CI or on a school laptop. When you want the circuit in Multisim, it hands you a netlist Multisim accepts. On Windows with Multisim installed, it can also open `.ms14` designs, change values and pull the netlist back out.
- **Simulate what SPICE can:** operating point, DC sweep, AC (Bode) and transient. Results come back as a short summary the model can reason about, not 10,000 raw samples.
- **Measure like a lab bench:** RMS, peak-to-peak, rise/fall time, overshoot, settling time, frequency, -3 dB bandwidth, gain/phase at a frequency, unity-gain frequency, phase margin.
- **Catch mistakes before simulating:** missing ground, floating nodes, nodes with no DC path, missing `.model`/`.subckt`, duplicate names, parallel voltage sources, and the classic "first line is the title" trap.
- **13 lab-ready templates** with textbook hand calculations to compare against: divider, RC/RLC filters, op-amp amplifiers, rectifiers, Zener regulator, LED driver, BJT common-emitter, relaxation oscillator.
- **Parameter sweeps:** "what happens to the bandwidth if C1 is 10n, 100n, 1µ?" in one call, for a component or a `.param`.
- **Tolerance (Monte Carlo) analysis:** vary every resistor ±5 % and capacitor ±10 % and get the mean, spread, percentiles and yield against a spec.
- **Pictures, not just numbers:** waveform plots and Bode plots with the -3 dB points marked, returned as images the assistant can show you.
- **Multisim in and out:** values like `4.7kΩ`, `10µF` and `1MΩ` are converted correctly (SPICE reads `1M` as one *milli*ohm), `GND` becomes node 0, and netlists are prepared for Multisim's Arbitrary SPICE Block.
- **Safe by default:** `.control` blocks in netlists are dropped, because they can run shell commands.
> Not affiliated with or endorsed by NI. Multisim is a trademark of National Instruments.
## Install
1. **Install ngspice** (free):
| OS | Command |
| --- | --- |
| macOS | `brew install ngspice` |
| Debian / Ubuntu | `sudo apt install ngspice` |
| Fedora | `sudo dnf install ngspice` |
| Windows | Download `ngspice-*_64.7z` from [ngspice.sourceforge.io](https://ngspice.sourceforge.io/download.html) and unzip it to `C:\Spice64` (found automatically), or set `NGSPICE_PATH` to `ngspice_con.exe` |
2. **Add the server to your MCP client.** With [uv](https://docs.astral.sh/uv/) nothing else needs installing.
**Claude Code**
```sh
claude mcp add multisim-spice -- uvx --from git+https://github.com/Sharkeeeeeee/multisim-spice-mcp multisim-spice-mcp
```
**Claude Desktop, Cursor, Windsurf** (`claude_desktop_config.json`, `~/.cursor/mcp.json`, ...)
```json
{
"mcpServers": {
"multisim-spice": {
"command": "uvx",
"args": ["--from", "git+https://github.com/Sharkeeeeeee/multisim-spice-mcp", "multisim-spice-mcp"]
}
}
}
```
**VS Code** (`.vscode/mcp.json`)
```json
{
"servers": {
"multisim-spice": {
"command": "uvx",
"args": ["--from", "git+https://github.com/Sharkeeeeeee/multisim-spice-mcp", "multisim-spice-mcp"]
}
}
}
```
For plots, add the `plot` extra: `uvx --from "multisim-spice-mcp[plot] @ git+https://github.com/Sharkeeeeeee/multisim-spice-mcp" multisim-spice-mcp`.
Or with pip: `pip install "multisim-spice-mcp[plot] @ git+https://github.com/Sharkeeeeeee/multisim-spice-mcp"`, then use `multisim-spice-mcp` as the command. On Windows, add the `windows` extra for the Multisim tools: `pip install "multisim-spice-mcp[windows] @ git+https://github.com/Sharkeeeeeee/multisim-spice-mcp"`.
3. Ask your assistant to run `backend_status` to check that ngspice was found.
## Tools
| Tool | What it does |
| --- | --- |
| `backend_status` | Which simulators are available (ngspice path and version, Multisim COM). |
| `list_templates` / `get_template` | Example circuits with parameters, a suggested analysis and the textbook hand calculation. |
| `validate_netlist` | Finds the mistakes that make SPICE fail, with a plain-language fix for each. |
| `parse_netlist` | Elements, nodes, models and analyses as JSON. |
| `build_netlist` | Netlist from a JSON list of components (names are numbered for you). |
| `simulate` | Runs `op`, `dc`, `ac`, `tran`, `tf` (gain and input/output resistance) or `noise`, and returns a compact summary plus a `result_id`. |
| `measure` | Exact measurements on a stored result (see below). |
| `sweep_parameter` | Re-simulates over a list of values for one component or `.param` and measures each run. |
| `monte_carlo` | Component-tolerance analysis: mean, standard deviation, min/max, 5th/95th percentiles, yield against a spec and the worst cases. |
| `plot` | Waveform (tran/dc) or Bode plot (ac) as a PNG image, optionally saved as PNG/SVG. Needs the `plot` extra. |
| `export_csv` | Full-resolution data as CSV, returned or written to a file. |
| `to_multisim` | Text for Multisim's Arbitrary SPICE Block, a complete `.cir` file and the steps. |
| `from_multisim` | Cleans Multisim-style netlists (`kΩ`, `µF`, `MΩ`, `GND`) for SPICE. |
| `convert_value` | Reads a value in SPICE or Multisim notation (`1M` vs `1MEG` vs `1MΩ`). |
| `multisim_open`, `multisim_components`, `multisim_get_value`, `multisim_set_value`, `multisim_export_netlist`, `multisim_save` | **Windows + Multisim only, experimental.** Drive Multisim through NI's Automation API. Registered only on Windows. |
**Measurements:** `max`, `min`, `peak_to_peak`, `average`, `rms`, `value_at`, `cross`, `rise_time`, `fall_time`, `frequency`, `overshoot`, `settling_time`, and for AC results `gain_db_at`, `phase_at`, `bandwidth_3db`, `unity_gain_frequency`, `phase_margin`. All accept a `start`/`stop` window.
**Analyses** are given as a dict or as a SPICE card:
```json
{"type": "op"}
{"type": "dc", "source": "V1", "start": 0, "stop": 5, "step": 0.1}
{"type": "ac", "sweep": "dec", "points": 20, "fstart": 10, "fstop": "1meg"}
{"type": "tran", "stop": "5m", "step": "1u"}
".tran 1u 5m"
".tf v(out) V1" (small-signal gain, input and output resistance)
".noise v(out) V1 dec 10 10 100k" (integrated output and input-referred noise)
```
Before running, `simulate` also checks the analysis itself: a DC sweep of a source that does not exist, or an AC analysis with no `AC` source, is reported instead of returning meaningless zeros.
## Templates
| Name | Circuit | Default analysis |
| --- | --- | --- |
| `voltage_divider` | Two-resistor divider | op |
| `rc_lowpass`, `rc_highpass` | First-order RC filters | ac |
| `rlc_series` | Series RLC band-pass | ac |
| `rc_step_response` | Capacitor charging | tran |
| `inverting_amplifier`, `non_inverting_amplifier` | Op-amp stages (single-pole macromodel, 1 MHz GBW) | ac |
| `half_wave_rectifier`, `full_wave_bridge_rectifier` | Diode rectifiers with smoothing capacitor | tran |
| `zener_regulator` | Zener shunt regulator | dc sweep |
| `led_driver` | LED with current-limiting resistor | op |
| `common_emitter` | Voltage-divider-biased NPN amplifier | ac |
| `rc_astable_comparator` | Op-amp relaxation oscillator | tran |
The tests simulate every template, and the key ones are checked against theory: cut-off frequency and phase, resonance, RC time constant, amplifier gain and oscillation frequency.
## Working with Multisim
**SPICE → Multisim.** `to_multisim` returns two things:
1. `arbitrary_spice_block`: paste it into an **Arbitrary SPICE Block** component (Place › Component, group *Basic*, family *BASIC_VIRTUAL*, or search for it). Multisim simulates the netlist with its own engine; pick the analysis under Simulate › Analyses and simulation.
2. `cir_file`: a complete SPICE file to keep next to the design or open in any other SPICE tool.
**Multisim → SPICE.** Give `from_multisim` a netlist exported from Multisim, or one written with Multisim-style values. It lists every change it made:
```
R1: value '1MΩ' -> '1meg' (SPICE would have read 1M as 1 mΩ)
C1: value '10µF' -> '10u'
V1: ground node 'GND' -> 0
```
**Driving Multisim itself (Windows, experimental).** With Multisim and `pywin32` installed, the `multisim_*` tools use NI's Automation API (`MultisimInterface.MultisimApp`) to open a design, list components, read and change R/L/C values, save, and export the netlist, which can be simulated with ngspice in the same call. NI's API covers simulation only and does not publish Python signatures, so these tools follow NI's member list and community examples. They are tested against a mock, not a real Multisim install. Reports from Multisim users are very welcome.
## SPICE gotchas the server handles for you
- **`M` is milli, `MEG` is mega.** `1M` in SPICE is 0.001. `convert_value` and `from_multisim` make this explicit.
- **The first line is always the title.** A netlist that starts with `R1 in out 1k` silently loses R1; `validate_netlist` warns about it.
- **Every node needs a DC path to ground.** A node joined only through capacitors makes the operating point fail; the validator names the node and suggests a 100 MΩ resistor.
- **Simulator failures come with hints.** "singular matrix", "timestep too small" and missing models are explained in plain language, along with the tail of the ngspice log.
## Configuration
| Variable | Default | Meaning |
| --- | --- | --- |
| `NGSPICE_PATH` | auto | Path to the ngspice executable (`ngspice_con.exe` on Windows). |
| `MULTISIM_SPICE_TIMEOUT` | `60` | Seconds before a simulation is stopped. |
| `MULTISIM_SPICE_COM` | unset | Set to `1` to register the Multisim tools outside Windows (testing only). |
`.include` and `.lib` lines are passed to ngspice; relative paths are resolved against the `workdir` argument of `simulate`. Only include files you trust.
## Development
```sh
git clone https://github.com/Sharkeeeeeee/multisim-spice-mcp
cd multisim-spice-mcp
pip install -e ".[dev]"
pytest # tests that need ngspice are skipped when it is missing
ruff check src tests
```
CI runs the tests on Linux, macOS and Windows with Python 3.10 and 3.13, against both `mcp` 1.x and 2.x, including an end-to-end session over stdio.
## License
[MIT](LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues