Skip to main content
Glama

terminal_close

DestructiveIdempotent

Close terminal sessions to free system resources and manage multiple terminal windows effectively. Specify the session ID to terminate the connection and clean up associated processes.

Instructions

Close a terminal session.

Closes the terminal window and cleans up associated resources.

Args:
    session_id: The terminal session ID to close.

Returns:
    dict: Contains success status and message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes

Implementation Reference

  • The 'terminal_close' function acts as the handler for the MCP tool, invoking the 'SessionManager' to close the terminal session and returning the result.
    async def terminal_close(session_id: str) -> dict:
        """Close a terminal session.
    
        Closes the terminal window and cleans up associated resources.
    
        Args:
            session_id: The terminal session ID to close.
    
        Returns:
            dict: Contains success status and message.
        """
        manager = SessionManager.get_instance()
        success = await manager.close_session(session_id)
    
        if success:
            return {
                "success": True,
                "message": f"Terminal session '{session_id}' has been closed.",
            }
  • The 'terminal_close' tool is registered using the '@mcp.tool' decorator with the name 'terminal_close' and relevant metadata annotations.
    @mcp.tool(
        name="terminal_close",
        annotations={
            "title": "Close Terminal",
            "readOnlyHint": False,
            "destructiveHint": True,
            "idempotentHint": True,
            "openWorldHint": False,
        },
    )
Behavior4/5

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

The description adds valuable behavioral context beyond annotations: it mentions 'cleans up associated resources,' which clarifies the scope of the destructive action hinted at by destructiveHint=true. It also notes the return format ('dict: Contains success status and message'), providing output expectations not covered by annotations. No contradictions with annotations exist.

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

Conciseness5/5

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

The description is well-structured and front-loaded with the core purpose, followed by details on behavior, args, and returns. Each sentence adds value without redundancy, making it efficient and easy to parse for an AI agent.

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

Completeness4/5

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

Given the tool's complexity (destructive action with one parameter), annotations cover safety and idempotency, and the description adds behavioral and output details. However, without an output schema, the description could more fully explain return values (e.g., specific keys in the dict). It is mostly complete but has minor gaps.

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 description adds minimal semantics for the single parameter ('The terminal session ID to close'), but schema description coverage is 0%, so the schema provides no details. The description compensates slightly by explaining the parameter's role, but it lacks format or source guidance (e.g., from terminal_list). Baseline is 3 due to low schema coverage and partial compensation.

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 clearly states the specific action ('Close a terminal session') and resource ('terminal window and associated resources'), distinguishing it from sibling tools like terminal_create_or_get (create/get), terminal_get_output (read output), terminal_list (list sessions), and terminal_send_input (send input). It provides a complete picture of what the tool does.

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

Usage Guidelines4/5

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

The description implies usage context by specifying it closes a terminal session, suggesting it should be used when a session is no longer needed. However, it does not explicitly state when not to use it (e.g., while actively using the terminal) or name alternatives like terminal_list to find session IDs, leaving some guidance gaps.

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/Hor1zonZzz/terminal-mcp'

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