Skip to main content
Glama
lucasgerads

spicelib-mcp

by lucasgerads
README.md
# spicelib-mcp

A thin MCP server that wraps [spicelib](https://pypi.org/project/spicelib/) for circuit simulation. The heavy lifting, such as simulator invocation, `.raw` file parsing, and multi-simulator abstraction, is done by spicelib, which deserves most of the credit. This project is purely a transport layer that exposes spicelib's functionality as MCP tools for use with Claude Code (and other coding agents).

Primary use case: behavioral model fitting — run simulations, compare against real measurements, iterate on SPICE models.

## Tools

- `run_ac_analysis` — AC frequency sweep, returns magnitude/phase data
- `run_transient` — transient simulation, returns time-domain waveforms
- `run_dc_op` — DC operating point analysis
- `run_sweep` — run multiple simulations in parallel, sweeping component values

Results are saved as `.npz` files alongside the netlist for further analysis and plotting.

## Supported simulators

| Simulator | `SPICE_SIMULATOR` value | Install |
|---|---|---|
| [ngspice](https://ngspice.sourceforge.io/) | `ngspice` (default) | `sudo apt install ngspice` |
| [LTspice](https://www.analog.com/en/resources/design-tools-and-calculators/ltspice-simulator.html) | `ltspice` | Download from Analog Devices |
| [Qspice](https://www.qorvo.com/design-hub/design-tools/interactive/qspice) | `qspice` | Download from Qorvo |

Set the `SPICE_PATH` environment variable to override the simulator binary location.

## Setup

Copy `.mcp.json.template` to `.mcp.json` in your project directory and adjust `SPICE_SIMULATOR` if needed:

```json
{
  "mcpServers": {
    "spicelib": {
      "type": "stdio",
      "command": "uvx",
      "args": ["spicelib-mcp"],
      "env": {
        "SPICE_SIMULATOR": "ngspice"
      }
    }
  }
}
```

## Requirements

- Python 3.10+
- A supported simulator installed and on PATH

## License

GPL-3.0-or-later

TDQS

A4.5/5.0

Scored across 4 tools

Disambiguation5/5

Each tool targets a distinct SPICE analysis type (AC, DC op, transient) or a sweep that combines them. The descriptions clearly state when to use run_sweep instead of individual calls, eliminating ambiguity.

Naming Consistency5/5

All tools follow the consistent 'run_<analysis>' pattern with snake_case. The naming is predictable and makes the purpose immediately clear.

Tool Count5/5

With 4 tools covering the core SPICE analyses and a parallel sweep utility, the count is well-scoped for a simulation-focused server. No extraneous or redundant tools.

Completeness4/5

The core transient, AC, and DC op analyses are covered, and the sweep tool fills the gap for multi-run parameter sweeps. Missing a dedicated DC sweep tool, but the sweep tool can handle that via analysis_cmd, so the gap is minor.

Maintenance

ActivityInactive
ResponsivenessNo issues