diff --git a/examples/fm_101_1.grc b/examples/fm_101_1.grc new file mode 100644 index 0000000..d5c4c96 --- /dev/null +++ b/examples/fm_101_1.grc @@ -0,0 +1,488 @@ +options: + parameters: + author: '' + catch_exceptions: 'True' + category: '[GRC Hier Blocks]' + cmake_opt: '' + comment: '' + copyright: '' + description: '' + gen_cmake: 'On' + gen_linking: dynamic + generate_options: qt_gui + hier_block_src_path: '.:' + id: default + max_nouts: '0' + output_language: python + placement: (0,0) + qt_qss_theme: '' + realtime_scheduling: '' + run: 'True' + run_command: '{python} -u {filename}' + run_options: prompt + sizing_mode: fixed + thread_safe_setters: '' + title: Not titled yet + window_size: (1000,1000) + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [8, 8] + rotation: 0 + state: enabled + +blocks: +- name: freq + id: variable + parameters: + comment: '' + value: 101.1e6 + states: + bus_sink: false + bus_source: false + bus_structure: null + state: enabled +- name: samp_rate + id: variable + parameters: + comment: '' + value: int(2.4e6) + states: + bus_sink: false + bus_source: false + bus_structure: null + state: enabled +- name: analog_wfm_rcv_1 + id: analog_wfm_rcv + parameters: + affinity: '' + alias: '' + audio_decimation: '10' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + quad_rate: 480e3 + states: + bus_sink: false + bus_source: false + bus_structure: null + state: enabled +- name: blocks_wavfile_sink_0 + id: blocks_wavfile_sink + parameters: + affinity: '' + alias: '' + append: 'False' + bits_per_sample1: FORMAT_PCM_16 + bits_per_sample2: FORMAT_PCM_16 + bits_per_sample3: FORMAT_VORBIS + bits_per_sample4: FORMAT_PCM_16 + comment: '' + file: '' + format: FORMAT_WAV + nchan: '1' + samp_rate: samp_rate + states: + bus_sink: false + bus_source: false + bus_structure: null + state: enabled +- name: low_pass_filter_1 + id: low_pass_filter + parameters: + affinity: '' + alias: '' + beta: '6.76' + comment: '' + cutoff_freq: 100e3 + decim: '5' + gain: '1' + interp: '1' + maxoutbuf: '0' + minoutbuf: '0' + samp_rate: 2.4e6 + type: fir_filter_ccf + width: 10e3 + win: window.WIN_HAMMING + states: + bus_sink: false + bus_source: false + bus_structure: null + state: enabled +- name: osmosdr_source_1 + id: osmosdr_source + parameters: + affinity: '' + alias: '' + ant0: '' + ant1: '' + ant10: '' + ant11: '' + ant12: '' + ant13: '' + ant14: '' + ant15: '' + ant16: '' + ant17: '' + ant18: '' + ant19: '' + ant2: '' + ant20: '' + ant21: '' + ant22: '' + ant23: '' + ant24: '' + ant25: '' + ant26: '' + ant27: '' + ant28: '' + ant29: '' + ant3: '' + ant30: '' + ant31: '' + ant4: '' + ant5: '' + ant6: '' + ant7: '' + ant8: '' + ant9: '' + args: '"rtl=0"' + bb_gain0: '20' + bb_gain1: '20' + bb_gain10: '20' + bb_gain11: '20' + bb_gain12: '20' + bb_gain13: '20' + bb_gain14: '20' + bb_gain15: '20' + bb_gain16: '20' + bb_gain17: '20' + bb_gain18: '20' + bb_gain19: '20' + bb_gain2: '20' + bb_gain20: '20' + bb_gain21: '20' + bb_gain22: '20' + bb_gain23: '20' + bb_gain24: '20' + bb_gain25: '20' + bb_gain26: '20' + bb_gain27: '20' + bb_gain28: '20' + bb_gain29: '20' + bb_gain3: '20' + bb_gain30: '20' + bb_gain31: '20' + bb_gain4: '20' + bb_gain5: '20' + bb_gain6: '20' + bb_gain7: '20' + bb_gain8: '20' + bb_gain9: '20' + bw0: '0' + bw1: '0' + bw10: '0' + bw11: '0' + bw12: '0' + bw13: '0' + bw14: '0' + bw15: '0' + bw16: '0' + bw17: '0' + bw18: '0' + bw19: '0' + bw2: '0' + bw20: '0' + bw21: '0' + bw22: '0' + bw23: '0' + bw24: '0' + bw25: '0' + bw26: '0' + bw27: '0' + bw28: '0' + bw29: '0' + bw3: '0' + bw30: '0' + bw31: '0' + bw4: '0' + bw5: '0' + bw6: '0' + bw7: '0' + bw8: '0' + bw9: '0' + clock_source0: '' + clock_source1: '' + clock_source2: '' + clock_source3: '' + clock_source4: '' + clock_source5: '' + clock_source6: '' + clock_source7: '' + comment: '' + corr0: '0' + corr1: '0' + corr10: '0' + corr11: '0' + corr12: '0' + corr13: '0' + corr14: '0' + corr15: '0' + corr16: '0' + corr17: '0' + corr18: '0' + corr19: '0' + corr2: '0' + corr20: '0' + corr21: '0' + corr22: '0' + corr23: '0' + corr24: '0' + corr25: '0' + corr26: '0' + corr27: '0' + corr28: '0' + corr29: '0' + corr3: '0' + corr30: '0' + corr31: '0' + corr4: '0' + corr5: '0' + corr6: '0' + corr7: '0' + corr8: '0' + corr9: '0' + dc_offset_mode0: '0' + dc_offset_mode1: '0' + dc_offset_mode10: '0' + dc_offset_mode11: '0' + dc_offset_mode12: '0' + dc_offset_mode13: '0' + dc_offset_mode14: '0' + dc_offset_mode15: '0' + dc_offset_mode16: '0' + dc_offset_mode17: '0' + dc_offset_mode18: '0' + dc_offset_mode19: '0' + dc_offset_mode2: '0' + dc_offset_mode20: '0' + dc_offset_mode21: '0' + dc_offset_mode22: '0' + dc_offset_mode23: '0' + dc_offset_mode24: '0' + dc_offset_mode25: '0' + dc_offset_mode26: '0' + dc_offset_mode27: '0' + dc_offset_mode28: '0' + dc_offset_mode29: '0' + dc_offset_mode3: '0' + dc_offset_mode30: '0' + dc_offset_mode31: '0' + dc_offset_mode4: '0' + dc_offset_mode5: '0' + dc_offset_mode6: '0' + dc_offset_mode7: '0' + dc_offset_mode8: '0' + dc_offset_mode9: '0' + freq0: 101.1e6 + freq1: 100e6 + freq10: 100e6 + freq11: 100e6 + freq12: 100e6 + freq13: 100e6 + freq14: 100e6 + freq15: 100e6 + freq16: 100e6 + freq17: 100e6 + freq18: 100e6 + freq19: 100e6 + freq2: 100e6 + freq20: 100e6 + freq21: 100e6 + freq22: 100e6 + freq23: 100e6 + freq24: 100e6 + freq25: 100e6 + freq26: 100e6 + freq27: 100e6 + freq28: 100e6 + freq29: 100e6 + freq3: 100e6 + freq30: 100e6 + freq31: 100e6 + freq4: 100e6 + freq5: 100e6 + freq6: 100e6 + freq7: 100e6 + freq8: 100e6 + freq9: 100e6 + gain0: '40' + gain1: '10' + gain10: '10' + gain11: '10' + gain12: '10' + gain13: '10' + gain14: '10' + gain15: '10' + gain16: '10' + gain17: '10' + gain18: '10' + gain19: '10' + gain2: '10' + gain20: '10' + gain21: '10' + gain22: '10' + gain23: '10' + gain24: '10' + gain25: '10' + gain26: '10' + gain27: '10' + gain28: '10' + gain29: '10' + gain3: '10' + gain30: '10' + gain31: '10' + gain4: '10' + gain5: '10' + gain6: '10' + gain7: '10' + gain8: '10' + gain9: '10' + gain_mode0: 'False' + gain_mode1: 'False' + gain_mode10: 'False' + gain_mode11: 'False' + gain_mode12: 'False' + gain_mode13: 'False' + gain_mode14: 'False' + gain_mode15: 'False' + gain_mode16: 'False' + gain_mode17: 'False' + gain_mode18: 'False' + gain_mode19: 'False' + gain_mode2: 'False' + gain_mode20: 'False' + gain_mode21: 'False' + gain_mode22: 'False' + gain_mode23: 'False' + gain_mode24: 'False' + gain_mode25: 'False' + gain_mode26: 'False' + gain_mode27: 'False' + gain_mode28: 'False' + gain_mode29: 'False' + gain_mode3: 'False' + gain_mode30: 'False' + gain_mode31: 'False' + gain_mode4: 'False' + gain_mode5: 'False' + gain_mode6: 'False' + gain_mode7: 'False' + gain_mode8: 'False' + gain_mode9: 'False' + if_gain0: '20' + if_gain1: '20' + if_gain10: '20' + if_gain11: '20' + if_gain12: '20' + if_gain13: '20' + if_gain14: '20' + if_gain15: '20' + if_gain16: '20' + if_gain17: '20' + if_gain18: '20' + if_gain19: '20' + if_gain2: '20' + if_gain20: '20' + if_gain21: '20' + if_gain22: '20' + if_gain23: '20' + if_gain24: '20' + if_gain25: '20' + if_gain26: '20' + if_gain27: '20' + if_gain28: '20' + if_gain29: '20' + if_gain3: '20' + if_gain30: '20' + if_gain31: '20' + if_gain4: '20' + if_gain5: '20' + if_gain6: '20' + if_gain7: '20' + if_gain8: '20' + if_gain9: '20' + iq_balance_mode0: '0' + iq_balance_mode1: '0' + iq_balance_mode10: '0' + iq_balance_mode11: '0' + iq_balance_mode12: '0' + iq_balance_mode13: '0' + iq_balance_mode14: '0' + iq_balance_mode15: '0' + iq_balance_mode16: '0' + iq_balance_mode17: '0' + iq_balance_mode18: '0' + iq_balance_mode19: '0' + iq_balance_mode2: '0' + iq_balance_mode20: '0' + iq_balance_mode21: '0' + iq_balance_mode22: '0' + iq_balance_mode23: '0' + iq_balance_mode24: '0' + iq_balance_mode25: '0' + iq_balance_mode26: '0' + iq_balance_mode27: '0' + iq_balance_mode28: '0' + iq_balance_mode29: '0' + iq_balance_mode3: '0' + iq_balance_mode30: '0' + iq_balance_mode31: '0' + iq_balance_mode4: '0' + iq_balance_mode5: '0' + iq_balance_mode6: '0' + iq_balance_mode7: '0' + iq_balance_mode8: '0' + iq_balance_mode9: '0' + maxoutbuf: '0' + minoutbuf: '0' + nchan: '1' + num_mboards: '1' + sample_rate: 2.4e6 + sync: sync + time_source0: '' + time_source1: '' + time_source2: '' + time_source3: '' + time_source4: '' + time_source5: '' + time_source6: '' + time_source7: '' + type: fc32 + states: + bus_sink: false + bus_source: false + bus_structure: null + state: enabled +- name: xmlrpc_server_0 + id: xmlrpc_server + parameters: + addr: 0.0.0.0 + alias: '' + comment: '' + port: '8090' + states: + bus_sink: false + bus_source: false + bus_structure: null + state: enabled + +connections: +- [analog_wfm_rcv_1, '0', blocks_wavfile_sink_0, '0'] +- [low_pass_filter_1, '0', analog_wfm_rcv_1, '0'] +- [osmosdr_source_1, '0', low_pass_filter_1, '0'] + +metadata: + file_format: 1 + grc_version: 3.10.12.0 diff --git a/examples/fm_101_1_recording.wav b/examples/fm_101_1_recording.wav new file mode 100644 index 0000000..b0d3a0b Binary files /dev/null and b/examples/fm_101_1_recording.wav differ diff --git a/examples/fm_receiver.py b/examples/fm_receiver.py new file mode 100644 index 0000000..041fd8a --- /dev/null +++ b/examples/fm_receiver.py @@ -0,0 +1,387 @@ +#!/usr/bin/env python3 +""" +FM Receiver Flowgraph Builder using gr-mcp + +This script uses gr-mcp's MCP tools to programmatically build a Wideband FM +receiver flowgraph that: +- Receives RF from an RTL-SDR dongle (or simulated source) +- Demodulates FM audio +- Outputs to speakers + +Signal Chain: + RTL-SDR Source (2.4 MHz) → Low Pass Filter → WBFM Demod → Audio Sink + ↓ ↓ ↓ ↓ + 88-108 MHz Anti-alias Demodulate Speakers + complex IQ 200 kHz BW to audio +""" + +import asyncio +import sys +from pathlib import Path + +from fastmcp import Client + +# Add project root to path for imports +sys.path.insert(0, str(Path(__file__).parent.parent)) + +from main import app as mcp_app + + +async def find_blocks_matching(client: Client, patterns: list[str]) -> dict[str, str]: + """Search available blocks for ones matching the given patterns.""" + result = await client.call_tool(name="get_all_available_blocks") + available = result.data + + matches = {} + for pattern in patterns: + for block in available: + if pattern.lower() in block.key.lower(): + if pattern not in matches: + matches[pattern] = block.key + break + return matches + + +async def build_fm_receiver( + client: Client, + freq_mhz: float = 99.5, + output_path: str = "/tmp/fm_receiver.grc", + use_simulation: bool = False, +): + """ + Build an FM receiver flowgraph. + + Args: + client: FastMCP client connected to gr-mcp + freq_mhz: FM station frequency in MHz (default 99.5) + output_path: Where to save the .grc file + use_simulation: If True, use signal source instead of RTL-SDR + """ + print(f"\n{'='*60}") + print(f"Building FM Receiver for {freq_mhz} MHz") + print(f"{'='*60}\n") + + # Step 1: Find available blocks + print("Step 1: Checking available blocks...") + result = await client.call_tool(name="get_all_available_blocks") + available_blocks = {b.key: b for b in result.data} + + # Check for SDR source options + sdr_sources = ["osmosdr_source", "soapy_source", "rtlsdr_source"] + found_sdr = None + for src in sdr_sources: + if src in available_blocks: + found_sdr = src + print(f" ✓ Found SDR source: {src}") + break + + if not found_sdr and not use_simulation: + print(" ⚠ No SDR source found (osmosdr, soapy, rtlsdr)") + print(" Using simulation mode with analog_sig_source_x") + use_simulation = True + + # Check for required blocks + required = ["low_pass_filter", "analog_wfm_rcv", "audio_sink"] + for block_key in required: + if block_key in available_blocks: + print(f" ✓ Found: {block_key}") + else: + # Try partial match + matches = [k for k in available_blocks if block_key in k] + if matches: + print(f" ✓ Found (partial): {matches[0]}") + else: + print(f" ✗ Missing: {block_key}") + + # Step 2: Create the blocks + print("\nStep 2: Creating blocks...") + blocks = {} + + # Source block + if use_simulation: + result = await client.call_tool( + name="make_block", arguments={"block_name": "analog_sig_source_x"} + ) + blocks["source"] = str(result.data) + print(f" Created simulation source: {blocks['source']}") + else: + result = await client.call_tool( + name="make_block", arguments={"block_name": found_sdr} + ) + blocks["source"] = str(result.data) + print(f" Created SDR source: {blocks['source']}") + + # Low pass filter + result = await client.call_tool( + name="make_block", arguments={"block_name": "low_pass_filter"} + ) + blocks["lpf"] = str(result.data) + print(f" Created low pass filter: {blocks['lpf']}") + + # WFM (Wideband FM) demodulator + result = await client.call_tool( + name="make_block", arguments={"block_name": "analog_wfm_rcv"} + ) + blocks["wfm"] = str(result.data) + print(f" Created WFM demod: {blocks['wfm']}") + + # Audio sink + result = await client.call_tool( + name="make_block", arguments={"block_name": "audio_sink"} + ) + blocks["audio"] = str(result.data) + print(f" Created audio sink: {blocks['audio']}") + + # Step 3: Configure block parameters + print("\nStep 3: Configuring block parameters...") + + freq_hz = freq_mhz * 1e6 + samp_rate = 2.4e6 # 2.4 MHz sample rate + audio_rate = 48000 # 48 kHz audio + + if use_simulation: + # Configure simulation source (complex sine wave at FM frequency) + # Using GRC parameter keys (not display names) from inspect_blocks.py + await client.call_tool( + name="set_block_params", + arguments={ + "block_name": blocks["source"], + "params": { + "type": "complex", + "samp_rate": str(samp_rate), + "freq": "1000", # 1 kHz tone offset + "amp": "1", + "offset": "0", + "waveform": "analog.GR_COS_WAVE", + }, + }, + ) + print(f" Configured simulation source (complex, {samp_rate/1e6} MHz)") + else: + # Configure RTL-SDR/OsmoSDR source + # Using GRC parameter keys (not display names) from inspect_blocks.py + await client.call_tool( + name="set_block_params", + arguments={ + "block_name": blocks["source"], + "params": { + "type": "fc32", + "args": '"rtl=0"', + "sample_rate": str(samp_rate), + "freq0": str(freq_hz), + "gain0": "40", + "if_gain0": "20", + "bb_gain0": "20", + }, + }, + ) + print(f" Configured SDR source: {freq_mhz} MHz, {samp_rate/1e6} MS/s") + + # Configure low pass filter + # Decimation: 2.4M → 480k (factor of 5) + # Using GRC parameter keys (not display names) from inspect_blocks.py + await client.call_tool( + name="set_block_params", + arguments={ + "block_name": blocks["lpf"], + "params": { + "type": "fir_filter_ccf", + "decim": "5", + "gain": "1", + "samp_rate": str(samp_rate), + "cutoff_freq": "100e3", # 100 kHz cutoff + "width": "10e3", # 10 kHz transition width + "win": "window.WIN_HAMMING", + }, + }, + ) + print(" Configured LPF: 100 kHz cutoff, 5x decimation → 480 kHz") + + # Configure WFM demodulator + # Input rate: 480 kHz, audio decimation: 10 → 48 kHz audio + # Using GRC parameter keys (not display names) from inspect_blocks.py + await client.call_tool( + name="set_block_params", + arguments={ + "block_name": blocks["wfm"], + "params": { + "quad_rate": "480e3", # 480 kHz input rate + "audio_decimation": "10", # → 48 kHz output + }, + }, + ) + print(" Configured WFM: quad_rate=480k, audio_dec=10 → 48 kHz") + + # Configure audio sink + # Using GRC parameter keys (not display names) from inspect_blocks.py + await client.call_tool( + name="set_block_params", + arguments={ + "block_name": blocks["audio"], + "params": { + "samp_rate": str(audio_rate), + "device_name": "", # Default audio device + "ok_to_block": "True", + "num_inputs": "1", + }, + }, + ) + print(f" Configured audio sink: {audio_rate} Hz") + + # Step 4: Check block ports before connecting + print("\nStep 4: Checking block ports...") + for name, block_name in blocks.items(): + sources = await client.call_tool( + name="get_block_sources", arguments={"block_name": block_name} + ) + sinks = await client.call_tool( + name="get_block_sinks", arguments={"block_name": block_name} + ) + src_count = len(sources.data) if sources.data else 0 + sink_count = len(sinks.data) if sinks.data else 0 + print(f" {name} ({block_name}): {src_count} source(s), {sink_count} sink(s)") + + # Step 5: Connect the signal chain + print("\nStep 5: Connecting signal chain...") + + # Source → Low Pass Filter + await client.call_tool( + name="connect_blocks", + arguments={ + "source_block_name": blocks["source"], + "sink_block_name": blocks["lpf"], + "source_port_name": "0", + "sink_port_name": "0", + }, + ) + print(f" {blocks['source']}:0 → {blocks['lpf']}:0") + + # Low Pass Filter → WBFM Demod + await client.call_tool( + name="connect_blocks", + arguments={ + "source_block_name": blocks["lpf"], + "sink_block_name": blocks["wfm"], + "source_port_name": "0", + "sink_port_name": "0", + }, + ) + print(f" {blocks['lpf']}:0 → {blocks['wfm']}:0") + + # WBFM Demod → Audio Sink + await client.call_tool( + name="connect_blocks", + arguments={ + "source_block_name": blocks["wfm"], + "sink_block_name": blocks["audio"], + "source_port_name": "0", + "sink_port_name": "0", + }, + ) + print(f" {blocks['wfm']}:0 → {blocks['audio']}:0") + + # Step 6: Validate the flowgraph + print("\nStep 6: Validating flowgraph...") + valid = await client.call_tool(name="validate_flowgraph") + if valid.data: + print(" ✓ Flowgraph is valid") + else: + print(" ✗ Flowgraph has errors:") + errors = await client.call_tool(name="get_all_errors") + for err in errors.data: + print(f" - {err}") + + # Step 7: Get all connections for verification + print("\nStep 7: Verifying connections...") + conns = await client.call_tool(name="get_connections") + for conn in conns.data: + # ConnectionModel has source/sink PortModels with parent (block) and key (port) + print( + f" {conn.source.parent}:{conn.source.key} → " + f"{conn.sink.parent}:{conn.sink.key}" + ) + + # Step 8: Save the flowgraph + print(f"\nStep 8: Saving flowgraph to {output_path}...") + await client.call_tool( + name="save_flowgraph", arguments={"filepath": output_path} + ) + print(f" ✓ Saved to {output_path}") + + # Summary + print(f"\n{'='*60}") + print("FM Receiver Flowgraph Complete!") + print(f"{'='*60}") + print(f" Frequency: {freq_mhz} MHz") + print(f" Sample Rate: {samp_rate/1e6} MS/s") + print(f" Audio Rate: {audio_rate} Hz") + print(f" Output: {output_path}") + if use_simulation: + print(" Mode: SIMULATION (no RTL-SDR)") + else: + print(" Mode: RTL-SDR") + print() + + return blocks + + +async def list_all_blocks(client: Client, filter_pattern: str = None): + """List all available GNU Radio blocks, optionally filtered.""" + result = await client.call_tool(name="get_all_available_blocks") + blocks = sorted(result.data, key=lambda b: b.key) + + if filter_pattern: + blocks = [b for b in blocks if filter_pattern.lower() in b.key.lower()] + + print(f"\nAvailable blocks ({len(blocks)} total):") + for block in blocks: + print(f" {block.key}") + + return blocks + + +async def main(): + """Main entry point.""" + import argparse + + parser = argparse.ArgumentParser(description="Build FM Receiver with gr-mcp") + parser.add_argument( + "--freq", type=float, default=99.5, help="FM frequency in MHz (default: 99.5)" + ) + parser.add_argument( + "--output", + type=str, + default="/tmp/fm_receiver.grc", + help="Output .grc file path", + ) + parser.add_argument( + "--simulate", + action="store_true", + help="Use simulated source instead of RTL-SDR", + ) + parser.add_argument( + "--list-blocks", + type=str, + nargs="?", + const="", + help="List available blocks (optionally filter by pattern)", + ) + + args = parser.parse_args() + + async with Client(mcp_app) as client: + if args.list_blocks is not None: + await list_all_blocks( + client, args.list_blocks if args.list_blocks else None + ) + else: + await build_fm_receiver( + client, + freq_mhz=args.freq, + output_path=args.output, + use_simulation=args.simulate, + ) + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/inspect_blocks.py b/examples/inspect_blocks.py new file mode 100644 index 0000000..6fb9045 --- /dev/null +++ b/examples/inspect_blocks.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +"""Inspect block parameters for FM receiver blocks.""" + +import asyncio +import sys +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).parent.parent)) + +from fastmcp import Client +from main import app as mcp_app + + +async def inspect_block(client: Client, block_key: str): + """Create a block and show its parameters.""" + print(f"\n{'='*60}") + print(f"Block: {block_key}") + print(f"{'='*60}") + + # Create the block + result = await client.call_tool( + name="make_block", arguments={"block_name": block_key} + ) + block_name = str(result.data) + print(f"Created: {block_name}") + + # Get parameters + params = await client.call_tool( + name="get_block_params", arguments={"block_name": block_name} + ) + + print("\nParameters (key -> display name):") + for param in params.data: + print(f" {param.key}: {param.value!r}") + print(f" name: {param.name}") + print(f" type: {param.dtype}") + + # Get sources (outputs) + sources = await client.call_tool( + name="get_block_sources", arguments={"block_name": block_name} + ) + print("\nSources (outputs):") + for port in sources.data: + print(f" [{port.key}] {port.name} ({port.dtype})") + + # Get sinks (inputs) + sinks = await client.call_tool( + name="get_block_sinks", arguments={"block_name": block_name} + ) + print("\nSinks (inputs):") + for port in sinks.data: + print(f" [{port.key}] {port.name} ({port.dtype})") + + return block_name + + +async def main(): + blocks_to_inspect = [ + "osmosdr_source", + "low_pass_filter", + "analog_wfm_rcv", + "audio_sink", + "analog_sig_source_x", + ] + + async with Client(mcp_app) as client: + for block_key in blocks_to_inspect: + try: + await inspect_block(client, block_key) + except Exception as e: + print(f"\nError inspecting {block_key}: {e}") + + +if __name__ == "__main__": + asyncio.run(main())