navigate_page
Directs a Firefox browser tab to a specified URL for automated testing, web scraping, or browser control tasks.
Instructions
Navigate selected tab to URL.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | Target URL |
Implementation Reference
- src/tools/pages.ts:141-168 (handler)The main handler function that executes the 'navigate_page' tool. It validates the 'url' input, gets the Firefox instance, refreshes tabs, checks the selected tab, navigates to the URL, and returns a success response.
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 schema definition for the 'navigate_page' tool, specifying the name, description, and input schema requiring a 'url' string.
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 execution function.
['navigate_page', tools.handleNavigatePage], - src/index.ts:154-154 (registration)Registration of the 'navigate_page' tool schema in the allTools array, used for listing available tools.
tools.navigatePageTool, - src/tools/index.ts:6-17 (registration)Re-export of the 'navigate_page' tool schema (navigatePageTool) and handler (handleNavigatePage) from pages.ts, making them available centrally.
export { listPagesTool, newPageTool, navigatePageTool, selectPageTool, closePageTool, handleListPages, handleNewPage, handleNavigatePage, handleSelectPage, handleClosePage, } from './pages.js';