Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getPageSource

Extract HTML source code from web pages for web scraping, testing, or automation tasks using browser automation capabilities.

Instructions

Get the HTML source code of the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function in PlaywrightController that retrieves the HTML source code of the current page using page.content() and handles errors.
    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'); } }
  • Defines the tool schema with name, description, and input schema (no required parameters).
    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)
    Registers the getPageSource tool in the server's tools dictionary for MCP capabilities.
    getPageSource: GET_PAGE_SOURCE_TOOL,
  • src/server.ts:679-684 (registration)
    Dispatches tool calls to the controller's getPageSource method in the MCP callTool handler.
    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