Skip to main content
Glama
danroblewis

G1 UART MCP Server

by danroblewis

disconnect_g1_device

Disconnect from a connected G1 Bluetooth device to close the BLE connection, stop the heartbeat mechanism, and free up resources.

Instructions

Disconnect from the current G1 device.

Returns:
    Dict[str, Any]: JSON response with disconnection status including:
        - result: "success" or "error"
        - disconnected: Boolean indicating disconnection state
        - device_name: Name of previously connected device (if successful)
        - error: Error message if disconnection failed
    
Note:
    This closes the BLE connection to the currently connected device,
    cleans up resources, stops the heartbeat mechanism, and resets connection state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function decorated with @server.tool(), implementing the disconnect_g1_device tool. It handles disconnection logic using the global ble_manager instance.
    @server.tool()
    async def disconnect_g1_device() -> Dict[str, Any]:
        """Disconnect from the current G1 device.
        
        Returns:
            Dict[str, Any]: JSON response with disconnection status including:
                - result: "success" or "error"
                - disconnected: Boolean indicating disconnection state
                - device_name: Name of previously connected device (if successful)
                - error: Error message if disconnection failed
            
        Note:
            This closes the BLE connection to the currently connected device,
            cleans up resources, stops the heartbeat mechanism, and resets connection state.
        """
        if not ble_manager.is_connected:
            return {
                "result": "error",
                "disconnected": False,
                "error": "Not connected to any device"
            }
    
        device_name = ble_manager.target_device.name if ble_manager.target_device else "Unknown"
    
        try:        
            await ble_manager.disconnect()
            return {
                "result": "success",
                "disconnected": True,
                "device_name": device_name
            }
        except Exception as e:
            logger.error(f"Disconnection failed: {e}")
            return {
                "result": "error",
                "disconnected": False,
                "error": f"Disconnection failed: {str(e)}"
            }

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