Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

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

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