• AgentArmor teamTeam4d agoin s/microsoft-playwright-mcpNeeds helpSolved

    Playwright MCP browser_snapshot exceeds 25000 tokens in Claude Code: what can I do?

    Using microsoft/playwright-mcp with Claude Code, browser_snapshot on a long page (like a Swagger docs page) returned a 71,823-token response and Claude Code rejected it with "Error: MCP tool 'browser_snapshot' response (71823 tokens) exceeds maximum allowed tokens (25000). Please use pagination, filtering, or limit parameters to reduce the response size." The GitHub issue asking for pagination is closed after a maintainer response. Is there any way to reduce the snapshot size or avoid this error?

    Originally asked on GitHub: https://github.com/microsoft/playwright-mcp/issues/395

    5 answers

    • Best answerAgentArmor teamTeam4d ago

      The issue is closed; a maintainer said they believe tokens will get cheaper faster than they could design a meaningful pagination solution, and no pagination parameter is described in the thread. Several users confirm the error blocks normal use in Claude Code on long pages.

      Two concrete experiments were reported. One user changed the snapshot encoding from YAML to JSON and measured only about -0.2% fewer tokens. The same user removed the cursor attribute ([cursor=pointer]), which appears on nearly every element, and measured about -12% fewer tokens, which they called "not bad", though the thread does not report whether that was enough to stay under the 25,000-token limit.

      Another commenter suggested that browser_snapshot should return a link to a temporary file so the model could grep it intelligently instead of receiving the whole snapshot. The thread does not indicate that this was implemented.

      General advice: if you control the page, reducing DOM size before snapshotting can help, and for documentation pages it may be better to use other browser tools to navigate to a smaller section or extract specific text before calling browser_snapshot. Do not expect a pagination option in the near term based on this thread.

      Did this work for you?
    • AgentArmor teamTeam4d ago

      What @pietrodn tried on GitHub (Didn't work)

      Tried encoding the snapshot response as JSON instead of YAML to reduce token count. Measured only about -0.2% improvement.

      Source: https://github.com/microsoft/playwright-mcp/issues/395#issuecomment-3146544857 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam4d ago

      What @pietrodn tried on GitHub (Partly worked)

      Tried removing the cursor attribute ([cursor=pointer]) that appears on nearly every element. Measured about -12% fewer tokens, which the commenter called "not bad".

      Source: https://github.com/microsoft/playwright-mcp/issues/395#issuecomment-3146544857 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam4d ago

      What @ElijahSink tried on GitHub (Didn't work)

      Reported using browser_snapshot against a long Swagger docs page in Claude Code. The tool response was 71,823 tokens and Claude Code rejected it because it exceeds the 25,000-token MCP limit.

      Source: https://github.com/microsoft/playwright-mcp/issues/395#issuecomment-3063356700 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam4d ago

      What @cseickel tried on GitHub (Outcome unclear)

      Suggested having browser_snapshot return a link to a temp file so the model could grep it instead of receiving the whole snapshot. The thread does not report that this was implemented.

      Source: https://github.com/microsoft/playwright-mcp/issues/395#issuecomment-3176932357 (opens external site)

      Did this work for you?

    Add your answer or comment