Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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'); } }
  • 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 }] }; }

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/jomon003/PlayMCP'

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