Skip to main content
Glama

create_session

Establish an interactive terminal session on an open UART serial port to send commands and receive responses, with configurable line endings and local echo settings.

Instructions

在已打开串口上创建终端会话,支持配置换行符和本地回显

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portYes串口路径,如 /dev/ttyUSB0 或 COM1
line_endingNo换行符类型:CR(回车)、LF(换行)、CRLF(回车换行)CRLF
local_echoNo是否本地回显发送的命令
buffer_sizeNo输出缓冲区大小(字节),默认 64KB

Implementation Reference

  • The core handler function for the 'create_session' tool. It invokes the terminal manager to create a session on the specified serial port with given configuration and returns the session info as a dict.
    def create_session( port: str, line_ending: str = "CRLF", local_echo: bool = DEFAULT_LOCAL_ECHO, buffer_size: int = DEFAULT_BUFFER_SIZE, ) -> dict[str, Any]: """在已打开串口上创建终端会话 Args: port: 串口路径 line_ending: 换行符类型(CR/LF/CRLF) local_echo: 是否本地回显 buffer_size: 输出缓冲区大小 Returns: 会话信息 """ manager = get_terminal_manager() session_info = manager.create_session( port=port, line_ending=line_ending, local_echo=local_echo, buffer_size=buffer_size, ) return session_info.to_dict()
  • Input schema definition for the 'create_session' tool, including parameters like port (required), line_ending, local_echo, and buffer_size.
    CREATE_SESSION_TOOL: dict[str, Any] = { "name": "create_session", "description": "在已打开串口上创建终端会话,支持配置换行符和本地回显", "inputSchema": { "type": "object", "properties": { "port": { "type": "string", "description": "串口路径,如 /dev/ttyUSB0 或 COM1", }, "line_ending": { "type": "string", "description": "换行符类型:CR(回车)、LF(换行)、CRLF(回车换行)", "enum": ["CR", "LF", "CRLF"], "default": "CRLF", }, "local_echo": { "type": "boolean", "description": "是否本地回显发送的命令", "default": False, }, "buffer_size": { "type": "integer", "description": "输出缓冲区大小(字节),默认 64KB", "default": DEFAULT_BUFFER_SIZE, }, }, "required": ["port"], }, }
  • Registration of the 'create_session' tool in the MCP server's list_tools() method, using the schema from terminal.py.
    name=CREATE_SESSION_TOOL["name"], description=CREATE_SESSION_TOOL["description"], inputSchema=CREATE_SESSION_TOOL["inputSchema"], ),
  • Dispatch logic in the MCP server's call_tool() handler that invokes the create_session function when the tool is called.
    elif name == "create_session": result = create_session(**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