list_pages
Display all open browser tabs with their index, title, and URL to identify and manage web pages for automation tasks.
Instructions
List all open tabs with index, title, and URL. The currently selected tab is marked. Use the index with select_page.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/pages.ts:107-120 (handler)The main execution handler for the list_pages tool. It connects to Firefox, refreshes tabs, gets the list and selected index, formats it, and returns as success response.export async function handleListPages(_args: unknown): Promise<McpToolResponse> { try { const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); await firefox.refreshTabs(); const tabs = firefox.getTabs(); const selectedIdx = firefox.getSelectedTabIdx(); return successResponse(formatPageList(tabs, selectedIdx)); } catch (error) { return errorResponse(error as Error); } }
- src/tools/pages.ts:9-16 (schema)The tool schema definition, specifying name, description, and empty input schema (no parameters required).export const listPagesTool = { name: 'list_pages', description: 'List open tabs (index, title, URL). Selected tab is marked.', inputSchema: { type: 'object', properties: {}, }, };
- src/tools/pages.ts:89-104 (helper)Helper function that formats the list of tabs into a readable string, marking the selected tab.function formatPageList( tabs: Array<{ title?: string; url?: string }>, selectedIdx: number ): string { if (tabs.length === 0) { return '📄 No pages'; } const lines: string[] = [`📄 ${tabs.length} pages (selected: ${selectedIdx})`]; for (const tab of tabs) { const idx = tabs.indexOf(tab); const marker = idx === selectedIdx ? '>' : ' '; const title = (tab.title || 'Untitled').substring(0, 40); lines.push(`${marker}[${idx}] ${title}`); } return lines.join('\n'); }
- src/index.ts:108-108 (registration)Registration of the handler function in the central toolHandlers Map used by the MCP server.['list_pages', tools.handleListPages],
- src/index.ts:152-152 (registration)Registration of the tool schema in the allTools array used for listing available tools.tools.listPagesTool,