list_ports
Discover available serial port devices by retrieving their paths, descriptions, and hardware IDs for UART communication setup.
Instructions
列出所有可用串口设备,返回设备路径、描述信息和硬件ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/uart_mcp/tools/list_ports.py:11-21 (handler)The handler function that executes the list_ports tool logic: retrieves the serial manager and returns a list of available ports as dictionaries.def list_ports() -> list[dict[str, str]]: """列出所有可用串口设备 返回系统中所有可用的串口设备列表,已过滤黑名单中的串口。 Returns: 串口信息列表,每个元素包含 port、description、hwid 字段 """ manager = get_serial_manager() ports = manager.list_ports() return [p.to_dict() for p in ports]
- Tool schema definition including name, description, and empty input schema (no parameters required).LIST_PORTS_TOOL: dict[str, Any] = { "name": "list_ports", "description": "列出所有可用串口设备,返回设备路径、描述信息和硬件ID", "inputSchema": { "type": "object", "properties": {}, "required": [], }, }
- src/uart_mcp/server.py:67-71 (registration)Registration of the list_ports tool in the MCP server's list_tools handler, using the schema from list_ports.py.types.Tool( name=LIST_PORTS_TOOL["name"], description=LIST_PORTS_TOOL["description"], inputSchema=LIST_PORTS_TOOL["inputSchema"], ),
- src/uart_mcp/server.py:148-149 (registration)Dispatch/handling of list_ports tool call in the MCP server's call_tool handler, invoking the list_ports function.if name == "list_ports": result = list_ports()