Skip to main content
Glama

navigate

Directs a browser to load a specific webpage URL, allowing control over navigation timing and tab selection for automated web interactions.

Instructions

Navigate to a URL in the browser

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to navigate to
waitUntilNoWhen to consider navigation complete
timeoutNoTimeout in milliseconds
tabIdNoTab ID to operate on (uses active tab if not specified)

Implementation Reference

  • The handler function that executes the 'navigate' tool logic, performing page navigation with Puppeteer.
    async ({ url, waitUntil, timeout, tabId }) => { const pageResult = await getPageForOperation(tabId); if (!pageResult.success) { return handleResult(pageResult); } const page = pageResult.data; const timeoutMs = timeout ?? getDefaultTimeout(); try { const response = await page.goto(url, { waitUntil: (waitUntil ?? 'load') as WaitUntilOption, timeout: timeoutMs, }); if (!response) { return handleResult(err(navigationFailed(url, 'No response received'))); } const status = response.status(); if (status >= 400) { return handleResult(err(navigationFailed(url, `HTTP ${status}`))); } return handleResult(ok({ url: page.url(), title: await page.title(), status, })); } catch (error) { if (error instanceof Error && error.message.includes('timeout')) { return handleResult(err(navigationTimeout(url, timeoutMs))); } return handleResult(err(normalizeError(error))); } }
  • Zod input schema definition for the 'navigate' tool.
    export const navigateSchema = z.object({ url: z.string().url().describe('URL to navigate to'), waitUntil: waitUntilSchema.describe('When to consider navigation complete'), timeout: timeoutSchema, tabId: tabIdSchema, });
  • Registration of the 'navigate' tool using server.tool, including schema and handler.
    server.tool( 'navigate', 'Navigate to a URL in the browser', navigateSchema.shape, async ({ url, waitUntil, timeout, tabId }) => { const pageResult = await getPageForOperation(tabId); if (!pageResult.success) { return handleResult(pageResult); } const page = pageResult.data; const timeoutMs = timeout ?? getDefaultTimeout(); try { const response = await page.goto(url, { waitUntil: (waitUntil ?? 'load') as WaitUntilOption, timeout: timeoutMs, }); if (!response) { return handleResult(err(navigationFailed(url, 'No response received'))); } const status = response.status(); if (status >= 400) { return handleResult(err(navigationFailed(url, `HTTP ${status}`))); } return handleResult(ok({ url: page.url(), title: await page.title(), status, })); } catch (error) { if (error instanceof Error && error.message.includes('timeout')) { return handleResult(err(navigationTimeout(url, timeoutMs))); } return handleResult(err(normalizeError(error))); } } );
  • src/server.ts:23-23 (registration)
    Invocation of registerNavigationTools which includes the navigate tool registration.
    registerNavigationTools(server);

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