53 Commits

Author SHA1 Message Date
822dfffcb8 feat: add OOT block path loading support 2026-01-29 18:53:32 -07:00
e9ac115728 feat: add OOT (Out-of-Tree) block path loading support
Add load_oot_blocks MCP tool to dynamically load GNU Radio OOT modules.

Since GRC's Platform.build_library() clears all blocks on every call,
the implementation combines default block paths with OOT paths before
rebuilding. This allows loading custom blocks from:
- /usr/local/share/gnuradio/grc/blocks (locally-built)
- Custom user-specified directories

Implementation:
- PlatformMiddleware.load_oot_paths(): validates paths, combines with
  defaults, rebuilds library
- PlatformProvider.load_oot_blocks(): exposes method to MCP layer
- McpPlatformProvider: registers load_oot_blocks tool

Returns useful diagnostics: added_paths, invalid_paths, and block
counts before/after reload.
2026-01-29 18:35:16 -07:00
fdcbffba1a tests: add integration tests for runtime middleware
Add comprehensive integration tests that don't require Docker:

- test_xmlrpc_subprocess.py: Tests XmlRpcMiddleware against a real
  subprocess-based XML-RPC server. Covers connection, variable
  discovery, get/set operations, and flowgraph control (18 tests).

- test_mcp_runtime.py: Tests MCP runtime tools via FastMCP Client.
  Verifies connect, disconnect, list_variables, get_variable,
  set_variable, and flowgraph control work end-to-end (15 tests).

- test_fm_scanner.py: Tests signal probe functionality and FM scanner
  parsing. Includes unit tests for helper functions and integration
  tests for flowgraph construction with signal probe blocks (18 tests).

All 59 integration tests pass. These tests provide faster feedback
than Docker-based tests while still exercising real XML-RPC
communication and flowgraph construction.
2026-01-29 05:14:29 -07:00
6c642f4a7e docker: add audio passthrough for containerized FM receiver
New files for running the FM receiver in Docker with audio output:

- Dockerfile.gnuradio-audio: GNU Radio image with ALSA→PulseAudio bridge
  - libasound2-plugins for ALSA PulseAudio plugin
  - /etc/asound.conf configures ALSA to route to PulseAudio

- docker-compose.fm-receiver.yml: Full FM receiver setup
  - PulseAudio socket mount for audio
  - USB passthrough for RTL-SDR (requires privileged mode)
  - XML-RPC port 8090 exposed for tuning control
  - Environment vars: FREQ_MHZ, GAIN

- entrypoint-fm.sh: Builds and runs flowgraph at specified frequency
- run-fm-receiver.sh: Helper script with usage instructions

Usage:
  HOST_UID=$(id -u) FREQ_MHZ=107.2 docker compose -f docker/docker-compose.fm-receiver.yml up
2026-01-29 04:12:07 -07:00
f6c9e465c5 examples: add real-time signal strength display to FM scanner
Add probe_avg_mag_sqrd_c block that taps the LPF output to measure
filtered RF power. A variable_function_probe polls it and exposes
signal_level via XML-RPC.

Display features:
- Signal strength in dB shown on tune and on 's' command
- Color-coded bar: green (strong), yellow (medium), red (weak)
- Updates after each frequency change

Signal chain now includes measurement tap:
  source → LPF → demod → audio
             ↓
        probe → var_function_probe ("signal_level")
2026-01-29 03:23:59 -07:00
b4c6efec6e examples: remove fm_receiver.grc template (now built programmatically) 2026-01-29 02:19:04 -07:00
2a5e73e9a7 examples: build FM receiver programmatically via GRC Platform API
Replace template-based prepare_flowgraph() with build_fm_receiver() that
constructs the entire flowgraph in Python code:

- Initialize Platform (same as gr-mcp main.py)
- Create variables: samp_rate, freq
- Create blocks: osmosdr_source, low_pass_filter, analog_wfm_rcv, audio_sink
- Add xmlrpc_server for runtime frequency control
- Connect signal chain: source → LPF → demod → audio
- Save and compile with grcc

