- CS16 streams read into an int16 buffer; files hold raw SC16 Q11 (full scale 2048) instead of all zeros - bladeRF-cli backed tools release the USB claim while they run and restore RX/TX settings afterwards; loopback uses the plugin setting - calibrate_dc runs "calibrate lms" + "calibrate dc rxtx"; a bare "cal dc" only printed help and reported success - report the span of all SoapySDR ranges (rate was capped at 10 Msps) - parse "Firmware version" from bladeRF-cli 1.10 - startup banner goes to stderr, off the stdio JSON-RPC channel - shared RX chunk reader: settle discard, overflow and stall handling, stream always closed; captures report overflows, clipping, peak dBFS - spectrum power normalized to dBFS - unit tests, README troubleshooting, version 2026.10.25
139 lines
5.1 KiB
Markdown
139 lines
5.1 KiB
Markdown
# mcbladerf
|
|
|
|
MCP server for Nuand BladeRF SDR control via SoapySDR.
|
|
|
|
## Overview
|
|
|
|
mcbladerf provides Model Context Protocol (MCP) tools for controlling Nuand BladeRF software-defined radios. It enables AI assistants to configure RF parameters, capture IQ samples, and perform spectrum analysis through a simple tool-based interface.
|
|
|
|
## Features
|
|
|
|
- **Device Management**: Enumerate, connect, and disconnect BladeRF devices
|
|
- **RF Configuration**: Set/get frequency, sample rate, bandwidth, and gain stages
|
|
- **IQ Capture**: Stream samples to files in CF32 or CS16 format
|
|
- **Spectrum Analysis**: Capture and compute FFT power spectra
|
|
- **Advanced Operations**: FPGA loading, firmware flashing, DC calibration
|
|
|
|
## Requirements
|
|
|
|
- Python 3.14+ (must match system SoapySDR installation)
|
|
- SoapySDR with BladeRF support (system packages)
|
|
- bladeRF CLI tools (for advanced operations)
|
|
- BladeRF 1.0 or 2.0 hardware
|
|
|
|
### System Dependencies (Arch Linux)
|
|
|
|
```bash
|
|
sudo pacman -S soapysdr soapysdr-bladerf bladerf
|
|
```
|
|
|
|
## Installation
|
|
|
|
SoapySDR is a C++ library with Python bindings that must be installed system-wide. The venv needs access to system site-packages:
|
|
|
|
```bash
|
|
cd mcbladerf
|
|
|
|
# One-time setup (creates venv with system site-packages access)
|
|
make setup
|
|
|
|
# Or manually:
|
|
uv venv --system-site-packages --python 3.14
|
|
uv pip install -e .
|
|
```
|
|
|
|
## Running
|
|
|
|
```bash
|
|
# After setup, run with:
|
|
uv run mcbladerf
|
|
|
|
# Or via make:
|
|
make run
|
|
```
|
|
|
|
## Usage with Claude Code
|
|
|
|
```bash
|
|
# Add to Claude Code (with full path)
|
|
claude mcp add mcbladerf -- uv run --directory /path/to/mcbladerf mcbladerf
|
|
```
|
|
|
|
The `.mcp.json` is already configured for local use:
|
|
```bash
|
|
claude -p "show bladerf status" --mcp-config .mcp.json --allowedTools "mcp__mcbladerf__*"
|
|
```
|
|
|
|
## Available Tools
|
|
|
|
### Device Management
|
|
- `bladerf_status` - Get comprehensive device status
|
|
- `bladerf_list_devices` - Enumerate connected devices
|
|
- `bladerf_connect` - Connect to a device by serial or index
|
|
- `bladerf_disconnect` - Close the current connection
|
|
|
|
### RF Configuration
|
|
- `bladerf_get_frequency` / `bladerf_set_frequency` - Center frequency
|
|
- `bladerf_get_sample_rate` / `bladerf_set_sample_rate` - Sample rate
|
|
- `bladerf_get_bandwidth` / `bladerf_set_bandwidth` - Analog bandwidth
|
|
- `bladerf_get_gain` / `bladerf_set_gain` - Individual gain stages
|
|
- `bladerf_list_gains` - Enumerate available gain stages
|
|
- `bladerf_get_frequency_range` / `bladerf_get_sample_rate_range` - Hardware limits
|
|
|
|
### IQ Capture
|
|
- `bladerf_capture_iq` - Stream samples to file (CF32/CS16)
|
|
- `bladerf_capture_spectrum` - Capture and compute FFT, power in dBFS
|
|
- `bladerf_stream_status` - Check capture progress
|
|
- `bladerf_stop_capture` - Abort running capture
|
|
|
|
### Advanced
|
|
- `bladerf_load_fpga` - Load FPGA bitstream (RAM)
|
|
- `bladerf_flash_firmware` - Flash FX3 firmware
|
|
- `bladerf_calibrate_dc` - Run DC offset calibration
|
|
- `bladerf_get_hardware_info` - Detailed hardware info
|
|
- `bladerf_set_loopback` - Configure loopback mode
|
|
- `bladerf_probe` - Device diagnostics
|
|
|
|
## Example Session
|
|
|
|
```
|
|
> Connect to my BladeRF and show status
|
|
[Uses bladerf_connect and bladerf_status]
|
|
|
|
> Set frequency to 915 MHz with 2 MHz sample rate
|
|
[Uses bladerf_set_frequency and bladerf_set_sample_rate]
|
|
|
|
> Capture 1 second of IQ data to /tmp/capture.cf32
|
|
[Uses bladerf_capture_iq]
|
|
|
|
> Show me the spectrum around 100 MHz
|
|
[Uses bladerf_capture_spectrum]
|
|
```
|
|
|
|
## Capture Files and Readings
|
|
|
|
CF32 files are complex64 scaled to ±1.0. CS16 files are the device's raw SC16 Q11 integers, interleaved I/Q with full scale 2048, the same layout `bladeRF-cli` writes with `format=bin`. Spectrum power is dBFS, so a full-scale tone reads 0. Every capture reports `overflows` (dropped-sample events), `clipped_samples` and `peak_dbfs`, so check those before trusting the data.
|
|
|
|
Gains you leave out keep whatever the device last had, including values set by another process. The radio is often shared, so set all three RX gains explicitly.
|
|
|
|
While connected, the server holds the USB device and nothing else can open it. The bladeRF-cli backed tools (probe, calibrate, FPGA load, firmware flash, hardware info) release it for the duration and restore the RX/TX settings afterwards. Call `bladerf_disconnect` when you are done so other tools can use the radio.
|
|
|
|
## Troubleshooting
|
|
|
|
**`setupStream() -3` / `bladerf_sync_config() returned -3`.** The SoapySDR plugin was built against an older libbladeRF. libbladeRF 2025.10 inserted `BLADERF_FORMAT_SC16_Q11_PACKED` into the `bladerf_format` enum without changing the soname, so a stale `soapybladerf` requests the wrong format and bladeRF1 rejects it. Rebuild `soapybladerf` against the installed headers (the Arch PKGBUILD needs `-DCMAKE_POLICY_VERSION_MINIMUM=3.5` under CMake 4).
|
|
|
|
**`No device(s) available` (-7) with the board plugged in.** Another process has the device open. Check `pgrep -xa bladeRF-cli`; `pgrep -f` can match your own shell.
|
|
|
|
**`No module named 'SoapySDR'`.** The venv must see system site-packages. Recreate it with `make setup`.
|
|
|
|
## BladeRF 1.0 x40 Specifications
|
|
|
|
- Frequency: 237.5 MHz - 3.8 GHz
|
|
- Sample rates: 80 Ksps - 40 Msps
|
|
- RX Gain stages: lna (0/3/6 dB), rxvga1 (5-30 dB), rxvga2 (0-30 dB)
|
|
- TX Gain stages: txvga1 (-35 to -4 dB), txvga2 (0-25 dB)
|
|
|
|
## License
|
|
|
|
MIT
|