Skip to main content
Glama
LukeLamb

claude-linux-mcp

key_press

Destructive

Press keyboard combinations (e.g., ctrl+c, alt+Tab) using xdotool keysym notation for desktop automation.

Instructions

Press a keyboard combination using xdotool's keysym notation. Examples: 'ctrl+c', 'alt+Tab', 'super', 'Return', 'Escape', 'Page_Down'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
comboYes

Implementation Reference

  • The key_press handler function. Uses xdotool to press a keyboard combination (e.g. 'ctrl+c', 'alt+Tab'). Validates that args.combo is a non-empty string, then spawns 'xdotool key -- <combo>'. Returns the combo on success or an error result on failure.
    // ─── Tool: key_press ──────────────────────────────────────────────────────
    async function keyPress(args) {
      const missing = requireBin('xdotool');
      if (missing) return errorResult(missing);
      if (typeof args.combo !== 'string' || !args.combo) return errorResult('combo is required (e.g. "ctrl+c")');
      const r = await run(BIN.xdotool, ['key', '--', args.combo]);
      if (r.code !== 0) return errorResult(`key_press failed: ${r.stderr || r.stdout}`);
      return textResult({ combo: args.combo });
    }
  • Input schema for the 'key_press' tool. Defines a single required string property 'combo' (e.g. 'ctrl+c', 'Return', 'Escape'). Also includes the description and annotations.
    {
      name: 'key_press',
      description: "Press a keyboard combination using xdotool's keysym notation. Examples: 'ctrl+c', 'alt+Tab', 'super', 'Return', 'Escape', 'Page_Down'.",
      annotations: { title: 'Press keys', destructiveHint: true },
      inputSchema: {
        type: 'object',
        properties: { combo: { type: 'string' } },
        required: ['combo'],
      },
  • server.js:564-564 (registration)
    Registration of the key_press tool in the HANDLERS map, mapping the tool name 'key_press' to the keyPress function.
    key_press: keyPress,
  • The run() helper function used by keyPress to spawn xdotool. It spawns a child process, collects stdout/stderr, and returns the exit code and output.
    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]); });
        if (opts.stdin !== undefined) {
          child.stdin.end(opts.stdin);
        } else {
          child.stdin.end();
        }
        child.on('error', (e) => resolve({ code: -1, stdout: '', stderr: e.message }));
        child.on('close', (code) => resolve({
          code,
          stdout: out.toString('utf8'),
          stderr: err.toString('utf8'),
        }));
      });
    }
  • The requireBin() helper used by keyPress to check if 'xdotool' is installed before attempting to run it.
    // ─── Helpers ──────────────────────────────────────────────────────────────
    function requireBin(name) {
      if (!BIN[name]) {
        return `Required system tool "${name}" is not installed. Install with: sudo apt install ${name === 'gnomeShot' ? 'gnome-screenshot' : name === 'xclip' ? 'xclip' : name === 'xdotool' ? 'xdotool' : 'wmctrl'}`;
      }
      return null;
    }
Behavior3/5

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

Annotations already set destructiveHint=true, so the description does not need to emphasize destructiveness. It adds value by specifying the notation (xdotool's keysym) but could disclose side effects like focus changes or system-level impact. With annotations covering the safety profile, a 3 is appropriate.

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?

The description is very concise: two sentences with no wasted words. It front-loads the action and notation, then immediately provides examples. Every sentence earns its place.

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?

For a simple tool with one parameter and no output schema, the description is fairly complete. It covers the action, notation, and examples. Minor omission: it doesn't state that the press is instantaneous or that it simulates press and release. Still, it's sufficient given the tool's simplicity.

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

Parameters4/5

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

Schema coverage for the 'combo' parameter is 0%, so the description must compensate. It does so by providing examples and explicitly mentioning 'xdotool's keysym notation', which clarifies the format expected. This adds significant semantic value beyond the bare schema.

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 it presses a keyboard combination using xdotool's keysym notation, with concrete examples. It specifies the verb 'Press' and the resource 'keyboard combination', making it unambiguous and distinct from siblings like type_text or mouse_click.

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

Usage Guidelines2/5

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

The description provides examples but offers no guidance on when to use this tool versus alternatives like type_text (for typing strings) or mouse_actions. There is no mention of when not to use it, prerequisites, or exclusions, which limits its helpfulness for selection decisions.

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-linux-mcp'

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