Skip to main content
Glama

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
NameRequiredDescriptionDefault
selectorNo
tabIdNo

Implementation Reference

  • 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 }] }; }
  • 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' } } } },
  • The dispatch case in the CallToolRequest handler that routes calls to the getPageContent method.
    case 'get_page_content': return await this.getPageContent(args);
  • 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); } }
  • 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.'); } }

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/JediLuke/firefox-mcp-server'

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