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)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While it mentions the tool creates a session and supports configuration of line endings and local echo, it doesn't describe what happens after creation (e.g., session persistence, how to interact with it), whether there are rate limits, authentication requirements, or error conditions. For a creation tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core purpose upfront. It wastes no words and gets directly to the point. However, it could be slightly more structured by separating the core action from the configurable features for even better clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of creating a session (a stateful operation with multiple parameters), no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., a session ID, success/failure status), error handling, or how the created session integrates with other tools like 'send_command' or 'read_output'. For a creation tool in this context, more completeness is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already fully documents all 4 parameters. The description mentions line endings and local echo configuration, which aligns with two parameters, but adds no additional semantic context beyond what's in the schema. With complete schema coverage, the baseline score of 3 is appropriate as the description doesn't enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('创建终端会话' - create terminal session) and the resource ('在已打开串口上' - on an already opened serial port). It also specifies two configurable features (line endings and local echo). However, it doesn't explicitly differentiate this tool from its siblings like 'open_port' or 'get_session_info', which would be needed for a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (like needing an open port first), nor does it explain when to choose this over other session-related tools like 'get_session_info' or 'list_sessions'. The phrase '在已打开串口上' implies a prerequisite but doesn't explicitly state it as a requirement.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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