navigate_page
Directs the browser tab to load a specific web address for testing, automation, or navigation tasks.
Instructions
Navigate the currently selected tab to the provided URL.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to navigate the page to |
Implementation Reference
- src/tools/pages.ts:141-168 (handler)The handler function that executes the navigate_page tool logic. It validates the URL input, gets the Firefox instance, navigates the selected tab to the given URL, and returns a success response with the tab index.export async function handleNavigatePage(args: unknown): Promise<McpToolResponse> { try { const { url } = args as { url: string }; if (!url || typeof url !== 'string') { throw new Error('url parameter is required and must be a string'); } const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); // Refresh tabs to get latest list await firefox.refreshTabs(); const tabs = firefox.getTabs(); const selectedIdx = firefox.getSelectedTabIdx(); const page = tabs[selectedIdx]; if (!page) { throw new Error('No page selected'); } await firefox.navigate(url); return successResponse(`✅ [${selectedIdx}] → ${url}`); } catch (error) { return errorResponse(error as Error); } }
- src/tools/pages.ts:33-46 (schema)The tool schema definition including name, description, and input schema requiring a 'url' string parameter.export const navigatePageTool = { name: 'navigate_page', description: 'Navigate selected tab to URL.', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'Target URL', }, }, required: ['url'], }, };
- src/index.ts:110-110 (registration)Registration of the navigate_page handler in the toolHandlers Map, mapping the tool name to its handler function.['navigate_page', tools.handleNavigatePage],
- src/index.ts:154-154 (registration)Inclusion of the navigate_page tool definition in the allTools array used for listing available tools.tools.navigatePageTool,
- src/tools/index.ts:6-17 (registration)Re-export of navigatePageTool and handleNavigatePage from pages.js, making them available centrally in tools/index.ts.export { listPagesTool, newPageTool, navigatePageTool, selectPageTool, closePageTool, handleListPages, handleNewPage, handleNavigatePage, handleSelectPage, handleClosePage, } from './pages.js';