get_page_content
Retrieve HTML content from a specific browser tab using a CSS selector. Part of the Firefox MCP Server, enabling precise webpage content extraction for automation and debugging tasks.
Instructions
Get HTML content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | No | ||
| tabId | No |
Implementation Reference
- index-multi-debug.js:1228-1246 (handler)The handler function for the 'get_page_content' tool. It ensures the browser is running, retrieves the appropriate page (by tabId or active tab), fetches the HTML content using page.innerHTML(selector) if selector provided or page.content() otherwise, and returns it as MCP content.async getPageContent(args = {}) { this.ensureBrowserRunning(); const { selector, tabId } = args; const page = this.getPage(tabId); let content; if (selector) { content = await page.innerHTML(selector); } else { content = await page.content(); } return { content: [{ type: 'text', text: content }] }; }
- index-multi-debug.js:188-198 (registration)The registration of the 'get_page_content' tool in the listTools response, including name, description, and input schema.{ name: 'get_page_content', description: 'Get HTML content', inputSchema: { type: 'object', properties: { selector: { type: 'string' }, tabId: { type: 'string' } } } },
- index-multi-debug.js:417-418 (handler)The dispatch case in the CallToolRequest handler that routes calls to the getPageContent method.case 'get_page_content': return await this.getPageContent(args);
- index-multi-debug.js:1021-1033 (helper)Helper method used by getPageContent to retrieve the Playwright Page object for the specified or active tab.getPage(tabId) { if (tabId) { if (!this.pages.has(tabId)) { throw new Error(`Tab '${tabId}' not found`); } return this.pages.get(tabId); } else { if (!this.activeTabId || !this.pages.has(this.activeTabId)) { throw new Error('No active tab. Use create_tab or set_active_tab first.'); } return this.pages.get(this.activeTabId); } }
- index-multi-debug.js:1400-1404 (helper)Helper method called by getPageContent to ensure the browser instance is available before accessing pages.ensureBrowserRunning() { if (!this.browser) { throw new Error('Firefox browser is not running. Please launch it first using the launch_firefox_multi tool.'); } }