Skip to main content
Glama
LukeLamb

claude-linux-mcp

screenshot_text

Read-only

Capture a screenshot and extract text using OCR, enabling Claude to read on-screen content like error dialogs or terminal output.

Instructions

Take a screenshot and OCR it with tesseract. Returns the recognized text plus the path to the underlying PNG. Use when Claude needs to READ what is on screen (log windows, error dialogs, terminal output in non-focused windows) rather than just see the image. Requires tesseract-ocr installed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
active_windowNoIf true, capture only the currently-focused window. Default false (full screen).
pathNoOptional target path for the PNG. Defaults to /tmp/claude-linux-mcp/shots/shot-<ts>.png.
langNoTesseract language code (e.g. "eng", "fra", "deu", "nld", or "eng+fra" for multi). Default "eng". Requires the matching tesseract-ocr-<lang> package.

Implementation Reference

  • The handler function `screenshotText` that implements the screenshot_text tool logic. It takes a screenshot (reusing the `screenshot` tool), then runs tesseract OCR on the resulting PNG to extract text. Returns the recognized text, path, size, language used, and text length.
    // ─── Tool: screenshot_text ────────────────────────────────────────────────
    // Take a screenshot, then OCR it with tesseract. Returns the recognized
    // text plus the path to the underlying PNG. Useful when Claude needs to
    // READ what's on screen (log windows, error dialogs, terminal output in
    // non-focused windows) rather than just see the image.
    async function screenshotText(args) {
      if (!BIN.tesseract) {
        return errorResult('tesseract is not installed. Install with: sudo apt install tesseract-ocr tesseract-ocr-eng (add tesseract-ocr-<lang> for other languages).');
      }
      // Reuse the screenshot tool to capture (and inherit its fallback chain).
      const shot = await screenshot({ active_window: args.active_window === true, path: args.path });
      if (shot.isError) return shot;
      // screenshot returns { content: [{ type: 'text', text: JSON.stringify({path, ...}) }] }
      const meta = JSON.parse(shot.content[0].text);
      const lang = (typeof args.lang === 'string' && args.lang.trim()) ? args.lang.trim() : 'eng';
      // tesseract <input> stdout -l <lang> writes plain text to stdout.
      const r = await run(BIN.tesseract, [meta.path, 'stdout', '-l', lang], {
        env: cleanEnv(),
      });
      if (r.code !== 0) {
        return errorResult(`tesseract failed (code ${r.code}): ${r.stderr || r.stdout || 'unknown'}. If lang=${lang} is missing, install tesseract-ocr-${lang}.`);
      }
      const text = (r.stdout || '').replace(/\f$/, '').trimEnd();
      return textResult({
        path: meta.path,
        size_bytes: meta.size_bytes,
        active_window: meta.active_window,
        tool: meta.tool,
        lang,
        text,
        text_length: text.length,
      });
    }
  • Input schema and description for the screenshot_text tool. Defines three optional parameters: active_window (boolean), path (string for output PNG), and lang (string for tesseract language code, default: 'eng').
      {
        name: 'screenshot_text',
        description: 'Take a screenshot and OCR it with tesseract. Returns the recognized text plus the path to the underlying PNG. Use when Claude needs to READ what is on screen (log windows, error dialogs, terminal output in non-focused windows) rather than just see the image. Requires tesseract-ocr installed.',
        annotations: { title: 'Read text from screen (OCR)', readOnlyHint: true },
        inputSchema: {
          type: 'object',
          properties: {
            active_window: { type: 'boolean', description: 'If true, capture only the currently-focused window. Default false (full screen).' },
            path: { type: 'string', description: 'Optional target path for the PNG. Defaults to /tmp/claude-linux-mcp/shots/shot-<ts>.png.' },
            lang: { type: 'string', description: 'Tesseract language code (e.g. "eng", "fra", "deu", "nld", or "eng+fra" for multi). Default "eng". Requires the matching tesseract-ocr-<lang> package.' },
          },
        },
      },
    ];
  • server.js:568-568 (registration)
    Registration of the screenshotText handler in the HANDLERS dispatch map, mapping the tool name 'screenshot_text' to the handler function.
    screenshot_text: screenshotText,
  • Discovery of system binaries including 'tesseract' (line 27) using the `which()` helper, which is checked inside the screenshotText handler before running OCR.
    const BIN = {
      xdotool: which('xdotool'),
      wmctrl: which('wmctrl'),
      xclip: which('xclip'),
      gnomeShot: which('gnome-screenshot'),
      scrot: which('scrot'),
      maim: which('maim'),
      tesseract: which('tesseract'),
    };
Behavior4/5

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

Annotations indicate readOnlyHint=true, and the description confirms it reads the screen. It discloses that it requires external software (tesseract-ocr) and describes the output (text + path). 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 sentences with no wasted words. Front-loaded: action first, then output and usage guidance.

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 purpose, output, usage context, and prerequisites. Lacks details on error handling (e.g., tesseract not installed) but is sufficient given no output schema.

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

Parameters3/5

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

Schema already provides 100% coverage of parameter descriptions. The description adds no additional meaning for parameters beyond what is in the schema. Baseline 3 is appropriate.

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 (take screenshot and OCR), the resource (screen), and the output (recognized text plus PNG path). It distinguishes from sibling tools like screenshot, which likely only captures the image.

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 explicit context for when to use this tool: 'when Claude needs to READ what is on screen' and gives concrete examples (log windows, error dialogs). It does not mention when not to use or alternative tools, but the guidance is clear.

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