Skip to main content
Glama
taskhub-sh

Terminal Control MCP

by taskhub-sh

terminal_input

Send text or keyboard commands to terminal sessions to control TUI applications through simulated input for automated interaction.

Instructions

Send input to a terminal session

Args: session_id: ID of the terminal session input_text: Text to type (for alphanumeric input) key: Special key to send (Return, Tab, Escape, etc.)

Returns: Dictionary with status and input confirmation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes
input_textNo
keyNo

Implementation Reference

  • Handler function for the 'terminal_input' tool. Decorated with @mcp.tool() for automatic registration. Handles sending text input or special keys to a specific terminal session, with error handling for missing sessions.
    @mcp.tool() async def terminal_input( session_id: str, input_text: Optional[str] = None, key: Optional[str] = None ) -> Dict[str, Any]: """Send input to a terminal session Args: session_id: ID of the terminal session input_text: Text to type (for alphanumeric input) key: Special key to send (Return, Tab, Escape, etc.) Returns: Dictionary with status and input confirmation """ if session_id not in sessions: return {"status": "error", "error": f"Session {session_id} not found"} session = sessions[session_id] try: if input_text is not None: await session.send_text(input_text) action = f"typed text: {input_text}" elif key is not None: await session.send_key(key) action = f"sent key: {key}" else: return { "status": "error", "error": "Must provide either input_text or key", } logger.info(f"Session {session_id}: {action}") return {"session_id": session_id, "status": "sent", "action": action} except Exception as e: logger.error(f"Failed to send input to 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