Skip to main content
Glama
taskhub-sh

Terminal Control MCP

by taskhub-sh

terminal_close

Close terminal sessions and release system resources to maintain performance and prevent memory leaks in terminal-based applications.

Instructions

Close a terminal session and cleanup resources

Args: session_id: ID of the terminal session

Returns: Dictionary with cleanup status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `terminal_close` tool handler: an async function decorated with `@mcp.tool()` that closes a terminal session by invoking cleanup on the associated XTermSession instance and removing it from the global sessions dictionary. Handles errors and returns status.
    @mcp.tool()
    async def terminal_close(session_id: str) -> Dict[str, Any]:
        """Close a terminal session and cleanup resources
    
        Args:
            session_id: ID of the terminal session
    
        Returns:
            Dictionary with cleanup status
        """
        if session_id not in sessions:
            return {"status": "error", "error": f"Session {session_id} not found"}
    
        session = sessions[session_id]
    
        try:
            await session.cleanup()
            del sessions[session_id]
    
            logger.info(f"Closed terminal session {session_id}")
            return {"session_id": session_id, "status": "closed"}
    
        except Exception as e:
            logger.error(f"Failed to close session {session_id}: {e}")
            return {"status": "error", "error": str(e)}
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the action ('close') and a behavioral trait ('cleanup resources'), which implies resource management, but does not detail what cleanup entails (e.g., freeing memory, terminating processes), potential side effects, or error conditions. It adds some value but lacks depth for a mutation tool.

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 front-loaded with the core purpose in the first sentence, followed by structured sections for Args and Returns. Every sentence earns its place by providing essential information without redundancy, making it efficient and well-organized.

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 (a mutation with cleanup), no annotations, and an output schema (which handles return values), the description is reasonably complete. It covers purpose, parameters, and returns, but could improve by adding more behavioral context (e.g., what happens on failure) to fully compensate for the lack of annotations.

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 0%, so the description must compensate. It adds meaning by explaining that 'session_id' is the 'ID of the terminal session', which clarifies its role beyond the schema's basic type. However, it does not provide format details, examples, or constraints, leaving gaps in parameter understanding.

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 cleanup resources') with the target resource ('terminal session'), distinguishing it from sibling tools like terminal_launch (create), terminal_input (send input), and terminal_capture (capture output). The verb 'close' and resource 'terminal session' are unambiguous.

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 'close a terminal session', suggesting it should be used when a session is no longer needed, but it does not explicitly state when not to use it or name alternatives. The context is clear but lacks explicit exclusions or comparisons to siblings.

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/taskhub-sh/terminal-driver-mcp'

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