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 }]
      };
    }
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 doesn't mention prerequisites (e.g., requires an open browser/page), side effects (e.g., might be read-only or have performance implications), or output format details (e.g., raw HTML string). This leaves gaps in understanding its behavior.

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 with zero waste—it directly states the tool's function without unnecessary words. It's front-loaded and efficiently conveys the essential information.

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

Completeness3/5

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

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is adequate but minimal. It covers the basic purpose but lacks context on usage relative to siblings or behavioral details, which could be helpful for an AI agent in a browser automation environment.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, and since there are none, it meets the baseline of 4 for not introducing confusion or redundancy.

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 action ('Get') and resource ('HTML source code of the current page'), making the tool's purpose immediately understandable. However, it doesn't explicitly differentiate from siblings like getPageText or getElementContent, which might retrieve related but different content.

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?

No guidance is provided on when to use this tool versus alternatives such as getPageText (for text content) or getElementContent (for specific elements). The description implies usage for HTML source retrieval but lacks explicit context or exclusions.

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