Skip to main content
Glama

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
NameRequiredDescriptionDefault
surfaceYesTarget surface ref
keyYesKey name (e.g. 'return', 'escape', 'tab')
workspaceNoTarget workspace ref

Implementation Reference

  • 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"),
      },
  • 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);
    }

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/EtanHey/cmuxlayer'

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