connect_device
Establish connection to a PicoScope oscilloscope device using its serial number or automatically detect the first available unit for signal acquisition and measurement operations.
Instructions
Connect to a specific PicoScope device.
Args: serial: Device serial number. If empty, connects to first available device.
Returns: Dictionary containing connection status and device information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serial | No |
Implementation Reference
- The handler function for the 'connect_device' tool. It uses device_manager to connect to a PicoScope device by optional serial number and returns a dictionary with connection status and device information.@mcp.tool() def connect_device(serial: str = "") -> dict[str, Any]: """Connect to a specific PicoScope device. Args: serial: Device serial number. If empty, connects to first available device. Returns: Dictionary containing connection status and device information. """ try: # Connect to device success = device_manager.connect(serial=serial if serial else None) if not success: return { "status": "error", "error": "Failed to connect to device", "serial": serial, } # Get device info info = device_manager.get_info() if info: return { "status": "success", "connected": True, "device": { "model": info.model, "serial": info.serial, "variant": info.variant, "num_channels": info.num_channels, "max_adc_value": info.max_adc_value, }, } else: return { "status": "error", "error": "Connected but failed to retrieve device info", } except Exception as e: return { "status": "error", "error": str(e), "serial": serial, }
- src/picoscope_mcp/server.py:15-15 (registration)Invocation of register_discovery_tools(mcp) which defines and registers the connect_device tool using the @mcp.tool() decorator.register_discovery_tools(mcp)