Metadata-Version: 2.4
Name: mcp-sigrok
Version: 0.1.0
Summary: MCP server exposing sigrok-cli functionality
Project-URL: Homepage, https://github.com/daedalus/mcp-sigrok
Project-URL: Repository, https://github.com/daedalus/mcp-sigrok
Project-URL: Issues, https://github.com/daedalus/mcp-sigrok/issues
Author-email: Dario Clavijo <clavijodario@gmail.com>
License: MIT
License-File: LICENSE
Requires-Python: >=3.11
Provides-Extra: all
Requires-Dist: hatch; extra == 'all'
Requires-Dist: mypy; extra == 'all'
Requires-Dist: pytest; extra == 'all'
Requires-Dist: pytest-cov; extra == 'all'
Requires-Dist: pytest-mock; extra == 'all'
Requires-Dist: ruff; extra == 'all'
Provides-Extra: dev
Requires-Dist: hatch; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Provides-Extra: lint
Requires-Dist: mypy; extra == 'lint'
Requires-Dist: ruff; extra == 'lint'
Provides-Extra: mcp
Requires-Dist: fastmcp; extra == 'mcp'
Provides-Extra: test
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-cov; extra == 'test'
Requires-Dist: pytest-mock; extra == 'test'
Description-Content-Type: text/markdown

# mcp-sigrok — MCP server for sigrok-cli

[![PyPI](https://img.shields.io/pypi/v/mcp-sigrok.svg)](https://pypi.org/project/mcp-sigrok/)
[![Python](https://img.shields.io/pypi/pyversions/mcp-sigrok.svg)](https://pypi.org/project/mcp-sigrok/)

MCP server that exposes all functionality of sigrok-cli as MCP tools. sigrok-cli is a cross-platform command-line utility for the sigrok software suite, used for hardware initialization, acquisition, protocol decoding, and saving logic analyzer sessions.

## Install

```bash
pip install mcp-sigrok
```

## Requirements

- sigrok-cli must be installed on the system

### Installing sigrok-cli

**Debian/Ubuntu:**
```bash
sudo apt install sigrok-cli
```

**macOS:**
```bash
brew install sigrok-cli
```

**From source:**
```bash
git clone git://sigrok.org/sigrok-cli
cd sigrok-cli
./autogen.sh
./configure
make
sudo make install
```

## Usage

### As MCP Server

```bash
# Run as stdio MCP server
mcp-sigrok
```

Or configure in your MCP settings:

```json
{
  "mcpServers": {
    "sigrok": {
      "command": "mcp-sigrok"
    }
  }
}
```

### Python API

```python
from mcp_sigrok import (
    check_sigrok_cli,
    get_version,
    list_drivers,
    scan_devices,
    capture_samples,
    load_input_file,
)

# Check if sigrok-cli is available
if cli_path := check_sigrok_cli():
    print(f"Found sigrok-cli at: {cli_path}")

# Get version info
info = get_version()

# List available drivers
drivers = list_drivers()

# Scan for devices
devices = scan_devices()

# Capture samples
result = capture_samples("fx2lafw", samples=1000)
```

## MCP Tools

| Tool | Description |
|------|-------------|
| `version` | Get sigrok-cli version info |
| `list_supported` | List all supported features |
| `list_hardware_drivers` | List available hardware drivers |
| `list_input_file_formats` | List supported input formats |
| `list_output_file_formats` | List supported output formats |
| `list_protocol_decoders` | List available protocol decoders |
| `scan_for_devices` | Scan for detectable devices |
| `show_device_info` | Show device info for a driver |
| `capture` | Capture samples from hardware |
| `capture_for_time` | Capture data for duration |
| `load_file` | Load and process input file |
| `show_decoder_docs` | Show protocol decoder docs |
| `set_config` | Set driver configuration |

## Examples

### Capture from logic analyzer

```python
# Capture 1000 samples from fx2lafw device
result = capture(
    driver="fx2lafw",
    samples=1000,
    channels="0-7",
    output_format="hex"
)
```

### Decode I2C protocol

```python
# Load capture file and decode I2C
result = load_file(
    input_file="capture.sr",
    protocol_decoders="i2c",
    output_file="decoded.txt"
)
```

### Scan for devices

```python
# Find available devices
devices = scan_for_devices()
for device in devices.get("devices", []):
    print(f"Found: {device}")
```

## Development

```bash
git clone https://github.com/daedalus/mcp-sigrok.git
cd mcp-sigrok
pip install -e ".[test]"

# run tests
pytest

# format
ruff format src/ tests/

# lint
ruff check src/ tests/

# type check
mypy src/
```

mcp-name: io.github.daedalus/mcp-sigrok