new_tab
Open a new browser tab in Puppeteer MCP Server to navigate to URLs, enabling AI agents to automate web interactions across multiple tabs for tasks like content extraction and form filling.
Instructions
Open a new browser tab, optionally navigating to a URL. The new tab becomes active.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | URL to navigate to in the new tab |
Implementation Reference
- src/schemas.ts:12-14 (schema)Zod schema defining the input for the new_tab tool: optional URL string.export const newTabSchema = z.object({ url: z.string().url().optional().describe('URL to navigate to in the new tab'), });
- src/tools/tab-tools.ts:22-30 (registration)Registration of the 'new_tab' tool on the MCP server, including tool name, description, input schema reference, and inline handler function that calls createTab.server.tool( 'new_tab', 'Open a new browser tab, optionally navigating to a URL. The new tab becomes active.', newTabSchema.shape, async ({ url }) => { const result = await createTab(url); return handleResult(result); } );
- src/tabs.ts:99-127 (handler)Main handler logic for creating a new tab: uses Puppeteer to create a new page, generates tab ID, registers the page in internal state, sets as active, optionally navigates to URL, and returns tab information.*/ export async function createTab(url?: string): Promise<Result<TabInfo>> { const browserResult = await ensureInitialized(); if (!browserResult.success) { return browserResult; } try { const page = await browserResult.data.newPage(); const tabId = generateTabId(); registerPage(tabId, page); state.activeTabId = tabId; if (url) { await page.goto(url); } return ok({ id: tabId, url: page.url(), title: await page.title(), isActive: true, }); } catch (error) { const message = error instanceof Error ? error.message : String(error); return err(browserNotLaunched()); } }