Skip to main content
Glama
andytango
by andytango

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
NameRequiredDescriptionDefault
urlNoURL to navigate to in the new tab

Implementation Reference

  • 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());
      }
    }
  • 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'),
    });
  • 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);
      }
    );

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