Skip to main content
Glama
ferrislucas

iTerm MCP Server

by ferrislucas

send_control_character

Send control characters (e.g., Control-C or telnet escape) to the active iTerm terminal for managing processes or executing commands directly within the terminal session.

Instructions

Sends a control character to the active iTerm terminal (e.g., Control-C, or special sequences like ']' for telnet escape)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
letterYesThe letter corresponding to the control character (e.g., 'C' for Control-C, ']' for telnet escape)

Implementation Reference

  • Core implementation of the send_control_character tool: maps input letter to control code (with special cases for ']' and 'ESC'), constructs iTerm2 AppleScript, and executes it using osascript to send the character.
    async send(letter: string): Promise<void> {
      let controlCode: number;
      
      // Handle special cases for telnet escape sequences
      if (letter.toUpperCase() === ']') {
        // ASCII 29 (GS - Group Separator) - the telnet escape character
        controlCode = 29;
      } 
      // Add other special cases here as needed
      else if (letter.toUpperCase() === 'ESCAPE' || letter.toUpperCase() === 'ESC') {
        // ASCII 27 (ESC - Escape)
        controlCode = 27;
      }
      else {
        // Validate input for standard control characters
        letter = letter.toUpperCase();
        if (!/^[A-Z]$/.test(letter)) {
          throw new Error('Invalid control character letter');
        }
        
        // Convert to standard control code (A=1, B=2, etc.)
        controlCode = letter.charCodeAt(0) - 64;
      }
    
      // AppleScript to send the control character
      const ascript = `
        tell application "iTerm2"
          tell front window
            tell current session of current tab
              -- Send the control character
              write text (ASCII character ${controlCode})
            end tell
          end tell
        end tell
      `;
    
      try {
        await this.executeCommand(`osascript -e '${ascript}'`);
      } catch (error: unknown) {
        throw new Error(`Failed to send control character: ${(error as Error).message}`);
      }
    }
  • Input schema for the tool, defining 'letter' as required string parameter.
    inputSchema: {
      type: "object",
      properties: {
        letter: {
          type: "string",
          description: "The letter corresponding to the control character (e.g., 'C' for Control-C, ']' for telnet escape)"
        },
      },
      required: ["letter"]
    }
  • src/index.ts:57-69 (registration)
    Registration of the tool in the MCP server's ListTools response, including name, description, and input schema.
      name: "send_control_character",
      description: "Sends a control character to the active iTerm terminal (e.g., Control-C, or special sequences like ']' for telnet escape)",
      inputSchema: {
        type: "object",
        properties: {
          letter: {
            type: "string",
            description: "The letter corresponding to the control character (e.g., 'C' for Control-C, ']' for telnet escape)"
          },
        },
        required: ["letter"]
      }
    }
  • MCP CallTool request handler dispatch for send_control_character: instantiates the class and calls send() with the letter argument, returns confirmation message.
    case "send_control_character": {
      const ttyControl = new SendControlCharacter();
      const letter = String(request.params.arguments?.letter);
      await ttyControl.send(letter);
      
      return {
        content: [{
          type: "text",
          text: `Sent control character: Control-${letter.toUpperCase()}`
        }]
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions the tool sends control characters to an 'active iTerm terminal', implying it requires an active terminal session, but doesn't disclose behavioral traits like whether it's read-only, destructive, requires specific permissions, or how it handles errors. The description is minimal and lacks crucial operational context.

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 a single, efficient sentence that front-loads the core purpose with helpful examples. It avoids redundancy, though it could be slightly more structured by separating usage context from examples.

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

Completeness2/5

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

Given no annotations, no output schema, and a tool that interacts with a terminal (potentially involving side effects), the description is incomplete. It doesn't explain what happens after sending the character (e.g., terminal response, error handling), or clarify dependencies like needing an active session. More context is needed for safe and effective use.

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?

Schema description coverage is 100%, with the parameter 'letter' fully documented in the schema. The description adds minimal value by reinforcing examples (e.g., 'C' for Control-C), but doesn't provide additional semantics beyond what the schema already states. Baseline 3 is appropriate given high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('sends a control character') and target ('to the active iTerm terminal'), with specific examples like Control-C and telnet escape. It distinguishes from sibling tools by focusing on control characters rather than reading or writing general text, though it doesn't explicitly contrast with siblings.

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 for sending control sequences in a terminal context, but doesn't explicitly state when to use this tool versus alternatives like 'write_to_terminal' for regular text or 'read_terminal_output' for monitoring. No guidance on prerequisites or exclusions is provided.

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

Related 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/ferrislucas/iterm-mcp'

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