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"] }

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