ltspice-mcp

ltspice-mcp

An MCP server that enables LLMs to read and modify LTspice schematics, run simulations, parse results, and generate plots, all through natural language.

Category
访问服务器

README

ltspice-mcp

I wanted to learn about MCP, slash commands and claude.md files. Are DSLs a thing of the past? I created the following with Claude:

An MCP (Model Context Protocol) server that gives an LLM direct, tool-based access to LTspice circuit simulations — read schematics, set component values, run simulations, parse results, and generate plots, all from a Claude conversation.


What it does

  1. Read & modify schematics — parse .asc files, inspect components and parameters, patch values
  2. Run simulations — invoke LTspice headlessly via Wine (-b batch mode), get back log and output files
  3. Analyze results — parse .raw / .op.raw binary output: waveforms, node voltages, device currents
  4. Generate plots — auto-generated matplotlib scripts saved next to the schematic as a reproducible record

MCP Tools

Tool Description
list_schematics Discover .asc files and associated outputs in a directory
read_schematic Parse components, params, includes, directives from .asc
read_parameters Read .param values from a .inc or .asc file
write_parameters Write/overwrite .param values in a .inc file
run_simulation Run LTspice via Wine (-b batch), return log + output file list
read_waveforms Parse transient/AC .raw output — returns waveforms
read_op_point Parse DC operating point .op.raw — returns node voltages/currents
modify_component Patch SYMATTR Value of a named component directly in .asc
write_schematic Generate a new .asc schematic from a component/netlist description

/analyze-circuit slash command

The flagship workflow. Run it from Claude Code on any .asc schematic:

/analyze-circuit examples/rc_filter/mystery_circuit.asc
/analyze-circuit /absolute/path/to/my_filter.asc
/analyze-circuit          ← lists available schematics and prompts

It will:

  1. Run the simulation via run_simulation
  2. Read the DC operating point — transistor bias, operating region
  3. Discover all waveforms (names, ranges, simulation type)
  4. Detect high-frequency signals and switch to full-resolution rendering automatically
  5. Write and execute a <stem>_analysis.py plot script next to the schematic
  6. Display the plot inline and provide a written circuit explanation

Example Analysis Output: AM Modulator (mystery_circuit.asc)

A collector-modulated AM transmitter built around a single 2N3904 NPN BJT.

; Sources
V1  30 V DC                        ; supply
V2  SINE(0 30m 600k)               ; RF carrier — 30 mV, 600 kHz
V3  SINE(0 3.5 1k)                 ; audio modulating signal — 3.5 V, 1 kHz

; Bias network
R1  56k    ; base voltage divider (top)
R2  15k    ; base voltage divider (bottom)
R3  10k    ; collector load
R4  4.7k   ; emitter resistor — V3 (audio) connects at its bottom terminal

; Signal coupling
C1  100n   ; AC-couples carrier (V2) into base
C2  100n   ; emitter bypass (shorts R4 at RF frequencies)
C3  470p   ; output coupling cap — collector → V(n002) load output

Q1  2N3904 ; common-emitter RF amplifier
R5  1k     ; output load

How it works: V3 (audio, 3.5 V) sits in series with R4 between the emitter and ground. As the audio signal swings, it shifts the effective emitter voltage at 1 kHz, varying Vbe and hence gm. Since the RF carrier is simultaneously being amplified at the base, its gain varies at the audio rate — producing AM modulation. C3 AC-couples the collector output to the load.

DC bias (Q1 in active region):

Parameter Value
Vcc 30.0 V
Vc (collector) 18.0 V
Vbe 0.66 V
Vce 12.4 V
Ic 1.20 mA
β 334

/analyze-circuit output:

mystery_circuit analysis

The top panel uses LTspice-style min/max-per-pixel rendering to produce the AM "football" shape at full 2 ms resolution — the green filled band is the 600 kHz carrier, its amplitude envelope tracing the 1 kHz audio signal (red dashed). The bottom panel zooms to 10–30 µs to show individual carrier cycles.


Setup

# Install in editable mode
pip install -e .

# LTspice runs via Wine — set path if different from default:
export LTSPICE_EXE="/home/user/.wine/drive_c/Program Files/LTC/LTspiceXVII/XVIIx64.exe"

MCP config (~/.config/claude/claude_desktop_config.json)

{
  "mcpServers": {
    "ltspice": {
      "command": "ltspice-mcp"
    }
  }
}

Or without installing the package:

{
  "mcpServers": {
    "ltspice": {
      "command": "python",
      "args": ["-m", "ltspice_mcp.server"],
      "cwd": "/path/to/ltspice-mcp/src"
    }
  }
}

Workflow example: RC filter optimization

list_schematics(directory="examples/rc_filter/")
read_schematic(path="rc_filter.asc")           # inspect components
read_parameters(path="params.inc")             # current R=1k, C=100n → fc≈1.6kHz
write_parameters(path="params.inc", parameters={"R": 2200, "C": 47e-9})
run_simulation(schematic_path="rc_filter.asc")
read_waveforms(raw_path="rc_filter.raw", signals=["V(out)"])
# adjust values, repeat

Project structure

src/ltspice_mcp/
  server.py           — MCP server, all tool definitions
  raw_parser.py       — .raw file parser (binary UTF-16-LE and ASCII)
  runner.py           — Wine subprocess runner (two-step: netlist → sim)
  schematic_writer.py — .asc generator (auto-layout + wire routing)
examples/
  rc_filter/
    rc_filter.asc                   — RC low-pass filter demo
    mystery_circuit.asc             — AM modulator (this example)
    mystery_circuit_analysis.py     — auto-generated plot script
    mystery_circuit_analysis.png    — analysis output
.claude/commands/
  analyze-circuit.md  — /analyze-circuit slash command definition

Requirements

  • Python 3.10+
  • Wine with LTspice XVII installed
  • matplotlib, numpy (for generated plot scripts)
  • MCP-compatible client (Claude Desktop or Claude Code)

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选