get_status
Retrieve current status and configuration details for an open serial port to monitor connection parameters and operational state.
Instructions
获取已打开串口的当前状态和配置信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| port | Yes | 串口路径 |
Implementation Reference
- src/uart_mcp/tools/port_ops.py:119-130 (handler)The primary handler function for the 'get_status' tool. It retrieves the serial manager and calls its get_status method, returning the result as a dictionary.def get_status(port: str) -> dict[str, Any]: """获取串口状态 Args: port: 串口路径 Returns: 串口状态信息 """ manager = get_serial_manager() status = manager.get_status(port) return status.to_dict()
- The schema definition for the 'get_status' tool, including name, description, and input schema. This is used for MCP tool registration.GET_STATUS_TOOL: dict[str, Any] = { "name": "get_status", "description": "获取已打开串口的当前状态和配置信息", "inputSchema": { "type": "object", "properties": { "port": { "type": "string", "description": "串口路径", }, }, "required": ["port"], }, }
- src/uart_mcp/server.py:156-157 (registration)Dispatch logic in the MCP server's call_tool handler that routes 'get_status' calls to the tool function.elif name == "get_status": result = get_status(**arguments)
- src/uart_mcp/server.py:87-91 (registration)Registration of the 'get_status' tool in the MCP server's list_tools handler, providing the schema.types.Tool( name=GET_STATUS_TOOL["name"], description=GET_STATUS_TOOL["description"], inputSchema=GET_STATUS_TOOL["inputSchema"], ),
- Core helper method in SerialManager that implements the actual port status retrieval logic, called by the tool handler.def get_status(self, port: str) -> PortStatus: """获取串口状态 Args: port: 串口路径 Returns: 串口状态 Raises: PortClosedError: 串口未打开 """ with self._lock: if port not in self._ports: raise PortClosedError(port) managed = self._ports[port] return PortStatus( port=port, is_open=True, config=managed.config, connected=managed.is_connected, reconnecting=managed.reconnecting, )