Metadata-Version: 2.5
Name: rigol-mcp
Version: 0.1.0
Summary: MCP server for controlling Rigol oscilloscopes over USB or Ethernet
Project-URL: Documentation, https://github.com/erebusnz/rigol-mcp#readme
Project-URL: Source, https://github.com/erebusnz/rigol-mcp
Project-URL: Issues, https://github.com/erebusnz/rigol-mcp/issues
Project-URL: Releases, https://github.com/erebusnz/rigol-mcp/releases
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: anyio>=4.5
Requires-Dist: libusb-package>=1.0.26.0; python_version < '3.14'
Requires-Dist: mcp[cli]<2,>=1.30
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: pyusb>=1.2.0
Requires-Dist: pyvisa-py>=0.7.0
Requires-Dist: pyvisa>=1.14.0
Provides-Extra: test
Requires-Dist: pytest-asyncio>=0.23; extra == 'test'
Requires-Dist: pytest>=8.0; extra == 'test'
Requires-Dist: trustme>=1.2; extra == 'test'
Description-Content-Type: text/markdown

# rigol-mcp

Control a Rigol oscilloscope from Claude, Codex, Cursor, or another Model Context Protocol (MCP) client. You can configure the scope, take measurements, inspect the displayed waveform, and save a triggered acquisition for offline analysis.

## Choose how to connect

Your MCP client connects to the `rigol-mcp` server, and the server connects to the oscilloscope. Choose each connection independently. For example, a laptop can reach a bench computer over HTTPS while that computer reads the scope over USB.

### Client to server

You can use a single PC connected directly to your scope, or where you wish to have multiple clients, use a remote shared server (e.g. Raspberry Pi with 1GB RAM) to manage requests.

| Setup | How it works | Instructions |
|---|---|---|
| Local server (stdio) | Your MCP client launches `rigol-mcp` on the same computer that's connected to the scope. | [Install the server](https://github.com/erebusnz/rigol-mcp#installation) · [Configure your local client](https://github.com/erebusnz/rigol-mcp#mcp-client-setup) |
| Remote shared server (Streamable HTTP) | One server stays running for one or more clients. To use an existing server, configure your client with the server's HTTP or HTTPS `/mcp` URL and any required token. | [Connect to an existing server](https://github.com/erebusnz/rigol-mcp/blob/main/docs/remote-operation.md#configure-mcp-clients) · [Host a shared server](https://github.com/erebusnz/rigol-mcp/blob/main/docs/remote-operation.md) |

### Server to scope

If you host `rigol-mcp`, configure the instrument connection on the server computer.