This proves gr-mcp's middleware approach works end-to-end: parameters
set via set_params() serialize correctly after the lru_cache fix.

No longer needs examples/fm_receiver.grc template file.
2026-01-29 02:18:58 -07:00
27f651307e fix: remove stale lru_cache from FlowGraphMiddleware.get_block
The lru_cache on get_block() caused three cache coherence bugs:

1. Removed blocks remained accessible — set_block_params would
   modify a detached block object that no longer exists in the
   flowgraph, so save_flowgraph would serialize stale state.

2. Re-created blocks with the same auto-generated name would
   return the cached (removed) block instead of the new one.

3. Renamed blocks (via set_block_params id=...) left phantom
   cache entries under the old name.

Fix: always look up blocks from the live flowgraph. Block lookup
is a linear scan of typically <20 blocks — no cache needed.
Raises KeyError instead of StopIteration for missing blocks.
2026-01-28 21:37:04 -07:00
2405bf5535 examples: replace rtl_fm tuning with GNU Radio XML-RPC control
The --tune flag now builds an FM receiver from a GRC template,
compiles it with grcc, launches it as a subprocess, and tunes
via XML-RPC — the same mechanism gr-mcp uses for runtime
parameter changes. Includes an interactive freq> prompt for
live re-tuning without restarting the flowgraph.
2026-01-28 20:46:20 -07:00
c793208932 runtime: handle GRC servers without XML-RPC introspection
GRC's SimpleXMLRPCServer uses register_instance() which doesn't
expose system.listMethods. Wrap the connectivity check in a
try/except so a Fault is treated as "connected" while
ConnectionRefusedError still propagates.
2026-01-28 20:46:11 -07:00
b6a031acc2 examples: add live tuning to FM scanner
--tune flag scans the band then tunes to a station using rtl_fm
piped to aplay. Supports interactive station picker (--tune) or
direct frequency (--tune 102.0).
2026-01-28 20:30:49 -07:00
b2880a85ee examples: add FM band scanner using rtl_power
Scans 87.5–108.0 MHz in 200 kHz bins, detects stations above the
noise floor, and displays a ranked signal-strength table. Supports
--json export, --threshold tuning, and --gain control.
2026-01-28 20:26:40 -07:00
97248fc069 examples: first autonomous FM capture — Pitbull on 101.1 MHz
LLM-driven SDR session recorded 2026-01-28T15:05:21-07:00.
Built flowgraph via MCP tools, launched in Docker with RTL-SDR
USB passthrough, captured 128s of WBFM audio to WAV.

Song identified via songrec/Shazam: "Damn I Love Miami"
by Pitbull & Lil Jon.

Signal chain: RTL2838 → osmocom source (2.4 MS/s)
→ LPF (100 kHz, ÷5) → WBFM demod (÷10) → 48 kHz WAV

Includes GRC flowgraph, WAV recording, and helper scripts.
2026-01-28 15:07:39 -07:00
75d19eb6dd runtime: add dynamic port allocation for Docker containers
Prevent silent Docker bind failures by checking port availability
before container creation. Supports auto-allocation (port=0) and
patches compiled flowgraphs when the embedded XML-RPC port differs
from the requested port.
2026-01-28 14:28:59 -07:00
0afb2f5b6e runtime: Phase 2 ControlPort/Thrift integration
Add ControlPort/Thrift support as an alternative transport to XML-RPC:

New middleware:
- ThriftMiddleware wrapping GNURadioControlPortClient

New MCP tools:
- connect_controlport, disconnect_controlport
- get_knobs (with regex filtering), set_knobs (atomic)
- get_knob_properties (units, min/max, description)
- get_performance_counters (throughput, timing, buffers)
- post_message (PMT injection to block ports)

Docker support:
- enable_controlport param in launch_flowgraph
- ENABLE_CONTROLPORT env in entrypoint.sh
- ControlPort config generation in ~/.gnuradio/config.conf

