Skip to main content
Glama
README.md
# siglent-mcp

**Lets Claude use a bench oscilloscope:** set it up, trigger, capture, measure and look at the result, over the LAN. It is an MCP server for the Siglent SDS1104X-E (SDS1000X-E series), written in Python.

[![Tests](https://github.com/mndxc/siglent-mcp/actions/workflows/tests.yml/badge.svg)](https://github.com/mndxc/siglent-mcp/actions)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)

| The scope's own screen | The same acquisition, captured and plotted by siglent-mcp |
|---|---|
| ![The SDS1104X-E screen showing the 1 kHz probe-compensation square wave on channel 4](docs/images/scope-screen.png) | ![The plot tool's PNG of the same 1.4-million-sample record](docs/images/plot-example.png) |

*One acquisition of the scope's 1 kHz probe-compensation signal. Left: the screen, read with `screenshot`. Right: the full 1.4-million-sample record, saved by `capture` and drawn by `plot` with the minimum and maximum of every pixel column, so even a one-sample glitch stays visible.*

## Why

Bringing up a new circuit board means hours at the oscilloscope: set the time base, find a trigger that catches the event, read the numbers, change one thing, repeat. An AI assistant could do much of that loop, but two problems get in the way.

- **A waveform is too big to read.** One capture is 1.4 million samples. Putting that into a language model's context would fill it and tell the model nothing. Here the record never enters the context: it is saved to a file, and Claude gets back measurements, a summary and pictures.
- **The scope fails silently.** The SDS1104X-E reports no SCPI errors. It ignores a command it doesn't like, and firmware R17 sometimes misreads a command outright, with no error at all. So every setting this server writes is read back and compared, and anything that didn't take is reported.

## Where it stands

| | |
|---|---|
| **Works** | 19 tools, all tested against a real SDS1104X-E on firmware 8.3.6.1.37R8 and 8.3.6.1.37R17 (December 2026). 173 automated tests run against a simulated scope |
| **Untested** | Other SDS1000X-E models and other firmware versions. The tools may work on them; check the first results against the scope's screen, and please report what you find |
| **Next** | Board bring-up checks (`check_*` tools), added as a real board needs them |

## What it does

- **Look:** the scope's full setup, its own measurements with statistics, and its screen as an image
- **Set up:** channels, time base, memory depth and acquire mode, and six trigger types (edge, slew, glitch, interval, runt, dropout)
- **Capture and measure:** save full records, then get edges, frequency, jitter, duty cycle, rise and fall times, overshoot, glitches and delays between channels, all computed on every sample
- **Watch for rare events:** take frame after frame in the background, and keep only the ones that meet a condition (a wrong edge, a voltage out of range, a pulse too narrow or too wide, a frequency out of range)
- **Save and restore setups:** compare the scope with a saved setup, then put back only what differs, with an undo snapshot first
- **Anything else:** raw SCPI queries, and raw commands at the highest permission tier

Every tool is listed in [docs/TOOLS.md](docs/TOOLS.md).

## What Claude sees

After `capture` and `analyze` on the signal above, Claude gets numbers rather than samples (trimmed):

```json
{
  "frequency_hz": 1000.0,
  "period_jitter_rms_s": 2e-09,
  "duty_cycle_pct": 50.0003,
  "levels": { "base_v": 0.0, "top_v": 3.0, "amplitude_v": 3.0 },
  "rise_time_10_90_s": { "mean": 9.46667e-07, "min": 9.44e-07, "max": 9.5e-07, "count": 3 },
  "fall_time_90_10_s": { "mean": 9.71e-07, "min": 9.64e-07, "max": 9.78e-07, "count": 2 },
  "overshoot_pct": 1.33333,
  "edges": { "rising": 3, "falling": 2, "first_rising_s": [-0.001000002, 0.0, 0.000999998] }
}
```

The scope's own readout for the same signal was 1.00 kHz and Pk-Pk 3.06 V. Times are seconds from the trigger, and the rising edge at the trigger comes out at exactly t = 0.

## How it works

- **Waveforms stay in files.** `capture` saves every channel's raw samples and scaling as a compressed NumPy file, and returns its path and a short summary. `analyze` and `plot` work from that file.
- **Every write is checked.** After each command the server waits for the scope to finish (`*OPC?`), reads the setting back and compares it. A refused, clamped or misread value comes back as a plain warning, and a misread is retried once.
- **Permission tiers.** `read` can only observe, `config` (the default) can change settings, and `full` adds raw SCPI commands.
- **Safe by default.** It connects only to private-LAN addresses, rejects command chaining and control characters, and logs every command to an audit file.
- **One client at a time.** The scope serves a single TCP connection, so the server holds a file lock per scope. A second process gets a clear message naming the process that holds the scope, not a silent hang.
- **Results say what to doubt.** A probe setting that looks wrong, clipped samples, too few samples per period, or a stale frame each add a warning sentence to the result.

More in [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).

## Quick start

You need [uv](https://docs.astral.sh/uv/), Python 3.11 or later, and the scope on the same LAN subnet as your computer (DHCP or a fixed address in the scope's LAN settings).

```sh
git clone https://github.com/mndxc/siglent-mcp.git
claude mcp add --scope user siglent -- uv run --project /path/to/siglent-mcp siglent-mcp
```

Then ask Claude something like *"What's on the scope? Capture channel 1 and tell me the rise time."* The server finds the scope by scanning the local subnet, or you can set `SIGLENT_HOST`.

Use `--project`, not `--directory`: `--project` keeps Claude's working directory, so captures are saved in the project you are working on (`./scope-captures/`). Any other MCP client can start the server the same way, over stdio.

### Settings

All optional, as environment variables:

| Variable | Default | What it sets |
|---|---|---|
| `SIGLENT_HOST` | scan the local /24 | The scope's address |
| `SIGLENT_TIER` | `config` | `read`, `config` or `full` |
| `SIGLENT_DATA_DIR` | `./scope-captures/` | Where captures, watches and setups are saved |
| `SIGLENT_PROBE_ATTN` | `10` | The probe setting you normally use; others get a warning. `any` turns the check off |
| `SIGLENT_AUDIT_LOG` | `~/.local/state/siglent-mcp/audit.log` | The log of every command sent |
| `SIGLENT_LOCK_DIR` | `~/.local/state/siglent-mcp/locks` | The per-scope lock files |

## Documentation

| | |
|---|---|
| [docs/TOOLS.md](docs/TOOLS.md) | Every tool and its arguments, the warnings, and the capture file format |
| [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) | How the server is built, and why: modules, write checking, locking, safety, tests |
| [docs/HARDWARE_NOTES.md](docs/HARDWARE_NOTES.md) | What the SDS1104X-E really does over SCPI: errors in its programming guide, a firmware bug, timings. Useful even without this server |
| [CONTRIBUTING.md](CONTRIBUTING.md) | Running the tests, and the rules a change must keep |

## Credits

Design ideas came from other oscilloscope MCP servers; no code was copied.

- [MagnusJohansson/siglent-sds-mcp](https://github.com/MagnusJohansson/siglent-sds-mcp) (MIT): the set of tools, query-only raw SCPI, input checks on commands, the audit log, and converting the screenshot BMP to PNG
- Bruce Perens' `scope_mcp` in [hams_open](https://github.com/BrucePerens/hams_open/pull/832): permission tiers, and refusing to read a stale frame
- lfhohmann (`scope_claim`): the undo snapshot before a restore, and the per-scope lock
- masahiro (`caveats[]`): one list of warnings in every result
- a PicoScope MCP server: the aliasing warning

## License

MIT. See [LICENSE](LICENSE).