list_tabs
Retrieve all open browser tabs with their IDs, URLs, and titles to manage and automate web interactions across multiple pages.
Instructions
List all open browser tabs with their IDs, URLs, and titles
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/tab-tools.ts:15-17 (handler)MCP tool handler for 'list_tabs': calls listTabs() to get all tabs and returns them in a result object.async () => { const tabs = await listTabs(); return handleResult(ok({ tabs }));
- src/schemas.ts:10-10 (schema)Zod schema defining the input for list_tabs tool (empty object since no parameters required).export const listTabsSchema = z.object({});
- src/tools/tab-tools.ts:11-19 (registration)Registers the 'list_tabs' tool with the MCP server, providing name, description, input schema, and handler function.server.tool( 'list_tabs', 'List all open browser tabs with their IDs, URLs, and titles', listTabsSchema.shape, async () => { const tabs = await listTabs(); return handleResult(ok({ tabs })); } );
- src/tabs.ts:192-212 (helper)Helper function that implements the core logic for listing all tracked tabs: ensures browser init, fetches URL/title for each page, handles closed pages, indicates active tab.export async function listTabs(): Promise<TabInfo[]> { await ensureInitialized(); const tabs: TabInfo[] = []; for (const [id, page] of state.tabs.entries()) { try { tabs.push({ id, url: page.url(), title: await page.title(), isActive: id === state.activeTabId, }); } catch { // Page may be closed, skip it state.tabs.delete(id); } } return tabs; }