Models: KnobModel, KnobPropertiesModel, PerfCounterModel,
ThriftConnectionInfoModel, plus ContainerModel updates.
2026-01-28 12:05:32 -07:00
4030633fde docs: add agent thread collaboration artifacts
Two async agent-to-agent design threads:

xmlrpc-runtime-integration/ (10 messages)
- Architecture handoff from gnuradio-codebase-agent
- Phase 1 Docker + XML-RPC design decisions
- epy_block vs build() vs .block.yml discussion
- Implementation review and fixes

coverage-integration/ (7 messages)
- Cross-process coverage design for containerized flowgraphs
- SIGTERM vs SIGKILL for coverage.py atexit handlers
- Smoke test results and bug fixes

These threads document the collaborative design process between
gr-mcp-agent and gnuradio-codebase-agent using the immutable
flat-file agent thread protocol.
2026-01-28 11:26:59 -07:00
1b57ea8c35 docs: update README with runtime and coverage features
- Document all 36 MCP tools (was 15)
- Add Runtime Control section (11 tools for Docker/XML-RPC)
- Add Coverage Collection section (4 tools)
- Update Python version to 3.14+
- Add Docker image build instructions
- Reorganize Features section with tool summaries
- Update usage examples for all feature areas
2026-01-28 11:25:47 -07:00
bfab802e05 coverage: add cross-process coverage collection for containerized flowgraphs
New MCP tools:
- collect_coverage(name) - combine parallel files, return summary
- generate_coverage_report(name, format) - HTML/XML/JSON reports
- combine_coverage(names) - aggregate across test runs
- delete_coverage(name?, older_than_days?) - cleanup

Modified:
- launch_flowgraph() now accepts enable_coverage parameter
- stop() uses 30s timeout for graceful shutdown (coverage needs atexit)

Docker:
- Dockerfile.gnuradio-coverage extends runtime with python3-coverage
- entrypoint-coverage.sh wraps execution with coverage run
- .coveragerc configured for GNU Radio source paths

Tests: 125 unit tests (21 new), 80% coverage
2026-01-27 13:50:17 -07:00
91a442cdf9 tests: add RuntimeProvider coverage (82% → 94%)
Unit tests (35):
- Mocked DockerMiddleware and XmlRpcMiddleware
- Full coverage of orchestration logic, preconditions, state tracking

Integration tests (6):
- Real Docker containers with gnuradio-runtime image
- End-to-end: launch → connect → control variables → stop
- Skip gracefully when Docker/image unavailable

Total: 112 tests, 94% coverage
2026-01-27 10:16:47 -07:00
2084c41228 runtime: Phase 1 Docker + XML-RPC control
Add RuntimeProvider with 17 MCP tools for controlling running flowgraphs:
- Container lifecycle: launch, list, stop, remove
- Connection: connect by URL or container name
- Variable control: list, get, set via XML-RPC introspection
- Flowgraph execution: start, stop, lock, unlock
- Visual feedback: screenshot capture, container logs

Docker is optional - 10 tools work without it for external flowgraphs.

Includes:
- DockerMiddleware wrapping docker.DockerClient
- XmlRpcMiddleware wrapping xmlrpc.client.ServerProxy
- Dockerfile with Xvfb + ImageMagick + VNC for headless QT
- 29 new unit tests (71 total)
2026-01-27 09:48:44 -07:00
2bef80a47a Add XML-RPC runtime integration design thread
Agent-to-agent discussion between gr-mcp and gnuradio-codebase agents:
- 001: gnuradio-agent proposes RuntimeProvider for XML-RPC control
- 002: gr-mcp-agent initial response with architecture ideas
- 003: gnuradio-agent provides technical details (lock/unlock, types, ControlPort)
- 004: gr-mcp-agent responds with Docker-based architecture proposal

