Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getPageText

Extract text content from web pages for web scraping, testing, and browser automation tasks using Playwright.

Instructions

Get the text content of the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Implements the core logic to retrieve the text content from the current page's body element using Playwright.
    async getPageText(): Promise<string> { try { if (!this.isInitialized()) { throw new Error('Browser not initialized'); } this.log('Getting page text content'); const text = await this.state.page?.innerText('body'); this.log('Page text retrieved'); return text || ''; } catch (error: any) { console.error('Get page text error:', error); throw new BrowserError('Failed to get page text', 'Check if the page is loaded'); } }
  • Defines the tool schema for MCP, specifying name, description, and input schema (no parameters required).
    const GET_PAGE_TEXT_TOOL: Tool = { name: "getPageText", description: "Get the text content of the current page", inputSchema: { type: "object", properties: {}, required: [] } };
  • src/server.ts:523-523 (registration)
    Registers the getPageText tool in the tools object that is passed to the MCP server's capabilities.
    getPageText: GET_PAGE_TEXT_TOOL,
  • MCP server request handler (dispatcher) that invokes the controller method and formats the response.
    case 'getPageText': { const text = await playwrightController.getPageText(); return { content: [{ type: "text", text }] };

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