{"id":180,"date":"2026-04-18T10:32:12","date_gmt":"2026-04-18T10:32:12","guid":{"rendered":"https:\/\/balamurali.in\/blog\/uncategorized\/claude-code-mcp-spice-hardware-verification\/"},"modified":"2026-04-18T10:40:57","modified_gmt":"2026-04-18T10:40:57","slug":"claude-code-mcp-spice-hardware-verification","status":"publish","type":"post","link":"https:\/\/balamurali.in\/blog\/uncategorized\/claude-code-mcp-spice-hardware-verification\/","title":{"rendered":"Closing the Hardware Loop: Claude Code, SPICE, and Oscilloscopes"},"content":{"rendered":"<p>Hardware engineering has long suffered from a lack of the &#8220;instant feedback&#8221; loop that software developers take for granted. While a software engineer can run a unit test in milliseconds, a hardware engineer often waits for simulations to finish or, worse, for PCBs to arrive from the fab, only to realize a component value was off by an order of magnitude.<\/p>\n<p>This week, the gap between LLM-driven design and physical reality narrowed significantly. By leveraging Anthropic&#8217;s Model Context Protocol (MCP), developers are now bridging Claude Code directly to SPICE simulators and physical test equipment, creating a &#8220;compiler for hardware&#8221; that catches hallucinations before they reach the breadboard.<\/p>\n<h2>What happened<\/h2>\n<p>Developer Lucas Gerads recently demonstrated a viral workflow that uses <a href=\"https:\/\/lucasgerads.com\/blog\/lecroy-mcp-spice-demo\/\" target=\"_blank\" rel=\"noopener\">Claude Code<\/a> to automate the entire hardware verification cycle. By connecting Claude to a LeCroy oscilloscope and a SPICE simulator via MCP, Gerads showed how an AI agent can autonomously design a circuit, simulate it, flash code to a microcontroller, and then verify the physical output against the simulated model.<\/p>\n<p>According to <a href=\"https:\/\/lucasgerads.com\/blog\/lecroy-mcp-spice-demo\/\" target=\"_blank\" rel=\"noopener\">Gerads<\/a>, the primary motivation was the difficulty of expressing complex designs in plain English. &#8220;I realized that Claude Code really shines when it can get immediate feedback,&#8221; he noted. The demonstration involved a simple RC filter and an MCU, but the implications for complex embedded projects are profound. The workflow effectively treats the oscilloscope and the simulator as external &#8220;verifiers&#8221; that prevent the model from falling into &#8220;optimistic hallucinations.&#8221;<\/p>\n<h2>Under the hood<\/h2>\n<p>The technical backbone of this integration is the <a href=\"https:\/\/www.anthropic.com\/news\/model-context-protocol\" target=\"_blank\" rel=\"noopener\">Model Context Protocol (MCP)<\/a>, an open-source standard that functions like a &#8220;USB-C port&#8221; for AI models. MCP allows a host (like Claude Desktop or Claude Code) to communicate with local or remote servers that expose specific tools and resources.<\/p>\n<h3>The Simulation Layer: spicelib<\/h3>\n<p>To handle the simulation, the workflow utilizes <a href=\"https:\/\/github.com\/nunobrum\/spicelib\" target=\"_blank\" rel=\"noopener\">spicelib<\/a>, a Python library designed to bridge the gap between Python&#8217;s data science stack and SPICE engines like LTspice, QSpice, and NGSpice.<\/p>\n<p><code>spicelib<\/code> is not a simulator itself; it is a controller. Its core capabilities include:<\/p>\n<ul>\n<li><strong>Netlist Manipulation:<\/strong> Programmatically opening <code>.asc<\/code> or netlist files and modifying component values (e.g., changing a resistor from 1k to 10k).<\/li>\n<li><strong>Execution Management:<\/strong> Managing the simulator executable (e.g., <code>XVIIx64.exe<\/code> for LTspice) and handling parallel batch runs.<\/li>\n<li><strong>Binary Parsing:<\/strong> Using the <code>RawRead<\/code> tool to parse <code>.raw<\/code> binary output files directly into NumPy arrays for analysis.<\/li>\n<\/ul>\n<h3>The Hardware Layer: MCP Servers<\/h3>\n<p>The connection is facilitated by three specific MCP servers:<\/p>\n<ol>\n<li><strong>lecroy-mcp:<\/strong> An MCP server that wraps the LeCroy oscilloscope&#8217;s remote control API (typically via VISA\/VXI-11).<\/li>\n<li><strong>spicelib-mcp:<\/strong> A server that exposes <code>spicelib<\/code> functions as tools for Claude.<\/li>\n<li><strong>rc-filter-demo-files:<\/strong> A repository containing the specific demo configurations.<\/li>\n<\/ol>\n<p>Communication between the Claude client and these servers happens via <strong>JSON-RPC 2.0<\/strong> over standard input\/output (stdio) for local processes. This allows Claude to call a tool like <code>run_simulation<\/code> or <code>get_oscilloscope_waveform<\/code> and receive structured data back in its context window.<\/p>\n<h2>How to try it yourself<\/h2>\n<p>To replicate this setup, you will need a Windows or Linux machine (macOS requires WINE for LTspice) and a supported SPICE simulator.<\/p>\n<h3>Prerequisites<\/h3>\n<ul>\n<li>Python 3.10 or higher.<\/li>\n<li><a href=\"https:\/\/www.analog.com\/en\/design-center\/design-tools-and-calculators\/ltspice-simulator.html\" target=\"_blank\" rel=\"noopener\">LTspice<\/a> installed (ensure the executable is in your system PATH).<\/li>\n<li>An Anthropic API key for Claude Code.<\/li>\n<\/ul>\n<h3>1. Install spicelib<\/h3>\n<p>First, install the core library that handles the simulation automation:<\/p>\n<pre><code class=\"language-bash\">\npip install spicelib\n<\/code><\/pre>\n<h3>2. Minimal Working Example<\/h3>\n<p>You can test the Python-to-SPICE bridge with this simple script. This assumes you have a file named <code>filter.asc<\/code> in your directory.<\/p>\n<pre><code class=\"language-python\">\nfrom spicelib import SimRunner\nfrom spicelib.raw_read import RawRead\n\n# Initialize the runner for LTspice\nrunner = SimRunner(output_folder='.\/sim_results', simulator='LTspice')\n\n# Run a simulation\n# Note: In a real MCP setup, Claude would trigger this via a tool call\nrunner.run_simulation('filter.asc')\n\n# Parse the results\nraw_data = RawRead('.\/sim_results\/filter.raw')\nprint(f\"Available traces: {raw_data.get_trace_names()}\")\n<\/code><\/pre>\n<h3>3. Setting up the MCP Server<\/h3>\n<p>To give Claude access, you must configure your <code>claude_desktop_config.json<\/code> (or the equivalent for Claude Code). Per the <a href=\"https:\/\/www.anthropic.com\/news\/model-context-protocol\" target=\"_blank\" rel=\"noopener\">MCP specification<\/a>, your config should look like this:<\/p>\n<pre><code class=\"language-json\">\n{\n  \"mcpServers\": {\n    \"spice-sim\": {\n      \"command\": \"python\",\n      \"args\": [\"-m\", \"spicelib_mcp_server\"]\n    },\n    \"oscilloscope\": {\n      \"command\": \"python\",\n      \"args\": [\"-m\", \"lecroy_mcp_server\", \"--ip\", \"192.168.1.100\"]\n    }\n  }\n}\n<\/code><\/pre>\n<h3>Quick Test<\/h3>\n<p>Once configured, open Claude Code and run: <code>\"Can you run a SPICE simulation of the RC filter in this directory and tell me the -3dB cutoff frequency?\"<\/code><\/p>\n<p>Claude should invoke the <code>spice-sim<\/code> tool, parse the <code>.raw<\/code> file, and return the numerical result without you ever opening the LTspice GUI.<\/p>\n<h2>Where this fits<\/h2>\n<p>This workflow represents a shift from &#8220;AI as a copywriter&#8221; to &#8220;AI as a systems engineer.&#8221;<\/p>\n<h3>Competitive Landscape<\/h3>\n<ul>\n<li><strong>Manual GUI Simulation:<\/strong> The status quo. It is slow and prone to human error in data transcription. While tools like LTspice are powerful, they are &#8220;islands&#8221; of data.<\/li>\n<li><strong>Custom Python Scripts:<\/strong> Many engineers already use libraries like <code>PyLTSpice<\/code> or <code>spicelib<\/code> for Monte Carlo analysis. However, these require the engineer to write the analysis logic themselves.<\/li>\n<li><strong>Claude + MCP:<\/strong> Replaces the need for the engineer to write the &#8220;glue code.&#8221; Claude can look at the simulation data, identify a discrepancy, and suggest a component change autonomously.<\/li>\n<\/ul>\n<h3>Trade-offs<\/h3>\n<table>\n<thead>\n<tr>\n<th style=\"text-align:left\">Feature<\/th>\n<th style=\"text-align:left\">Manual GUI<\/th>\n<th style=\"text-align:left\">Custom Python<\/th>\n<th style=\"text-align:left\">Claude + MCP<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align:left\"><strong>Setup Effort<\/strong><\/td>\n<td style=\"text-align:left\">Low<\/td>\n<td style=\"text-align:left\">Medium<\/td>\n<td style=\"text-align:left\">High<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><strong>Verification Speed<\/strong><\/td>\n<td style=\"text-align:left\">Slow<\/td>\n<td style=\"text-align:left\">Fast<\/td>\n<td style=\"text-align:left\">Instant<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><strong>Hallucination Risk<\/strong><\/td>\n<td style=\"text-align:left\">N\/A<\/td>\n<td style=\"text-align:left\">Low<\/td>\n<td style=\"text-align:left\">High (Mitigated by Tools)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:left\"><strong>Licence<\/strong><\/td>\n<td style=\"text-align:left\">Proprietary<\/td>\n<td style=\"text-align:left\">Open Source<\/td>\n<td style=\"text-align:left\">Proprietary (Anthropic)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>What practitioners are saying<\/h2>\n<p>The reaction from the community has been a mix of awe and caution. On <a href=\"https:\/\/lucasgerads.com\/blog\/lecroy-mcp-spice-demo\/\" target=\"_blank\" rel=\"noopener\">Hacker News<\/a>, the consensus is that &#8220;closing the loop&#8221; is the only way to make LLMs viable for hardware.<\/p>\n<p>One practitioner noted the &#8220;Verifier Theory&#8221;: the idea that because LLMs lack a physical world model, they default to &#8220;optimistic narration.&#8221; As one user put it, the model &#8220;can&#8217;t talk its way past&#8221; a mismatched waveform on a physical scope. If the simulation says 1V and the scope says 0.5V, the model is forced to reconcile that reality rather than hallucinating a success.<\/p>\n<p>However, there is significant dissent regarding the &#8220;rabbit holes&#8221; of toolchain setup. Some users on <a href=\"https:\/\/www.reddit.com\/r\/ClaudeCode\/comments\/1q5kx4c\/how_good_is_claude_code_in_terms_of_web_designing\/\" target=\"_blank\" rel=\"noopener\">Reddit<\/a> warned that Claude Code can be &#8220;dangerously confident&#8221; without these constraints, sharing anecdotes where the model hallucinated entire board capabilities that didn&#8217;t exist. The consensus: MCP isn&#8217;t just a feature; it&#8217;s a safety requirement for hardware AI.<\/p>\n<h2>Takeaways<\/h2>\n<ul>\n<li><strong>LLMs require external grounding:<\/strong> Never trust an LLM&#8217;s circuit design without a simulation or hardware-in-the-loop (HIL) verification step. The &#8220;optimistic hallucination&#8221; is too high a risk in electronics.<\/li>\n<li><strong>MCP is the new standard:<\/strong> If you are building AI tools for engineers, stop writing custom integrations. Use <a href=\"https:\/\/github.com\/modelcontextprotocol\" target=\"_blank\" rel=\"noopener\">MCP<\/a> to ensure your tools can talk to any host (Claude, Cursor, etc.).<\/li>\n<li><strong>Data Management is key:<\/strong> When using MCP, do not dump raw waveform data into the LLM context. Save it to a file and let the model use tools (like <code>spicelib<\/code>&#8216;s parser) to extract specific metrics (Vpp, frequency, rise time).<\/li>\n<li><strong>The &#8220;Compiler&#8221; for Hardware is here:<\/strong> By treating SPICE as a compiler and the oscilloscope as a debugger, we can finally apply modern CI\/CD practices to physical hardware design.<\/li>\n<\/ul>\n<p>Full analysis: {BLOG_URL}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hardware design meets the LLM feedback loop. Learn how to use MCP to connect Claude Code to SPICE simulators and physical oscilloscopes.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[29,24,26,25,28,27],"class_list":["post-180","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-automation","tag-claude-code","tag-hardware-engineering","tag-mcp","tag-python","tag-spice-simulation"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/balamurali.in\/blog\/wp-json\/wp\/v2\/posts\/180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/balamurali.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/balamurali.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/balamurali.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/balamurali.in\/blog\/wp-json\/wp\/v2\/comments?post=180"}],"version-history":[{"count":1,"href":"https:\/\/balamurali.in\/blog\/wp-json\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":181,"href":"https:\/\/balamurali.in\/blog\/wp-json\/wp\/v2\/posts\/180\/revisions\/181"}],"wp:attachment":[{"href":"https:\/\/balamurali.in\/blog\/wp-json\/wp\/v2\/media?parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/balamurali.in\/blog\/wp-json\/wp\/v2\/categories?post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/balamurali.in\/blog\/wp-json\/wp\/v2\/tags?post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}