Skip to main content
Glama

tmux_send_keys

Send keyboard input or commands to tmux terminal sessions for automation, with optional Enter key simulation for command execution.

Instructions

Send keys/commands to a tmux session. Automatically appends Enter unless literal mode is specified.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_nameYesName of the tmux session
keysYesKeys or command to send to the session
literalNoIf true, send keys literally without appending Enter (default: false)

Implementation Reference

  • The main handler function for the 'tmux_send_keys' tool. It destructures the arguments, builds a tmux send-keys command (escaping quotes in keys), optionally appends 'Enter' if literal is false, executes it via execAsync, and returns a success message or throws an error.
    async sendKeys(args) {
      const { session_name, keys, literal = false } = args;
    
      try {
        let cmd = `tmux send-keys -t "${session_name}" "${keys.replace(
          /"/g,
          '\\"'
        )}"`;
    
        if (!literal) {
          cmd += " Enter";
        }
    
        await execAsync(cmd);
    
        return {
          content: [
            {
              type: "text",
              text: `Sent keys to session ${session_name}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to send keys: ${error.message}`);
      }
    }
  • The input schema for the tmux_send_keys tool, defining required session_name and keys strings, and optional literal boolean.
    inputSchema: {
      type: "object",
      properties: {
        session_name: {
          type: "string",
          description: "Name of the tmux session",
        },
        keys: {
          type: "string",
          description: "Keys or command to send to the session",
        },
        literal: {
          type: "boolean",
          description:
            "If true, send keys literally without appending Enter (default: false)",
        },
      },
      required: ["session_name", "keys"],
    },
  • src/index.js:66-89 (registration)
    Registration of the tmux_send_keys tool in the ListTools response, including name, description, and input schema.
    {
      name: "tmux_send_keys",
      description:
        "Send keys/commands to a tmux session. Automatically appends Enter unless literal mode is specified.",
      inputSchema: {
        type: "object",
        properties: {
          session_name: {
            type: "string",
            description: "Name of the tmux session",
          },
          keys: {
            type: "string",
            description: "Keys or command to send to the session",
          },
          literal: {
            type: "boolean",
            description:
              "If true, send keys literally without appending Enter (default: false)",
          },
        },
        required: ["session_name", "keys"],
      },
    },
  • src/index.js:195-196 (registration)
    Registration/dispatch of the tmux_send_keys tool in the CallToolRequestHandler switch statement, calling the sendKeys method.
    case "tmux_send_keys":
      return await this.sendKeys(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/MediocreTriumph/tmux-mcp'

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