Skip to main content
Glama
danroblewis
by danroblewis

scan_g1_devices

Scan for available G1 Bluetooth devices to discover and list them with addresses and signal strength for connection setup.

Instructions

Scan for available G1 devices.

Returns: Dict[str, Any]: JSON response with scan results including: - result: "success" or "error" - devices: List of discovered devices with their properties - count: Number of devices found - error: Error message if scan failed Note: This performs an actual BLE scan for devices with names containing "G1_" pattern. Returns a structured list of discovered devices with their addresses and signal strength.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for scan_g1_devices tool. Decorated with @server.tool() for registration. Performs BLE scan using NordicBLEUARTManager, processes devices to identify left/right G1 devices, and returns structured JSON result.
    async def scan_g1_devices() -> Dict[str, Any]: """Scan for available G1 devices. Returns: Dict[str, Any]: JSON response with scan results including: - result: "success" or "error" - devices: List of discovered devices with their properties - count: Number of devices found - error: Error message if scan failed Note: This performs an actual BLE scan for devices with names containing "G1_" pattern. Returns a structured list of discovered devices with their addresses and signal strength. """ try: devices = await ble_manager.scan_for_devices(filter_pattern="G1_") except Exception as e: logger.error(f"Scan failed: {e}") return { "result": "error", "error": str(e), "devices": [], "count": 0 } # Process devices to extract side information and format properly processed_devices = [] for device in devices: device_info = { "name": device['name'], "id": device['address'], "side": "right" if "_R_" in device['name'] else "left" if "_L_" in device['name'] else "unknown", "rssi": device.get('rssi') if device.get('rssi') != 'N/A' else None } processed_devices.append(device_info) return { "result": "success", "devices": processed_devices, "count": len(processed_devices) }
  • mcp_server.py:74-74 (registration)
    The @server.tool() decorator registers the scan_g1_devices function as an MCP tool with the FastMCP server.
    async def scan_g1_devices() -> Dict[str, Any]:
  • Helper function that uses the same scan_for_devices logic to find and auto-connect to right G1 devices.
    async def auto_connect_to_right_device(): """Automatically scan for and connect to the first right G1 device found""" try: logger.info("Auto-connecting to right G1 device...") # Scan for devices devices = await ble_manager.scan_for_devices(filter_pattern="G1_") if not devices: logger.warning("No G1 devices found during auto-connect") return False # Find the first device with "_R_" in the name (right device) right_device = None for device in devices: if "_R_" in device['name']: right_device = device break if not right_device: logger.warning("No right G1 device found during auto-connect") return False logger.info(f"Found right G1 device: {right_device['name']} ({right_device['address']})") # Attempt to connect success = await ble_manager.connect_to_device(right_device['address']) if success: logger.info(f"Auto-connect successful to {right_device['name']}") return True else: logger.warning(f"Auto-connect failed to {right_device['name']}") return False except Exception as e: logger.error(f"Auto-connect failed: {e}") return False

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/danroblewis/g1_uart_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server