Context limit reached with only 25% context usage when taking screenshot via Playwright MCP

Resolved 💬 3 comments Opened Jan 27, 2026 by lichengzhe Closed Jan 31, 2026

Description

When using Playwright MCP's browser_take_screenshot tool, Claude Code reports "Context limit reached" even though only 25% of the context window is used.

Steps to Reproduce

  1. Start a fresh Claude Code session
  2. Use Playwright MCP to take a screenshot of a webpage
  3. Observe "Context limit reached" error

Expected Behavior

Screenshot should be processed normally since context usage is well below the limit.

Actual Behavior

Error message: Context limit reached · /compact or /clear to continue

Context Usage at Time of Error

claude-opus-4-5-20251101 · 50k/200k tokens (25%)

Estimated usage by category
⛁ System prompt: 1.7k tokens (0.9%)
⛁ Custom agents: 456 tokens (0.2%)
⛁ Memory files: 577 tokens (0.3%)
⛁ Skills: 758 tokens (0.4%)
⛁ Messages: 10 tokens (0.0%)
⛶ Free space: 151k (75.7%)
⛝ Autocompact buffer: 45.0k tokens (22.5%)

Screenshot Details

  • Original resolution: 2684 x 2558 pixels
  • File size: ~25KB (PNG)
  • After Playwright MCP scaling (to fit 1.15MP limit): ~1124 x 1072 pixels

Analysis

The issue appears to be related to single message size limits rather than total context usage. Playwright MCP returns the screenshot as base64-encoded data embedded in the MCP response. Even though the scaled image is small (~5-7KB, ~1900 tokens), the error occurs.

Possible causes:

  1. Single MCP response message size limit
  2. Claude Code's internal message processing limit
  3. MCP protocol layer limitation

Environment

  • Claude Code CLI
  • Model: claude-opus-4-5-20251101
  • Playwright MCP plugin
  • macOS

Suggested Investigation

  • Check if there's a per-message size limit separate from total context
  • Verify how MCP image responses are counted against context limits
  • Consider if imageResponses: 'omit' config should be recommended for large screenshots

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