list_tabs
Retrieve all open browser tabs, including their IDs, URLs, titles, and active status. Useful for finding specific pages or obtaining tab identifiers for further automation.
Instructions
Get a list of ALL open browser tabs. Use this to find tab IDs, see what pages are open, or locate a specific website you need to interact with. Returns tab ID, URL, title, and active status.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiKey | No | API key for authentication if enabled |
Implementation Reference
- src/tools/tab-management.ts:12-23 (handler)The handler function for the 'list_tabs' tool. It sends a 'list_tabs' command via the WebSocket bridge and returns the list of browser tabs as formatted JSON.
async ({ apiKey }) => { const result = await bridge.sendCommand({ command: 'list_tabs', params: {}, apiKey, }); if (!result.success) { return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } ); - src/tools/tab-management.ts:6-11 (schema)The tool registration and schema definition for 'list_tabs'. Registers the tool with the MCP server using the McpServer SDK, with an optional 'apiKey' parameter described via Zod schema.
server.tool( 'list_tabs', 'Get a list of ALL open browser tabs. Use this to find tab IDs, see what pages are open, or locate a specific website you need to interact with. Returns tab ID, URL, title, and active status.', { apiKey: z.string().optional().describe('API key for authentication if enabled'), }, - src/tools/index.ts:31-31 (registration)Registration of the tab management tools (including list_tabs) via the registerAllTools function, which is called from createServer in server.ts.
registerTabManagementTools(server, bridge); - src/websocket-bridge.ts:63-103 (helper)The WebSocketBridge.sendCommand helper that the list_tabs handler calls to relay the 'list_tabs' command to the Chrome extension over WebSocket.
async sendCommand(cmd: BridgeCommand): Promise<BridgeResponse> { if (!this.isConnected()) { return { success: false, error: { code: 'NOT_CONNECTED', message: 'Chrome extension is not connected. Ensure the extension is installed, enabled, and the browser is running.', }, }; } const id = crypto.randomUUID(); const timeout = cmd.timeout ?? DEFAULT_TIMEOUT; return new Promise<BridgeResponse>((resolve, reject) => { const timer = setTimeout(() => { this.pending.delete(id); resolve({ success: false, error: { code: 'TIMEOUT', message: `Command '${cmd.command}' timed out after ${timeout}ms`, }, }); }, timeout); this.pending.set(id, { resolve, reject, timer }); const message = { id, type: 'request', command: cmd.command, params: cmd.params, tabId: cmd.tabId, apiKey: cmd.apiKey, timestamp: Date.now(), }; this.client!.send(JSON.stringify(message)); }); }