list_tabs
Retrieve all open browser tabs with their IDs, URLs, and titles to manage multiple browser sessions and track navigation states.
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-18 (handler)Handler function for the 'list_tabs' MCP tool. Calls the listTabs helper and returns the result wrapped in error handling.async () => { const tabs = await listTabs(); return handleResult(ok({ tabs })); }
- src/schemas.ts:10-10 (schema)Zod schema defining the input for the list_tabs tool (empty object, 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, including 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)Core implementation that lists all open tabs: ensures browser initialized, iterates tracked Puppeteer pages, collects id/url/title/isActive, skips closed pages.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; }