Skip to main content
Glama
LukeLamb

claude-sessions-mcp

send_keys

Destructive

Send key combos or literal text to a tmux session's active pane, useful for interrupts, end-of-input, or typing commands. Enter appended by default; set enter=false for raw combos.

Instructions

Send key combos or text to the session's active pane. Use for interrupts (C-c), end-of-input (C-d), or typing a command. Text is sent literally. Enter is appended by default; set enter=false for raw key combos.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesSession name.
keysYesKey combo (e.g. "C-c", "C-d", "Escape") or literal text to type.
enterNoAppend an Enter keypress after the keys. Default true.

Implementation Reference

  • The sendKeys function implements the 'send_keys' tool logic. It validates inputs (tmux availability, session name, keys), constructs a tmux send-keys command targeting the session's active pane, optionally appends an Enter keypress (default true), executes it via spawn, and returns success/failure.
    // ─── Tool: send_keys ──────────────────────────────────────────────────────
    async function sendKeys(args) {
      const missing = requireTmux();
      if (missing) return errorResult(missing);
      const bad = validSessionName(args.name);
      if (bad) return errorResult(bad);
      if (typeof args.keys !== 'string' || !args.keys.length) {
        return errorResult('keys is required (non-empty string)');
      }
      // When `enter` is true (default for text input), append an Enter keypress.
      // For raw key combos like 'C-c' you usually want enter=false.
      const appendEnter = args.enter !== false;
      // `=NAME:` targets the session's active pane with exact name match.
      const cmd = ['send-keys', '-t', `=${args.name}:`, args.keys];
      if (appendEnter) cmd.push('Enter');
      const r = await run(BIN.tmux, cmd);
      if (r.code !== 0) return errorResult(`tmux send-keys failed: ${r.stderr || r.stdout}`);
      return textResult({ session: args.name, keys: args.keys, enter: appendEnter });
    }
  • The input schema for 'send_keys' tool registration. Defines the expected parameters: name (string, required), keys (string, required), and enter (boolean, optional, default true). Includes description, annotations, and additionalProperties: false.
    {
      name: 'send_keys',
      description: 'Send key combos or text to the session\'s active pane. Use for interrupts (C-c), end-of-input (C-d), or typing a command. Text is sent literally. Enter is appended by default; set enter=false for raw key combos.',
      annotations: { title: 'Send keys to session', readOnlyHint: false, destructiveHint: true, openWorldHint: true },
      inputSchema: {
        type: 'object',
        properties: {
          name: { type: 'string', description: 'Session name.' },
          keys: { type: 'string', description: 'Key combo (e.g. "C-c", "C-d", "Escape") or literal text to type.' },
          enter: { type: 'boolean', description: 'Append an Enter keypress after the keys. Default true.' },
        },
        required: ['name', 'keys'],
        additionalProperties: false,
      },
    },
  • server.js:326-333 (registration)
    The HANDLERS map that registers the sendKeys function under the key 'send_keys'. This is used by the tools/call dispatcher to route incoming requests.
    const HANDLERS = {
      list_sessions: listSessions,
      has_session: hasSession,
      list_windows: listWindows,
      capture_pane: capturePane,
      new_session: newSession,
      send_keys: sendKeys,
      kill_session: killSession,
  • The run function is a helper that spawns a child process and returns stdout/stderr/exit code. Used by sendKeys to execute 'tmux send-keys ...' via spawn.
    function run(cmd, args, opts = {}) {
      return new Promise((resolve) => {
        const child = spawn(cmd, args, { stdio: ['pipe', 'pipe', 'pipe'], ...opts });
        let out = Buffer.alloc(0);
        let err = Buffer.alloc(0);
        child.stdout.on('data', (d) => { out = Buffer.concat([out, d]); });
        child.stderr.on('data', (d) => { err = Buffer.concat([err, d]); });
        child.on('error', (e) => resolve({ code: -1, stdout: '', stderr: e.message }));
        child.stdin.end();
        child.on('close', (code) => resolve({
          code,
          stdout: out.toString('utf8'),
          stderr: err.toString('utf8'),
        }));
      });
    }
Behavior4/5

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

Annotations indicate destructive and open-world hints; the description adds detail: text is sent literally, Enter appended by default, and raw combos require enter=false. No contradictions.

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?

Three concise sentences, front-loaded with purpose, then specific guidelines. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers key behavioral aspects; lacks description of return values, but given no output schema and the nature of the action (send), this is acceptable. Sibling tools are listed for context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema covers 100% of parameters; description enriches meaning by explaining literal sending and enter default behavior, going beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb (send), resource (key combos or text to session's active pane), and specific use cases (interrupts, end-of-input, typing a command). It distinguishes from sibling tools like capture_pane or kill_session.

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

Usage Guidelines4/5

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

Provides clear when-to-use guidance (interrupts, end-of-input, typing) and explains the enter parameter behavior. Does not explicitly mention when not to use or alternatives among siblings, but sibling tools are sufficiently different.

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/LukeLamb/claude-sessions-mcp'

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