You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(mcp): add --output-max-size with post-response disk eviction (draft)
Alternative to #41021 implementing Pavel's suggestion: instead of
intercepting writes in code with an OutputFile/OutputDir layer, let
tools write whatever and prune the outputDir from disk after each
tool call.
After Response.serialize() builds its sections, _enforceOutputBudget
recursively lists outputDir, sorts by mtime ascending, and unlinks
oldest files until total <= outputMaxSize. Files written by the
current Response are tracked in _writtenFiles and never evicted, so
artifacts referenced in the response stay readable.
Config: same outputMaxSize field, --output-max-size CLI flag, and
PLAYWRIGHT_MCP_OUTPUT_MAX_SIZE env var as #41021.
Trade-offs vs #41021:
- ~74 lines added vs ~390; no new types or evictable plumbing.
- Trace/sessionLog need no special-casing — their mtime bumps keep
them young, naturally last to evict.
- Sees externally-written files (downloads, trace bundles) — they
count against the budget and evict by age.
- Self-healing on external fs changes.
- Cap can briefly exceed during a single tool call that writes a
large artifact; #41021 pre-evicts so the cap is hard.
- Weaker pin guarantee for session.md (recency-based, not flag-based).
Copy file name to clipboardExpand all lines: packages/playwright-core/src/tools/mcp/program.ts
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,7 @@ export function decorateMCPCommand(command: Command) {
59
59
.option('--image-responses <mode>','whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".',enumParser.bind(null,'--image-responses',['allow','omit']))
60
60
.option('--no-sandbox','disable the sandbox for all process types that are normally sandboxed.')
61
61
.option('--output-dir <path>','path to the directory for output files.')
62
+
.option('--output-max-size <bytes>','Threshold for evicting old output files, in bytes.',numberParser)
62
63
.option('--output-mode <mode>','whether to save snapshots, console messages, network logs to a file or to the standard output. Can be "file" or "stdout". Default is "stdout".',enumParser.bind(null,'--output-mode',['file','stdout']))
63
64
.option('--port <port>','port to listen on for SSE transport.')
64
65
.option('--proxy-bypass <bypass>','comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"')
0 commit comments