Skip to main content
Glama

select_page

Selects the active Firefox browser tab by index, URL, or title to control web automation workflows.

Instructions

Select active tab by index, URL, or title. Index takes precedence.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageIdxNoTab index (0-based, most reliable)
urlNoURL substring (case-insensitive)
titleNoTitle substring (case-insensitive)

Implementation Reference

  • The main execution handler for the 'select_page' tool. It selects the active tab in Firefox by priority: index, URL substring, or title substring. Uses Firefox DevTools to refresh tabs, find matching tab, validate, and select it.
    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); } }
  • The tool schema definition for 'select_page', including name, description, and input schema allowing optional pageIdx (number), url (string), or title (string).
    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)
    Maps the 'select_page' tool name to its handler function (handleSelectPage) in the MCP server's toolHandlers Map, enabling tool execution.
    ['select_page', tools.handleSelectPage],
  • src/index.ts:155-155 (registration)
    Includes the selectPageTool schema in the allTools array, which is returned by the MCP list_tools request.
    tools.selectPageTool,

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