Skip to main content
Glama

select_page

Switch between browser tabs by index, URL, or title to control which webpage is currently active for automation tasks.

Instructions

Select the active tab by index (preferred), or by matching URL/title. Index takes precedence when multiple parameters are provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageIdxNoThe index of the page to select (e.g., 0, 1, 2). Use list_pages first to see all available page indices. Most reliable method.
titleNoSelect page by title (partial match, case-insensitive). Example: "Google" will match "Google Search - About"
urlNoSelect page by URL (partial match, case-insensitive). Example: "github.com" will match "https://github.com/user/repo"

Implementation Reference

  • Core implementation of the select_page tool handler. Selects Firefox tab by index (highest priority), URL substring, or title substring. Refreshes tab list, validates selection, calls firefox.selectTab().
    export async function handleSelectPage(args: unknown): Promise<McpToolResponse> { try { const { pageIdx, url, title } = args as { pageIdx?: number; url?: string; title?: string }; const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); // Refresh tabs to get latest list await firefox.refreshTabs(); const tabs = firefox.getTabs(); let selectedIdx: number; // Priority 1: Select by index if (typeof pageIdx === 'number') { selectedIdx = pageIdx; } // Priority 2: Select by URL pattern else if (url && typeof url === 'string') { const urlLower = url.toLowerCase(); const foundIdx = tabs.findIndex((tab) => tab.url?.toLowerCase().includes(urlLower)); if (foundIdx === -1) { throw new Error(`No page matching URL "${url}"`); } selectedIdx = foundIdx; } // Priority 3: Select by title pattern else if (title && typeof title === 'string') { const titleLower = title.toLowerCase(); const foundIdx = tabs.findIndex((tab) => tab.title?.toLowerCase().includes(titleLower)); if (foundIdx === -1) { throw new Error(`No page matching title "${title}"`); } selectedIdx = foundIdx; } else { throw new Error('Provide pageIdx, url, or title'); } // Validate the selected index if (!tabs[selectedIdx]) { throw new Error(`Page [${selectedIdx}] not found`); } // Select the tab await firefox.selectTab(selectedIdx); return successResponse(`✅ selected [${selectedIdx}]`); } catch (error) { return errorResponse(error as Error); }
  • Input schema definition for the select_page tool, defining optional parameters pageIdx, url, title.
    export const selectPageTool = { name: 'select_page', description: 'Select active tab by index, URL, or title. Index takes precedence.', inputSchema: { type: 'object', properties: { pageIdx: { type: 'number', description: 'Tab index (0-based, most reliable)', }, url: { type: 'string', description: 'URL substring (case-insensitive)', }, title: { type: 'string', description: 'Title substring (case-insensitive)', }, }, required: [], }, };
  • src/index.ts:111-111 (registration)
    Registers 'select_page' tool name to handleSelectPage function in the MCP server toolHandlers Map.
    ['select_page', tools.handleSelectPage],
  • src/index.ts:155-155 (registration)
    Includes selectPageTool schema in the allTools array returned by listTools MCP handler.
    tools.selectPageTool,
  • Re-exports selectPageTool schema and handleSelectPage handler from pages.js for centralized tool access.
    export { listPagesTool, newPageTool, navigatePageTool, selectPageTool, closePageTool, handleListPages, handleNewPage, handleNavigatePage, handleSelectPage, handleClosePage, } from './pages.js';

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/freema/firefox-devtools-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server