read_output
Retrieve content from terminal output buffers in UART serial sessions, with options to clear after reading for continuous data monitoring.
Instructions
读取终端输出缓冲区的内容
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes | 会话ID(即串口路径),如 /dev/ttyUSB0 或 COM1 | |
| clear | No | 读取后是否清空缓冲区 |
Implementation Reference
- src/uart_mcp/tools/terminal.py:75-89 (handler)The core handler function for the 'read_output' tool. It retrieves the terminal manager and calls its read_output method with the provided session_id and clear flag.def read_output( session_id: str, clear: bool = True, ) -> dict[str, Any]: """读取终端输出缓冲区内容 Args: session_id: 会话ID(串口路径) clear: 是否清空缓冲区 Returns: 输出内容 """ manager = get_terminal_manager() return manager.read_output(session_id=session_id, clear=clear)
- The schema definition for the 'read_output' tool, including input schema with session_id (required) and optional clear parameter.READ_OUTPUT_TOOL: dict[str, Any] = { "name": "read_output", "description": "读取终端输出缓冲区的内容", "inputSchema": { "type": "object", "properties": { "session_id": { "type": "string", "description": "会话ID(即串口路径),如 /dev/ttyUSB0 或 COM1", }, "clear": { "type": "boolean", "description": "读取后是否清空缓冲区", "default": True, }, }, "required": ["session_id"], }, }
- src/uart_mcp/server.py:118-122 (registration)Registration of the 'read_output' tool in the MCP server's list_tools() handler.types.Tool( name=READ_OUTPUT_TOOL["name"], description=READ_OUTPUT_TOOL["description"], inputSchema=READ_OUTPUT_TOOL["inputSchema"], ),
- src/uart_mcp/server.py:169-170 (registration)Dispatch logic in the MCP server's call_tool() handler that invokes the read_output function.elif name == "read_output": result = read_output(**arguments)