close_session
Terminate an active serial port communication session to free system resources and ensure proper device disconnection.
Instructions
关闭指定的终端会话
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes | 会话ID(即串口路径),如 /dev/ttyUSB0 或 COM1 |
Implementation Reference
- src/uart_mcp/tools/terminal.py:39-50 (handler)The handler function for the 'close_session' tool. It retrieves the terminal manager and calls its close_session method with the provided session_id, returning the result as a dictionary.def close_session(session_id: str) -> dict[str, Any]: """关闭指定终端会话 Args: session_id: 会话ID(串口路径) Returns: 操作结果 """ manager = get_terminal_manager() return manager.close_session(session_id)
- The schema definition for the 'close_session' tool, specifying the input schema that requires a 'session_id' string.CLOSE_SESSION_TOOL: dict[str, Any] = { "name": "close_session", "description": "关闭指定的终端会话", "inputSchema": { "type": "object", "properties": { "session_id": { "type": "string", "description": "会话ID(即串口路径),如 /dev/ttyUSB0 或 COM1", }, }, "required": ["session_id"], }, }
- src/uart_mcp/server.py:108-112 (registration)Registration of the 'close_session' tool in the MCP server's list_tools handler, providing name, description, and input schema.types.Tool( name=CLOSE_SESSION_TOOL["name"], description=CLOSE_SESSION_TOOL["description"], inputSchema=CLOSE_SESSION_TOOL["inputSchema"], ),
- src/uart_mcp/server.py:165-166 (registration)Dispatch logic in the MCP server's call_tool handler that invokes the close_session function when the tool 'close_session' is called.elif name == "close_session": result = close_session(**arguments)