DEV Community

Uwe c
Uwe c

Posted on

Screenshots cost 25,000 tokens. I got it down to 750.

A single screenshot in an AI conversation eats 25,000 tokens. That's more than most code searches, file reads, and tool calls combined.

I've been building AiDex, an MCP server that gives AI coding assistants a persistent code index. But screenshots kept blowing up the context — even after I'd optimized everything else.

So I asked myself: does an AI really need 16 million colors to read an error message?

The answer is no

Most screenshots in AI context are for reading text — error messages, stack traces, UI labels, terminal output. Black and white at half resolution is plenty.

v1.13 adds two new parameters to aidex_screenshot:

aidex_screenshot({ scale: 0.5, colors: 2 })
Enter fullscreen mode Exit fullscreen mode

That's it. Half resolution, two colors.

Result: 108 KB → 5 KB. 95% reduction.

The numbers

Raw Screenshot Optimized
File size 100-500 KB 5-15 KB
Tokens 5,000-25,000 250-750
Colors 16 million 2 (black & white)
Text readable? Yes Yes

The text stays perfectly readable. You lose the pretty colors, but the AI doesn't care about your VS Code theme.

The clever part: AI decides the quality

The tool description tells AI assistants to optimize automatically:

  1. Start aggressivescale: 0.5, colors: 2 (B&W, half size)
  2. Can't read it? — Retry with colors: 16 (adds shading)
  3. Still unclear?scale: 0.75 or full color
  4. Remember — Cache what works per app for the session

So the AI learns: "Terminal screenshots work fine in B&W, but that Figma mockup needs 256 colors." No configuration needed.

Available options

Parameter Values Use case
scale 0.1 - 1.0 Resolution. Most HiDPI screens are 2-3x anyway.
colors: 2 B&W Text, terminals, logs
colors: 4 4 shades Text with light UI elements
colors: 16 16 colors Full UI, icons visible
colors: 256 256 colors Near-photographic quality

Cross-platform

Works on Windows (PowerShell + System.Drawing), macOS (sips + ImageMagick), and Linux (ImageMagick). The screenshot is captured at full quality first, then post-processed — so you never lose data.

Part of a bigger picture

This is part of AiDex, an MCP server with 27 tools for AI coding assistants. The core idea: stop wasting tokens on navigation.

  • Code search — 50 tokens instead of 2,000+ (vs grep)
  • Method signatures — See all methods without reading the file
  • Global search — Search across ALL your projects at once (v1.11)
  • Zero-confignpm install -g aidex-mcp and it just works (v1.12)
  • Screenshot optimization — 95% smaller images for LLM context (v1.13)

Try it

npm install -g aidex-mcp
Enter fullscreen mode Exit fullscreen mode

That's literally it. Auto-setup detects your AI tools (Claude Code, Claude Desktop, Cursor, Windsurf, Gemini CLI, VS Code Copilot) and registers AiDex.

Then ask your AI to take a screenshot:

aidex_screenshot({ mode: "active_window", scale: 0.5, colors: 2 })
Enter fullscreen mode Exit fullscreen mode

GitHub: CSCSoftware/AiDex | npm: aidex-mcp | MIT licensed

What's your experience with screenshot token costs? I'd love to hear if you've found other ways to reduce context usage.

Top comments (0)