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 }]
      };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but lacks details on how it behaves: e.g., does it return plain text or formatted text, is it affected by JavaScript rendering, are there rate limits, or does it require specific page states? This leaves significant gaps in understanding the tool's operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that directly states the tool's purpose without any fluff. It's front-loaded and efficiently communicates the core function, making it easy to parse and understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of browser interaction tools and the lack of annotations and output schema, the description is insufficient. It doesn't explain what 'text content' includes (e.g., visible text, hidden text, formatting), how it's retrieved, or potential errors, leaving the agent with incomplete context for reliable use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and the input schema has 100% description coverage (though empty). The description doesn't need to add parameter semantics, so it meets the baseline for a parameterless tool. No additional value is required beyond stating the action.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'text content of the current page', making the purpose immediately understandable. However, it doesn't explicitly distinguish this from sibling tools like getElementContent or getPageSource, which might also retrieve text in different ways, so it misses full sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as getElementContent (for specific elements) or getPageSource (for raw HTML). There's no mention of prerequisites like needing an open browser page or context about what 'current page' refers to, leaving usage unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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