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

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)}

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