Skip to main content
Glama

set_config

Change configuration settings for an open serial port without closing it, including baud rate, data bits, parity, stop bits, flow control, and timeout values.

Instructions

修改已打开串口的配置(热更新,无需关闭重开)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portYes串口路径
baudrateNo波特率,支持的值:[300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200, 230400, 460800, 921600]
bytesizeNo数据位,支持的值:[5, 6, 7, 8]
parityNo校验位,支持的值:['N', 'E', 'O', 'M', 'S']
stopbitsNo停止位,支持的值:[1.0, 1.5, 2.0]
flow_controlNo流控制,支持的值:['none', 'hardware', 'software']
read_timeout_msNo读取超时(毫秒),范围 0-60000
write_timeout_msNo写入超时(毫秒),范围 0-60000

Implementation Reference

  • The handler function that executes the set_config tool logic by calling the serial manager's set_config method and returning the updated status dictionary.
    def set_config( port: str, baudrate: int | None = None, bytesize: int | None = None, parity: str | None = None, stopbits: float | None = None, flow_control: str | None = None, read_timeout_ms: int | None = None, write_timeout_ms: int | None = None, ) -> dict[str, Any]: """修改串口配置(热更新) Args: port: 串口路径 baudrate: 波特率(可选) bytesize: 数据位(可选) parity: 校验位(可选) stopbits: 停止位(可选) flow_control: 流控制(可选) read_timeout_ms: 读取超时(可选) write_timeout_ms: 写入超时(可选) Returns: 更新后的串口状态 """ manager = get_serial_manager() status = manager.set_config( port=port, baudrate=baudrate, bytesize=bytesize, parity=parity, stopbits=stopbits, flow_control=flow_control, read_timeout_ms=read_timeout_ms, write_timeout_ms=write_timeout_ms, ) return status.to_dict()
  • The input schema and metadata definition for the set_config tool used in MCP registration.
    SET_CONFIG_TOOL: dict[str, Any] = { "name": "set_config", "description": "修改已打开串口的配置(热更新,无需关闭重开)", "inputSchema": { "type": "object", "properties": { "port": { "type": "string", "description": "串口路径", }, "baudrate": { "type": "integer", "description": f"波特率,支持的值:{list(SUPPORTED_BAUDRATES)}", }, "bytesize": { "type": "integer", "description": f"数据位,支持的值:{list(SUPPORTED_BYTESIZES)}", }, "parity": { "type": "string", "description": f"校验位,支持的值:{[p.value for p in Parity]}", }, "stopbits": { "type": "number", "description": f"停止位,支持的值:{[s.value for s in StopBits]}", }, "flow_control": { "type": "string", "description": f"流控制,支持的值:{[f.value for f in FlowControl]}", }, "read_timeout_ms": { "type": "integer", "description": "读取超时(毫秒),范围 0-60000", }, "write_timeout_ms": { "type": "integer", "description": "写入超时(毫秒),范围 0-60000", }, }, "required": ["port"], }, }
  • Registration of the set_config tool in the MCP server's list_tools handler, providing name, description, and input schema.
    types.Tool( name=SET_CONFIG_TOOL["name"], description=SET_CONFIG_TOOL["description"], inputSchema=SET_CONFIG_TOOL["inputSchema"], ),
  • Dispatch logic in the MCP server's call_tool handler that invokes the set_config function when the tool is called.
    elif name == "set_config": result = set_config(**arguments)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/donnel666/uart-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server