connect_device
Establish connection to a PicoScope oscilloscope device for signal acquisition and analysis. Specify a serial number or connect to the first available device to enable measurement and data capture functionality.
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' MCP tool. Connects to a PicoScope device by serial (or first available), retrieves info via device_manager, and returns success/error status with device details.@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)Registers the discovery tools (including connect_device) by calling register_discovery_tools on the MCP server instance.register_discovery_tools(mcp)
- src/picoscope_mcp/server.py:5-5 (registration)Imports the register_discovery_tools function used to register connect_device and other discovery tools.from .tools.discovery import register_discovery_tools