Implements comprehensive solution for browser_click and other interactive tools
returning massive responses (37K+ tokens) due to full page snapshots.
Features implemented:
1. **Snapshot size limits** (--max-snapshot-tokens, default 10k)
- Automatically truncates large snapshots with helpful messages
- Preserves essential info (URL, title, errors) when truncating
- Shows exact token counts and configuration suggestions
2. **Optional snapshots** (--no-snapshots)
- Disables automatic snapshots after interactive operations
- browser_snapshot tool always works for explicit snapshots
- Maintains backward compatibility (snapshots enabled by default)
3. **Differential snapshots** (--differential-snapshots)
- Shows only changes since last snapshot instead of full page
- Tracks URL, title, DOM structure, and console activity
- Significantly reduces token usage for incremental operations
4. **Enhanced tool descriptions**
- All interactive tools now document snapshot behavior
- Clear guidance on when snapshots are included/excluded
- Helpful suggestions for users experiencing token limits
Configuration options:
- CLI: --no-snapshots, --max-snapshot-tokens N, --differential-snapshots
- ENV: PLAYWRIGHT_MCP_INCLUDE_SNAPSHOTS, PLAYWRIGHT_MCP_MAX_SNAPSHOT_TOKENS, etc.
- Config file: includeSnapshots, maxSnapshotTokens, differentialSnapshots
Fixes token overflow errors while providing users full control over
snapshot behavior and response sizes.
Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive artifact storage system with session-specific directories:
- Add --artifact-dir CLI option and PLAYWRIGHT_MCP_ARTIFACT_DIR env var
- Create ArtifactManager class for session-specific artifact organization
- Implement ArtifactManagerRegistry for multi-session support
- Add tool call logging with JSON persistence in tool-calls.json
- Update screenshot, video, and PDF tools to use centralized storage
- Add browser_configure_artifacts tool for per-session control
- Support dynamic enable/disable without server restart
- Maintain backward compatibility when artifact storage not configured
Directory structure: {artifactDir}/{sessionId}/[artifacts, videos/, tool-calls.json]
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>