Skip to main content
Glama
ferrislucas

iTerm MCP Server

by ferrislucas

send_control_character

Send a control character to the active iTerm terminal, such as Control-C to interrupt or ']' for telnet escape.

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

  • The `send()` method on the SendControlCharacter class executes the tool logic: it converts a letter to a control code (Ctrl+A=1, etc.), handles special cases for ']' (telnet escape, ASCII 29) and ESC (ASCII 27), then uses AppleScript via osascript to send the control character to iTerm2.
    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}`);
      }
    }
  • The CallToolRequestSchema handler case for 'send_control_character': instantiates SendControlCharacter, calls send() with the 'letter' argument, and returns a 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()}`
        }]
      };
    }
  • Tool registration with input schema under ListToolsRequestSchema: defines the 'send_control_character' tool with required 'letter' (string) parameter, describing it as sending control characters (e.g., Control-C, telnet escape) to the active iTerm terminal.
      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"]
      }
    }
  • src/index.ts:11-11 (registration)
    Import statement registering the SendControlCharacter class from './SendControlCharacter.js'.
    import SendControlCharacter from "./SendControlCharacter.js";
  • Helper method `executeCommand()` that wraps exec with promisify, used by send() to run the osascript command.
    protected async executeCommand(command: string): Promise<void> {
      await execPromise(command);
    }
Behavior2/5

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

No annotations provided. Description only states action, does not disclose side effects (e.g., interrupting processes), permissions, or return behavior. Minimal behavioral insight beyond the action itself.

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?

Single concise sentence with all essential information: action, target, examples. No wasted words; front-loaded with purpose.

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

Completeness3/5

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

Adequate for a simple tool with one parameter and no output schema. Covers basic purpose and examples, but lacks behavioral details or usage context that would make it fully complete.

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?

Schema coverage 100% with description for 'letter'. Description adds examples ('C' for Control-C, ']' for telnet escape) and clarifies 'special sequences', enriching meaning beyond schema.

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?

Description clearly states the tool sends a control character to the active iTerm terminal, with specific examples (Control-C, telnet escape). It differentiates from siblings: write_to_terminal sends text, read_terminal_output reads output.

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?

Provides examples of when to use (control characters, special sequences). Implicitly contrasts with write_to_terminal for regular text. Could explicitly state not to use for typing text, but adequate guidance.

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

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