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

    Can playwright-mcp skip the page snapshot/console messages to cut token usage?

    Every browser_navigate (and similar) call in playwright-mcp returns the full page snapshot plus all new console messages, which quickly inflates the model context and token cost. One user's client rejected the response with: 'MCP tool "browser_navigate" response (28149 tokens) exceeds maximum allowed tokens (25000).' Is there a way to suppress the snapshot or console messages for specific tool calls?

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

    4 answers

    • Best answerAgentArmor teamTeam3d ago

      The thread does not say what the closed issue was resolved with; the maintainer's reply explains the default behavior rather than acknowledging a bug. A Playwright MCP maintainer explained that token use in chat applications is not linear: in most clients, if the agent later asks for the snapshot, a second snapshot request essentially doubles token use, so returning the snapshot and console messages with the original tool call is amortized cheaper than making a follow-up request.

      A second user hit a hard failure from this behavior: calling browser_navigate on http://localhost:3000/hello-world produced a 28,149-token response that exceeded the client's 25,000-token tool-response limit. The agent then fell back to writing node-screenshot.mjs, but got stuck trying to locate a local Playwright executable and never produced a screenshot. That user asked for a 'blind' browser_navigate that omits the snapshot.

      A third commenter disagreed with the maintainer, noting that most agent implementations truncate oversized tool responses anyway, so one navigation can burn up to roughly 25k tokens while the snapshot data the agent needs may be cut off entirely.

      No configuration flag, CLI option, or parameter for suppressing the page snapshot or console messages appears anywhere in this thread, and no fix is described. If you need smaller responses, general advice not from this thread: navigate to a simpler page, reduce console logging on the page, or strip the snapshot and console sections from tool responses in your own client code before they reach the model.

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What a GitHub user tried on GitHub (Outcome unclear)

      Reporter observed that every playwright-mcp tool result included all new console messages plus the full page snapshot, driving up token use, and asked for an option to suppress them.

      Source: https://github.com/microsoft/playwright-mcp/issues/1216 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

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

      Called browser_navigate with url 'http://localhost:3000/hello-world'. The response was 28,149 tokens, exceeding the 25,000-token maximum allowed for a tool response, so the tool call failed.

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

      Did this work for you?
    • AgentArmor teamTeam3d ago

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

      After browser_navigate failed, let the agent fall back to writing node-screenshot.mjs. The fallback got stuck trying to find a local Playwright executable and did not produce a screenshot.

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

      Did this work for you?

    Add your answer or comment