Key design decisions:
- Docker container for GNU Radio runtime (librespace/gnuradio)
- Xvfb for headless QT GUI rendering
- Support both XML-RPC and ControlPort/Thrift transports
- OOT block generation via epy_block and full modules
2026-01-26 16:46:14 -07:00
fdc42c9bed Upgrade to FastMCP 3.0 and Python 3.14
- Bump version to 0.2.0
- Require Python 3.14+
- Update to FastMCP 3.0.0b1 with new Client API
- Update tests for FastMCP 3.0 (Pydantic models in .data)
- Pin modern dependency versions
2026-01-26 16:46:05 -07:00
Yoel bassin
1c704af06d update FastMCP instructions 2026-01-05 21:12:50 +02:00
Yoel bassin
664c2adedc add tests for FastMCP integration and update pre-commit 2026-01-05 20:52:48 +02:00
Yoel bassin
24c442d5c4 fix FastMCP version update that broke api 2026-01-05 20:43:16 +02:00
Julius
35067e9fec
Merge pull request #1 from Matvey-Kuk/add-mcp-badge
MCP Trust Score
2025-08-16 11:48:15 +03:00
Matvey-Kuk
4ac473de1c Add MCP Catalog Trust Score badge 2025-08-15 21:29:16 +01:00
Julius
7ed5e25435
main - feat: Add LICENSE 2025-05-12 23:40:42 +03:00
Yoel Bassin
3df548e684 main - fix: Change repository name to gr-mcp 2025-05-05 20:12:24 +03:00
Yoel Bassin
2dc21b5363 main - fix: Update README to add UV support 2025-04-28 09:49:49 +03:00
Yoel Bassin
80c0a1f32a main - fix: Update README and pyproject.toml 2025-04-27 22:35:21 +03:00
Yoel Bassin
2ade89408e main - fix: Update README 2025-04-27 22:20:31 +03:00
Yoel Bassin
425b308556 main - feat: Imlement basic MCP server 2025-04-27 22:16:58 +03:00
Yoel Bassin
f5a0629da7 main - fix: Fix using already populated GRC file and connection of hidden ports 2025-04-27 20:51:48 +03:00
Yoel Bassin
6d6e4d0fc2 main - fix: Change BlockModel key to name 2025-04-27 17:16:13 +03:00
Yoel Bassin
ac4105b210 main - feat: Create new BlockTypeModel and allow named ports 2025-04-27 16:58:50 +03:00
Yoel Bassin
42484d6c7d main - feat: Implement gnuradio element validation and errors 2025-04-27 12:33:29 +03:00
Yoel Bassin
0be8e77596 main - feat: Add mypy.ini 2025-04-27 11:07:35 +03:00
Yoel Bassin
7fd80477f1 main - fix: Update README 2025-04-27 00:32:21 +03:00
Yoel Bassin
f8174d07a1 main - feat: Implement block params update 2025-04-27 00:18:18 +03:00
Yoel Bassin
5485413efd main - feat: Implement block connection 2025-04-27 00:02:19 +03:00
Yoel Bassin
73bf514fc1 main - feat: Implement default block naming 2025-04-26 22:05:06 +03:00
Yoel Bassin
185e68f809 main - feat: Add pre-commit and fix all files 2025-04-26 21:52:32 +03:00
Yoel Bassin
37cb51f056 main - fiat: Implement BlockMiddleware and reorganize tests 2025-04-26 21:25:28 +03:00
Yoel Bassin
c5b4be6950 main - feat: Implement flowgraph block removal 2025-04-26 16:40:39 +03:00
Yoel Bassin
a4a3d124bd main - feat: Implement basic flowgraph 2025-04-26 16:35:43 +03:00
Yoel Bassin
eb0d9fd6be main - feat: Add real gnuradio data to tests 2025-04-26 16:08:09 +03:00
Yoel Bassin
377dab4ff9 main - feat: Create initial structure 2025-04-26 15:47:56 +03:00
Yoel Bassin
43ad41495a main - feat: Remove everything for clean start 2025-04-26 15:46:42 +03:00
Yoel Bassin
9f96402e02 main - feat: Make some initial MCP server work 2025-04-26 04:18:02 +03:00