Skip to main content
Glama

send_control_character

Send control characters like Control-C to the active iTerm terminal session to interrupt processes or execute terminal commands programmatically.

Instructions

Sends a control character to the active iTerm terminal (e.g., Control-C)

Input Schema

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

Implementation Reference

  • The SendControlCharacter class provides the core handler logic for the send_control_character tool. Its send method validates the input letter, computes the ASCII control code, constructs an AppleScript to send it to the front iTerm2 session, and executes it via osascript.
    class SendControlCharacter {
      async send(letter: string): Promise<void> {
        // Validate input
        letter = letter.toUpperCase();
        if (!/^[A-Z]$/.test(letter)) {
          throw new Error('Invalid control character letter');
        }
    
        // Convert to control code
        const 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 execPromise(`osascript -e '${ascript}'`);
        } catch (error: unknown) {
          throw new Error(`Failed to send control character: ${(error as Error).message}`);
        }
      }
    }
    
    export default SendControlCharacter;
  • src/index.ts:56-69 (registration)
    Registration of the send_control_character tool in the ListToolsRequestHandler, including name, description, and input schema.
    {
      name: "send_control_character",
      description: "Sends a control character to the active iTerm terminal (e.g., Control-C)",
      inputSchema: {
        type: "object",
        properties: {
          letter: {
            type: "string",
            description: "The letter corresponding to the control character (e.g., 'C' for Control-C)"
          },
        },
        required: ["letter"]
      }
    }
  • The switch case handler in CallToolRequestSchema that dispatches to the SendControlCharacter instance for execution.
    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()}`
        }]
      };
    }
  • Input schema definition for the send_control_character tool, specifying the 'letter' parameter.
    inputSchema: {
      type: "object",
      properties: {
        letter: {
          type: "string",
          description: "The letter corresponding to the control character (e.g., 'C' for Control-C)"
        },
      },
      required: ["letter"]
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Sends') but doesn't clarify effects (e.g., whether it interrupts running commands, requires specific terminal state, or has side effects like closing sessions). The example 'Control-C' hints at interruption, but explicit behavioral traits like permissions or terminal requirements are missing.

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?

The description is a single, efficient sentence that front-loads the core action with a clarifying example. There is no wasted text, and it directly addresses the tool's purpose without unnecessary elaboration, making it highly concise and well-structured.

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 the complexity of a tool that interacts with a terminal (potentially affecting running processes), the description is incomplete. With no annotations and no output schema, it lacks details on behavioral impact, error conditions, or return values. The example helps but doesn't cover broader usage or constraints, leaving gaps for safe and effective tool invocation.

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?

The schema description coverage is 100%, with the parameter 'letter' fully documented in the schema. The description adds minimal value by providing an example ('C' for Control-C), which reinforces the schema but doesn't elaborate on semantics like valid letters, case sensitivity, or special characters beyond what the schema implies.

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') and target ('active iTerm terminal'), with a specific example ('Control-C') that clarifies the type of operation. It distinguishes from sibling tools like 'read_terminal_output' and 'write_to_terminal' by focusing on control characters rather than reading or writing text. However, it doesn't explicitly mention what resource is being affected beyond the terminal.

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

Usage Guidelines2/5

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

No explicit guidance is provided on when to use this tool versus alternatives. The description implies usage for sending control characters, but doesn't specify scenarios (e.g., interrupting processes, sending signals) or contrast with sibling tools like 'write_to_terminal' for regular text input. This leaves the agent to infer usage context.

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

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