From 5e5123d1ac4c9c2acf80efa8fa828af8ff9433f5 Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Mon, 12 Jan 2026 20:30:18 -0700 Subject: [PATCH] feat: add browser_status tool to show mode and capabilities Adds a new browser_status tool that displays: - Current browser mode (isolated/persistent) - Profile path when in persistent mode - Capability matrix (Push API, Notifications, Service Workers, Storage) - Tips for switching modes and customizing profile path This helps MCP clients understand what browser features are available and how to enable full Push API support when needed. --- README.md | 8 ++++ src/tools/configure.ts | 89 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/README.md b/README.md index 08df044..b033b6b 100644 --- a/README.md +++ b/README.md @@ -1155,6 +1155,14 @@ Full API: See MODEL-COLLABORATION-API.md +- **browser_status** + - Title: Get browser status and capabilities + - Description: Get current browser configuration status including mode (isolated/persistent), profile path, and available capabilities like Push API support. + - Parameters: None + - Read-only: **true** + + + - **browser_stop_recording** - Title: Stop video recording - Description: Finalize video recording session and return paths to all recorded video files (.webm format). Automatically closes browser pages to ensure videos are properly saved and available for use. Essential final step for completing video recording workflows and accessing demo files. diff --git a/src/tools/configure.ts b/src/tools/configure.ts index 8c06dac..ff40929 100644 --- a/src/tools/configure.ts +++ b/src/tools/configure.ts @@ -934,6 +934,95 @@ export default [ } }, }), + defineTool({ + capability: 'core', + schema: { + name: 'browser_status', + title: 'Get browser status and capabilities', + description: 'Get current browser configuration status including mode (isolated/persistent), profile path, and available capabilities like Push API support.', + inputSchema: z.object({}), + type: 'readOnly', + }, + handle: async (context: Context, _params: unknown, response: Response) => { + const config = context.config; + const browserConfig = config.browser; + + const isIsolated = browserConfig.isolated; + const mode = isIsolated ? 'isolated (incognito-like)' : 'persistent'; + + // Build status report + const lines: string[] = [ + '## 🌐 Browser Status', + '', + '### Mode', + `**${mode.toUpperCase()}**`, + '', + ]; + + if (isIsolated) { + lines.push( + '⚠️ **Limitations in isolated mode:**', + '- Push API (pushManager.subscribe) is blocked', + '- Service workers don\'t persist across sessions', + '- Browser state is ephemeral', + '', + '💡 **To enable Push API:** Restart with `--no-isolated` flag or set `PLAYWRIGHT_MCP_ISOLATED=false`', + '' + ); + } else { + const profilePath = browserConfig.userDataDir || '~/.cache/ms-playwright/mcp--profile (auto)'; + lines.push( + '✅ **Full capabilities available:**', + '- Push API (pushManager.subscribe) is supported', + '- Service workers persist across sessions', + '- Browser state is retained', + '', + `📁 **Profile path:** \`${profilePath}\``, + '', + '💡 **Custom path:** Use `--user-data-dir ` or `PLAYWRIGHT_MCP_USER_DATA_DIR=`', + '' + ); + } + + // Browser info + const browserName = browserConfig.browserName; + const channel = browserConfig.launchOptions?.channel; + lines.push( + '### Browser', + `- **Type:** ${browserName}${channel ? ` (${channel})` : ''}`, + `- **Headless:** ${browserConfig.launchOptions?.headless ? 'yes' : 'no'}`, + ); + + // Viewport + const viewport = browserConfig.contextOptions?.viewport; + if (viewport) { + lines.push(`- **Viewport:** ${viewport.width}x${viewport.height}`); + } else { + lines.push('- **Viewport:** maximized (null)'); + } + + // Proxy + const proxy = browserConfig.launchOptions?.proxy; + if (proxy) { + lines.push(`- **Proxy:** ${proxy.server}`); + } + + lines.push(''); + + // Capabilities summary + lines.push( + '### Capabilities', + `| Feature | Status |`, + `|---------|--------|`, + `| Push API | ${isIsolated ? '❌ Blocked' : '✅ Available'} |`, + `| Notifications API | ✅ Available |`, + `| Service Workers | ${isIsolated ? '⚠️ Ephemeral' : '✅ Persistent'} |`, + `| Browser Storage | ${isIsolated ? '⚠️ Ephemeral' : '✅ Persistent'} |`, + ); + + response.addResult(lines.join('\n')); + }, + }), offlineModeTest, ];