Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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 })); }
  • Zod schema defining the input for the list_tabs tool (empty object, no parameters required).
    export const listTabsSchema = z.object({});
  • 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 })); } );
  • 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; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/andytango/puppeteer-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server