send_key
Submit terminal commands by sending key presses to interactive programs like Claude sessions after text input.
Instructions
Send a key press to a terminal surface. Use this after send_input to reliably submit commands — especially when targeting interactive programs like Claude sessions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| surface | Yes | Target surface ref | |
| key | Yes | Key name (e.g. 'return', 'escape', 'tab') | |
| workspace | No | Target workspace ref |
Implementation Reference
- src/server.ts:331-339 (handler)The tool handler for "send_key" which invokes the client's sendKey method.
async (args) => { try { await client.sendKey(args.surface, args.key, { workspace: args.workspace, }); return ok({ surface: args.surface, applied: "send_key" }); } catch (e) { return err(e); } - src/server.ts:323-330 (registration)Registration of the "send_key" MCP tool in server.ts.
server.tool( "send_key", "Send a key press to a terminal surface. Use this after send_input to reliably submit commands — especially when targeting interactive programs like Claude sessions.", { surface: z.string().describe("Target surface ref"), key: z.string().describe("Key name (e.g. 'return', 'escape', 'tab')"), workspace: z.string().optional().describe("Target workspace ref"), }, - src/cmux-client.ts:229-238 (handler)The client-side implementation of sendKey which sends the "send-key" command to the cmux process.
async sendKey( surface: string, key: string, opts?: { workspace?: string }, ): Promise<void> { const args = ["send-key", "--surface", surface]; if (opts?.workspace) args.push("--workspace", opts.workspace); args.push(key); await this.run(args); }