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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

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)}
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions sending input and a return dictionary, but lacks critical behavioral details such as whether this is a read-only or mutating operation, error handling (e.g., invalid session_id), rate limits, or how input_text and key interact (e.g., if both are provided). The description doesn't disclose enough about the tool's behavior beyond basic functionality.

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 well-structured with a clear purpose statement followed by Args and Returns sections. It's appropriately sized and front-loaded, with each sentence adding value. Minor improvements could include integrating the sections more fluidly, but overall it's efficient with minimal waste.

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 moderate complexity (3 parameters, no annotations, but has an output schema), the description is fairly complete. It covers the purpose, parameters, and return value. The output schema exists, so the description doesn't need to detail return values, but it could improve by addressing behavioral aspects like error cases or interaction between input_text and key.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates by explaining all three parameters: session_id (ID of the terminal session), input_text (text to type for alphanumeric input), and key (special key like Return, Tab, Escape). It adds meaningful context beyond the schema's titles, clarifying the purpose and usage of each parameter, though it could detail allowed values for 'key' more explicitly.

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 ('Send input to a terminal session') and resource ('terminal session'), distinguishing it from siblings like terminal_capture (capture output), terminal_close (end session), and terminal_launch (start session). The verb 'send input' precisely defines the tool's function.

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

Usage Guidelines3/5

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

The description implies usage by mentioning 'terminal session' and parameters like 'input_text' and 'key', but doesn't explicitly state when to use this tool versus alternatives. For example, it doesn't clarify if this should be used for all terminal input or only specific scenarios, nor does it mention prerequisites like needing an active session from terminal_launch.

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