Listen to today's AI briefing

Daily podcast — 5 min, AI-narrated summary of top stories

How to Bridge Simulation and Reality with Claude Code and MCP Servers
AI ResearchScore: 84

How to Bridge Simulation and Reality with Claude Code and MCP Servers

A developer built MCP servers for SPICE and oscilloscopes, enabling Claude Code to analyze discrepancies between simulated and real-world circuit behavior.

GAla Smith & AI Research Desk·1d ago·4 min read·5 views·AI-Generated
Share:
Source: lucasgerads.comvia hn_claude_code, devto_claudecode, gn_mcp_protocolMulti-Source

The Technique — Closing the Hardware Debugging Loop

6 Best MCP Servers for Developers

A developer has built a powerful workflow that solves a classic engineering problem: the gap between a perfect circuit simulation and a flawed physical build. The setup uses Claude Code as an intelligent comparator between two data sources.

First, a SPICE simulator (like LTspice or ngspice) runs a circuit simulation and exports the expected voltage/current waveforms. Second, a digital oscilloscope (connected via USB/GPIB) captures the actual signal from the physical circuit on your bench. Both datasets are fed to Claude Code via custom Model Context Protocol (MCP) servers.

Claude doesn't just look at the data—it performs a structured discrepancy analysis. It identifies where the real signal diverges from the simulation, hypothesizes potential causes (e.g., incorrect component values, parasitic capacitance, faulty connections), and suggests the next debugging step.

Why It Works — Structured Data Over Guessing

This works because Claude Code is operating on clean, structured data from two authoritative sources, not guessing from a vague description. You're not asking, "Why isn't my circuit working?" You're asking, "Here is the expected waveform from the model and the actual waveform from the scope. They differ at time t with characteristic x. What are the most likely physical causes?"

This transforms Claude from a conversational assistant into a reasoning engine for a well-defined problem. The MCP servers handle the tool-specific complexity (communicating with the oscilloscope, parsing SPICE output), leaving Claude to do what it's best at: pattern recognition, hypothesis generation, and planning.

How To Apply It — Building Your Own Verification Pipeline

How to Supercharge Your Development with Claude Code MCP Servers | by ...

You don't need the exact MCP servers from the project to adopt this pattern. The core concept is creating a script that gathers data and prompts Claude effectively.

Start with a Python script that automates data collection. Use subprocess to run ngspice and pyvisa to query your oscilloscope. Crucially, pre-process the data before sending it to Claude. Send statistical summaries (min, max, rise time, frequency) and maybe a few hundred sample points—not millions of raw data points.

Your prompt to Claude should be structured like this:

I am debugging a circuit. I have two datasets:

1. SIMULATION (from SPICE): Expected behavior of a [describe circuit, e.g., 1kHz low-pass filter].
2. MEASUREMENT (from Oscilloscope): Actual behavior from the physical prototype.

Here are the key data summaries:
- Simulation Vpp: 3.3V, Frequency: 1.00kHz, Rise Time (10-90%): 35us
- Measurement Vpp: 2.8V, Frequency: 0.98kHz, Rise Time: 120us

The measured signal is attenuated and slower than simulated.

Circuit Context: The circuit uses a 1kΩ resistor and a 100nF ceramic capacitor (theoretical fc=1.59kHz). The op-amp is an LM358 powered by a single 5V supply.

Task: Analyze the discrepancy. Provide a ranked list of the most likely physical causes (e.g., component tolerance, loading effect, supply issue) and recommend the next specific measurement or component change to test.

This prompt gives Claude the necessary context to move from "data differ" to "actionable debug step."

The MCP Advantage

If you want to integrate this deeply into your Claude Code workflow, building MCP servers is the next step. The MCP server for the oscilloscope would handle all the PyVISA commands, presenting a simple interface like capture_waveform(channel=1) to Claude. The SPICE server would manage netlist files and simulation runs.

This means you can eventually ask Claude in natural language: "Run the simulation for filter.net, capture the output from channel 1 on the scope, and tell me if the cutoff frequency is within 10%." The MCP servers turn complex instrument control into simple tools Claude can use.

Following this story?

Get a weekly digest with AI predictions, trends, and analysis — free.

AI Analysis

This project demonstrates a shift from using Claude Code for purely software tasks to acting as a bridge for hardware-in-the-loop verification. The actionable takeaway is to structure your prompts around data comparison. **Change your prompt strategy:** Instead of asking open-ended hardware questions, build a script that captures quantitative data (simulation vs. measurement) and ask Claude to analyze the *delta*. Provide specific circuit context (component values, topology, IC part numbers) to ground its reasoning in practical electronics. **Consider the MCP pattern for lab equipment:** If you regularly use instruments (scopes, logic analyzers, power supplies), building a simple MCP server is a force multiplier. It turns Claude into a lab assistant that can fetch measurements, allowing you to focus on analysis. Start by wrapping PyVISA commands in a simple FastMCP server—it's often less than 100 lines of code.
Enjoyed this article?
Share:

Related Articles

More in AI Research

View all