Skip to main content
Glama
LukeLamb

claude-linux-mcp

focus_window

Destructive

Bring any window to the foreground by specifying part of its title (case-insensitive substring matching).

Instructions

Bring a window matching the given title pattern (substring, case-insensitive per wmctrl) to the foreground.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
title_patternYes

Implementation Reference

  • The handler function for the 'focus_window' tool. Uses wmctrl -a with the given title_pattern to bring a matching window to the foreground.
    async function focusWindow(args) {
      const missing = requireBin('wmctrl');
      if (missing) return errorResult(missing);
      if (!args.title_pattern) return errorResult('title_pattern is required');
      const r = await run(BIN.wmctrl, ['-a', args.title_pattern]);
      if (r.code !== 0) return errorResult(`no window matched "${args.title_pattern}"`);
      return textResult({ matched: args.title_pattern, focused: true });
    }
  • The tool definition/schema for 'focus_window' with the required title_pattern string parameter.
    {
      name: 'focus_window',
      description: 'Bring a window matching the given title pattern (substring, case-insensitive per wmctrl) to the foreground.',
      annotations: { title: 'Focus window', destructiveHint: true },
      inputSchema: {
        type: 'object',
        properties: { title_pattern: { type: 'string' } },
        required: ['title_pattern'],
      },
    },
  • server.js:553-556 (registration)
    Registration of focus_window handler in the HANDLERS map, mapping the tool name to the focusWindow function.
    const HANDLERS = {
      screenshot,
      list_windows: listWindows,
      focus_window: focusWindow,
  • Helper function that checks whether the required binary (wmctrl) is available before executing focus_window.
    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;
    }
  • Helper function that spawns a child process (used to run wmctrl) and captures stdout/stderr.
    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'),
        }));
      });
Behavior4/5

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

The description explains the matching behavior (substring, case-insensitive) beyond the annotation's destructiveHint. It adds value by detailing how the pattern is matched. No contradiction with annotations, though destructiveHint seems misaligned.

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 a single sentence that is front-loaded with the key action and resource. No wasted words; every part is necessary.

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

Completeness5/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 fully complete. It covers the purpose, matching behavior, and implicitly the effect. No gaps remain.

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?

The input schema provides no description for 'title_pattern' (0% coverage). The description compensates by clarifying that it is a substring, case-insensitive pattern. This is essential information for correct invocation.

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 action (bring to foreground) and the resource (window matching title pattern), and specifies matching semantics (substring, case-insensitive). This distinguishes it from sibling tools like close_window or move_window.

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

Usage Guidelines3/5

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

The description implies usage for focusing an existing window but does not explicitly state when to use this tool versus alternatives like list_windows or move_window. No exclusion criteria or prerequisites are provided.

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