new_tab
Open a new browser tab for navigation or automation tasks, optionally loading a specific URL immediately upon creation.
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/tabs.ts:95-127 (handler)Core handler implementation: creates a new Puppeteer Page (tab), generates ID, registers it in state, activates it, optionally navigates to URL, returns TabInfo./** * Create a new tab * @param url Optional URL to navigate to * @returns Result with tab info */ 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()); } }
- src/schemas.ts:12-14 (schema)Zod schema for new_tab tool input: optional URL.export const newTabSchema = z.object({ url: z.string().url().optional().describe('URL to navigate to in the new tab'), });
- src/tools/tab-tools.ts:21-30 (registration)Registers the new_tab tool with MCP server, providing name, description, input schema, and thin handler wrapper around createTab.// Create new tab 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); } );