get_status
Retrieve current status and configuration details for an open serial port to monitor device communication parameters.
Instructions
获取已打开串口的当前状态和配置信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| port | Yes | 串口路径 |
Implementation Reference
- src/uart_mcp/tools/port_ops.py:119-131 (handler)The handler function for the 'get_status' MCP tool. It calls the serial manager's get_status method and converts the result to 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 input schema definition for the 'get_status' tool used in MCP 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)Tool dispatch registration in the MCP server's handle_call_tool method, which invokes the get_status handler.elif name == "get_status": result = get_status(**arguments)
- src/uart_mcp/server.py:87-91 (registration)Tool listing registration in the MCP server's handle_list_tools method, exposing the get_status tool.types.Tool( name=GET_STATUS_TOOL["name"], description=GET_STATUS_TOOL["description"], inputSchema=GET_STATUS_TOOL["inputSchema"], ),
- Core helper method in SerialManager that retrieves and returns the detailed PortStatus for a specific port.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, )