Skip to main content
Glama

close_port

Close a specified UART serial port connection by providing the port path, ending communication with the device.

Instructions

关闭指定串口连接

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portYes串口路径

Implementation Reference

  • The close_port tool handler function that delegates to SerialManager.close_port().
    def close_port(port: str) -> dict[str, Any]:
        """关闭串口
    
        Args:
            port: 串口路径
    
        Returns:
            操作结果
        """
        manager = get_serial_manager()
        return manager.close_port(port)
  • The core SerialManager.close_port() method that actually closes the serial port connection.
    def close_port(self, port: str) -> dict[str, Any]:
        """关闭串口
    
        Args:
            port: 串口路径
    
        Returns:
            操作结果
    
        Raises:
            PortClosedError: 串口未打开
        """
        with self._lock:
            if port not in self._ports:
                raise PortClosedError(port)
    
            managed = self._ports.pop(port)
            try:
                managed.serial.close()
            except Exception as e:
                logger.warning("关闭串口时发生异常:%s - %s", port, e)
    
            logger.info("串口关闭成功:%s", port)
            return {"success": True, "port": port}
  • The schema/input validation definition for the close_port tool (name, description, inputSchema with required port parameter).
    CLOSE_PORT_TOOL: dict[str, Any] = {
        "name": "close_port",
        "description": "关闭指定串口连接",
        "inputSchema": {
            "type": "object",
            "properties": {
                "port": {
                    "type": "string",
                    "description": "串口路径",
                },
            },
            "required": ["port"],
        },
    }
  • Registration of close_port in the MCP server's call_tool handler, dispatching to the close_port function.
    elif name == "close_port":
        result = close_port(**arguments)
  • Registration of close_port in the MCP server's list_tools handler via CLOSE_PORT_TOOL schema.
    types.Tool(
        name=CLOSE_PORT_TOOL["name"],
        description=CLOSE_PORT_TOOL["description"],
        inputSchema=CLOSE_PORT_TOOL["inputSchema"],
    ),
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. It only states the action without detailing side effects (e.g., resource release), error states (e.g., closing already closed port), or required permissions.

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, concise phrase that hits the key point. It is front-loaded and does not waste words, though it could benefit from slightly more structure for clarity.

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

Completeness3/5

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

Given the low complexity (one parameter, no output schema), the description is minimally complete. However, it lacks information on return values, error handling, and usage context, leaving gaps for the agent.

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 input schema covers 100% of parameters, and the description adds no extra meaning beyond the parameter descriptions. The baseline score of 3 is appropriate as the schema already provides necessary details.

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

Purpose5/5

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

The description specifies the action 'close' and the resource 'specified serial port connection', clearly stating the tool's function. It distinguishes itself from sibling tools like 'open_port' and 'close_session' due to its explicit reference to serial port connection.

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?

No guidance on when to use this tool versus alternatives like 'close_session' for sessions. No prerequisites or conditions for use are mentioned, leaving the agent without context for appropriate invocation.

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