get_status
Retrieve the current status and configuration of an open serial port, including active settings, to quickly diagnose connection issues.
Instructions
获取已打开串口的当前状态和配置信息
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| port | Yes | 串口路径 |
Implementation Reference
- src/uart_mcp/tools/port_ops.py:119-130 (handler)The 'get_status' handler function - the MCP tool entry point. It delegates to SerialManager.get_status() and returns the result as a dict.
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 GET_STATUS_TOOL schema definition - registers the tool's name, description, and input schema (requires 'port' string parameter).
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:87-91 (registration)Tool registration in handle_list_tools - registers 'get_status' as an available MCP tool with its schema.
types.Tool( name=GET_STATUS_TOOL["name"], description=GET_STATUS_TOOL["description"], inputSchema=GET_STATUS_TOOL["inputSchema"], ), - src/uart_mcp/server.py:156-157 (registration)Tool dispatch in handle_call_tool - routes the 'get_status' tool name to the get_status() handler function.
elif name == "get_status": result = get_status(**arguments) - SerialManager.get_status() - the underlying implementation that looks up the managed port and returns a PortStatus dataclass.
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, )