getPageSource
Retrieve the HTML source code of the current web page to facilitate web scraping, testing, or debugging within PlayMCP Browser Automation Server.
Instructions
Get the HTML source code of the current page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/controllers/playwright.ts:263-276 (handler)Core handler function in PlaywrightController that retrieves and returns the HTML content of the current page using page.content().async getPageSource(): Promise<string> { try { if (!this.isInitialized()) { throw new Error('Browser not initialized'); } this.log('Getting page source'); const content = await this.state.page?.content(); this.log('Page source retrieved'); return content || ''; } catch (error: any) { console.error('Get page source error:', error); throw new BrowserError('Failed to get page source', 'Check if the page is loaded'); } }
- src/server.ts:83-91 (schema)Tool schema defining the getPageSource tool with name, description, and empty input schema (no parameters required).const GET_PAGE_SOURCE_TOOL: Tool = { name: "getPageSource", description: "Get the HTML source code of the current page", inputSchema: { type: "object", properties: {}, required: [] } };
- src/server.ts:522-522 (registration)Registration of the getPageSource tool in the tools dictionary provided to the MCP server.getPageSource: GET_PAGE_SOURCE_TOOL,
- src/server.ts:679-684 (registration)Dispatch handler in the MCP server's callTool request handler that invokes the controller's getPageSource method and formats the response.case 'getPageSource': { const source = await playwrightController.getPageSource(); return { content: [{ type: "text", text: source }] }; }