browser_get_page_source
Retrieve the complete HTML source code of the current web page for analysis, debugging, or content extraction during browser automation.
Instructions
Get the current page source
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/browserTools.ts:145-162 (handler)The inline handler function for the browser_get_page_source tool. It gets the current WebDriver instance from the StateManager, calls getPageSource() to retrieve the HTML source of the current page, and returns it formatted in the MCP response. Error handling returns an error message.server.tool('browser_get_page_source', 'Get the current page source', {}, async () => { try { const driver = stateManager.getDriver(); const pageSource = await driver.getPageSource(); return { content: [{ type: 'text', text: `Current page source is: ${pageSource}` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error getting page source: ${(e as Error).message}`, }, ], }; } });