| Connection | On the scope | In the server's settings file | Instructions |
|---|---|---|---|
| Ethernet (LAN) | Connect Ethernet and find the scope's IP in its LAN settings. | Set `RIGOL_USB=0` and `RIGOL_IP` to the scope's IP address. | [LAN setup](https://github.com/erebusnz/rigol-mcp/blob/main/docs/lan-connection.md) |
| USB | Connect the scope's USB **Device** port to the server computer. | Set `RIGOL_USB=1`. A single Rigol scope is discovered automatically. | [USB drivers and scope selection](https://github.com/erebusnz/rigol-mcp/blob/main/docs/usb-connection.md) |

## Installation

Install [uv](https://docs.astral.sh/uv/getting-started/installation/) on the computer that will run `rigol-mcp`. The server requires Python 3.11 or later. The examples select Python 3.13 to use the project's bundled USB backend.

### Run a published release

Save your USB or LAN settings in a file such as `rigol.env` on the server computer. For one USB scope, the file needs just `RIGOL_USB=1`. Use the file's absolute path when launching the pinned package with `uvx`.

```sh
uvx --python 3.13 --env-file "/absolute/path/to/rigol.env" rigol-mcp@0.1.0 --transport stdio
```

For a local MCP client, put this command in the client configuration below so the client starts the server itself. If you supply the connection settings in the process environment, you can omit `--env-file` and its path.

### Run from a checkout

```sh
git clone https://github.com/erebusnz/rigol-mcp.git
cd rigol-mcp
uv sync --locked
```

Create a `.env` file beside `pyproject.toml` with the settings for your [scope connection](https://github.com/erebusnz/rigol-mcp#server-to-scope). You can also copy [.env.example](https://github.com/erebusnz/rigol-mcp/blob/main/.env.example), which starts with USB selected. Variables already set in the server process take precedence over the file.

Before starting the server, check the instrument connection from the checkout. The [connection example](https://github.com/erebusnz/rigol-mcp/blob/main/examples/check_connection.py) prints the instrument's manufacturer, model, serial number, and firmware, then releases the connection.

```sh
uv run python examples/check_connection.py
```

## MCP client setup

The examples below launch a local server over stdio. For a running HTTP or HTTPS server, use the [client configurations for connecting by URL](https://github.com/erebusnz/rigol-mcp/blob/main/docs/remote-operation.md#configure-mcp-clients).

Replace `/absolute/path/to/rigol.env` with your settings file. On Windows, forward slashes work in paths such as `C:/config/rigol.env`. If a desktop client cannot find `uvx`, use its absolute executable path. To launch from a checkout, use `uv` as the command and `["--directory", "/absolute/path/to/rigol-mcp", "run", "rigol-mcp", "--transport", "stdio"]` as its arguments.

### Claude Desktop and Cursor

Both clients accept the following JSON. Merge the `rigol` entry into `mcpServers` if you already have other servers configured.

| Client | Configuration file |
|---|---|
| Claude Desktop | On macOS, `~/Library/Application Support/Claude/claude_desktop_config.json`. On Windows, `%APPDATA%\Claude\claude_desktop_config.json`. [Claude Desktop setup](https://py.sdk.modelcontextprotocol.io/get-started/real-host/) |
| Cursor | `.cursor/mcp.json` in the project, or `~/.cursor/mcp.json` for all projects. [Cursor MCP guide](https://cursor.com/guides/coding-agent-mcp) |

```json
{
  "mcpServers": {
    "rigol": {
      "command": "uvx",
      "args": ["--python", "3.13", "--env-file", "/absolute/path/to/rigol.env", "rigol-mcp@0.1.0", "--transport", "stdio"]
    }
  }
}
```

Restart Claude Desktop after saving. In Cursor, open MCP settings and check that `rigol` is enabled.

### Claude Code

Run this in the project where you want to use the scope, then check the server with `/mcp`. [Claude Code MCP guide](https://code.claude.com/docs/en/mcp)

```sh
claude mcp add --transport stdio rigol -- uvx --python 3.13 --env-file "/absolute/path/to/rigol.env" rigol-mcp@0.1.0 --transport stdio
```

### Codex

Add this table to `~/.codex/config.toml`. You can check the entry with `codex mcp list`. [Codex MCP guide](https://developers.openai.com/codex/mcp/)

```toml
[mcp_servers.rigol]
command = "uvx"
args = ["--python", "3.13", "--env-file", "/absolute/path/to/rigol.env", "rigol-mcp@0.1.0", "--transport", "stdio"]
```

From your client, ask **“Use `idn` to identify the scope, then show me which channels are enabled.”**

## Tools

| Task | Tools | What you can do |
|---|---|---|
| Inspect the instrument | `idn`, `get_scope_state`, `get_acquisition_info` | Identify the scope, read channel and trigger settings, and check acquisition status and available transfer modes. |
| Control acquisition | `run`, `stop`, `single`, `autoscale`, `wait_for_trigger` | Run continuously, freeze the record, arm a single capture, autoscale, or wait for a running scope to report a trigger. |
| Set channels and timebase | `set_channel`, `set_timebase` | Set channel scale, offset, coupling and probe ratio, or change the time per division and horizontal offset. |
| Configure triggering and acquisition | `set_trigger`, `set_trigger_options`, `set_acquisition` | Configure the edge trigger, sweep, holdoff and coupling. Choose the acquisition type, average count and memory depth. [Capture settings](https://github.com/erebusnz/rigol-mcp/blob/main/docs/acquisition-export.md#capture-settings) |
| Take measurements | `measure`, `measure_between` | Read voltage, frequency, rise time, and other single-channel measurements, or measure delay and phase between channels. |
| Displayed waveform (**Screen**) | `get_waveform` | Get a text analysis of one channel. Set `return_points=true` for its `times_s` and `voltages_v` arrays. Older clients can use the `raw_data` alias. |
| Acquisition record (**Memory**) | `export_acquisition` | Save the full stopped record for enabled channels as binary files and a JSON manifest on the server. [Acquisition export and Python example](https://github.com/erebusnz/rigol-mcp/blob/main/docs/acquisition-export.md) |
| Use cursors | `set_cursors`, `get_cursor_values` | Position cursors in seconds and read their time and amplitude differences. |
| Capture the display | `screenshot` | Return a PNG image and save it under `RIGOL_SCREENSHOT_DIR` (default `screenshots/`). |
| Manage the connection | `check_error`, `disconnect` | Read the SCPI error queue or release the server's VISA connection. A later tool call can reconnect. |
| Send a SCPI command | `send_raw` | Enable this optional tool with `RIGOL_ENABLE_SEND_RAW=1` in the server environment. |

## Supported hardware

Support is selected by exact model name and covers analog channels.

| Rigol series | Analog channels | Supported operations |
|---|---|---|
| DS1000Z / MSO1000Z | 4 | Control, measurements, screenshots, displayed waveforms, acquisition information, and full memory export |
| DHO800 / DHO900 / DHO1000 / DHO1000U / DHO4000 | 2 or 4 | Control, measurements, screenshots, displayed waveforms, acquisition information, and full memory export |
| MHO900 / MHO98 | 4 | Control, measurements, screenshots, displayed waveforms, and acquisition information |
| DS2000A / MSO2000A, MHO2000, DHO5000 / MHO5000, MSO/DS9000 | 2, 4, 6, or 8 | Model and channel information only ([pending hardware testing](https://github.com/erebusnz/rigol-mcp/blob/main/docs/hardware-testing.md)) |

Find your exact model in the [hardware catalog](https://github.com/erebusnz/rigol-mcp/blob/main/docs/hardware-support.md#model-catalog). If you have access to a Rigol scope, we welcome [pull requests with hardware test results](https://github.com/erebusnz/rigol-mcp/blob/main/docs/hardware-testing.md#contribute-a-test).

## Example prompts

> Measure the frequency and peak-to-peak voltage on channel 1. Adjust the timebase until two complete cycles are visible, then describe the waveform.

> Channel 1 is the input to an amplifier and channel 2 is the output. Measure the gain in dB.

> The rising edge on channel 1 rings. Place the cursors on two adjacent peaks and measure the ringing period.

![Oscilloscope trace with cursors on adjacent peaks of a damped oscillation](https://raw.githubusercontent.com/erebusnz/rigol-mcp/main/media/example.png)

## Testing

Run the offline suite from the checkout. It uses simulated VISA instruments.

```sh
uv run --locked --extra test pytest
```

Maintainers can find the publishing steps in the [release guide](https://github.com/erebusnz/rigol-mcp/blob/main/docs/releasing.md).

## License

[MIT](https://github.com/erebusnz/rigol-mcp/blob/main/LICENSE)
