Skip to main content
Glama
danroblewis

G1 UART MCP Server

by danroblewis

get_g1_connection_status

Check connection status and device information for G1 Bluetooth devices using the Nordic UART protocol over BLE. Returns connection state, device details, UART service availability, and message statistics.

Instructions

Get current connection status and device info.

Returns:
    Dict[str, Any]: JSON response with detailed connection status including:
        - result: "success" or "error"
        - connected: Boolean indicating connection state
        - device_name: Name of connected device (if connected)
        - device_address: Address of connected device (if connected)
        - uart_service_available: Boolean indicating UART service availability
        - tx_characteristic_available: Boolean indicating TX characteristic availability
        - rx_characteristic_available: Boolean indicating RX characteristic availability
        - pending_messages_count: Number of pending messages
        - total_messages: Total message count
        - error: Error message if status check failed
    
Note:
    This returns detailed status information including:
     - Connection state (connected/disconnected)
     - Device name and address (if connected)
     - UART service availability
     - Number of pending messages
     - Total message count

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler for the get_g1_connection_status tool. Registered via @server.tool() decorator. Retrieves status from BLE manager and formats the response dictionary with connection details.
    @server.tool()
    async def get_g1_connection_status() -> Dict[str, Any]:
        """Get current connection status and device info.
        
        Returns:
            Dict[str, Any]: JSON response with detailed connection status including:
                - result: "success" or "error"
                - connected: Boolean indicating connection state
                - device_name: Name of connected device (if connected)
                - device_address: Address of connected device (if connected)
                - uart_service_available: Boolean indicating UART service availability
                - tx_characteristic_available: Boolean indicating TX characteristic availability
                - rx_characteristic_available: Boolean indicating RX characteristic availability
                - pending_messages_count: Number of pending messages
                - total_messages: Total message count
                - error: Error message if status check failed
            
        Note:
            This returns detailed status information including:
             - Connection state (connected/disconnected)
             - Device name and address (if connected)
             - UART service availability
             - Number of pending messages
             - Total message count
        """
        try:
            status = ble_manager.get_connection_status()
        except Exception as e:
            logger.error(f"Status check failed: {e}")
            return {
                "result": "error",
                "connected": False,
                "error": f"Status check failed: {str(e)}"
            }
    
        return {
            "result": "success",
            "connected": status['connected'],
            "device_name": status.get('device_name'),
            "device_address": status.get('device_address'),
            "uart_service_available": status.get('uart_service_available', False),
            "tx_characteristic_available": status.get('tx_characteristic_available', False),
            "rx_characteristic_available": status.get('rx_characteristic_available', False),
            "pending_messages_count": status.get('pending_messages_count', 0),
            "total_messages": status.get('total_messages', 0)
        }
  • Supporting helper method in NordicBLEUARTManager class that provides the detailed connection status data used by the tool handler.
    def get_connection_status(self) -> Dict[str, Any]:
        """Get current connection status and device info"""
        connection_duration = None
        if self.connection_start_time:
            connection_duration = (datetime.now() - self.connection_start_time).total_seconds()
        
        last_activity = None
        if self.last_activity_time:
            last_activity = (datetime.now() - self.last_activity_time).total_seconds()
        
        return {
            "connected": self.is_connected,
            "device_name": self.target_device.name if self.target_device else None,
            "device_address": self.target_device.address if self.target_device else None,
            "uart_service_available": self.uart_service is not None,
            "tx_characteristic_available": self.tx_characteristic is not None,
            "rx_characteristic_available": self.rx_characteristic is not None,
            "pending_messages_count": len(self.pending_messages),
            "total_messages": len(self.communication_log),
            "connection_duration_seconds": connection_duration,
            "last_activity_seconds": last_activity,
            "reconnect_attempts": self.reconnect_attempts,
            "auto_reconnect_enabled": self.auto_reconnect_enabled
        }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the tool's read-only nature by specifying it 'returns' status information without indicating any mutations. However, it does not address potential side effects, error handling beyond the 'error' field, or performance characteristics like latency or rate limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded, starting with a clear purpose statement followed by a detailed return specification. However, the 'Note' section is somewhat redundant with the 'Returns' section, repeating information about connection state and device details, which slightly reduces efficiency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (status retrieval with detailed output), the description is complete. It fully explains the return values, compensating for the lack of annotations and output schema by detailing each field in the JSON response. The context signals (0 parameters, output schema true) are adequately addressed, making the tool's behavior clear for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately focuses on output semantics, detailing the return structure comprehensively. This adds significant value beyond the schema by explaining the meaning of each field in the response, such as what 'pending_messages_count' represents.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Get current connection status and device info') and identifies the exact resource (G1 device connection status). It distinguishes from siblings like connect_g1_device, disconnect_g1_device, scan_g1_devices, and send_g1_message by focusing on status retrieval rather than connection management or communication.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through the detailed return structure, suggesting this tool is for checking connection state and device details. However, it lacks explicit guidance on when to use this versus alternatives like scan_g1_devices (for discovery) or send_g1_message (for communication), and does not specify prerequisites such as requiring a prior connection attempt.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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