Skip to main content
Glama

pilot_page_text

Extract clean readable text from any web page by removing scripts, styles, and non-content elements. Use this to get concise page content for analysis or processing.

Instructions

Extract clean text from the page (strips script/style/noscript/svg).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_charsNoMax characters to return (default: 20000). Prevents token bloat on large pages.

Implementation Reference

  • Registration of 'pilot_page_text' tool via server.tool(), including the handler function that extracts clean text from the page using getCleanText() and truncates via truncate().
    export function registerPageTools(server: McpServer, bm: BrowserManager) {
      server.tool(
        'pilot_page_text',
        'Extract clean text from the page (strips script/style/noscript/svg).',
        {
          max_chars: z.number().optional().describe('Max characters to return (default: 20000). Prevents token bloat on large pages.'),
        },
        async ({ max_chars }) => {
          await bm.ensureBrowser();
          try {
            const text = await getCleanText(bm.getPage());
            return { content: [{ type: 'text' as const, text: truncate(text, max_chars) }] };
          } catch (err) {
            return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
          }
        }
      );
  • Helper function getCleanText() that clones the document body, strips script/style/noscript/svg elements, and returns cleaned innerText.
    async function getCleanText(page: import('playwright').Page): Promise<string> {
      return await page.evaluate(() => {
        const body = document.body;
        if (!body) return '';
        const clone = body.cloneNode(true) as HTMLElement;
        clone.querySelectorAll('script, style, noscript, svg').forEach(el => el.remove());
        return clone.innerText
          .split('\n')
          .map(line => line.trim())
          .filter(line => line.length > 0)
          .join('\n');
      });
    }
  • Helper function truncate() that truncates text to max_chars (default 20000) with a message about remaining chars.
    function truncate(text: string, maxChars?: number): string {
      const limit = maxChars || DEFAULT_MAX_CHARS;
      if (text.length <= limit) return text;
      const truncated = text.slice(0, limit);
      const remaining = text.length - limit;
      return truncated + `\n\n── truncated: ${remaining} chars not shown (use max_chars to increase) ──`;
    }
  • Zod schema for the max_chars optional input parameter (default 20000).
    max_chars: z.number().optional().describe('Max characters to return (default: 20000). Prevents token bloat on large pages.'),
  • Tool registration via registerAllTools() calling registerPageTools(). The tool is included in the 'standard' profile set (line 45).
    function createFilteredServer(server: McpServer, allowed: Set<string>): McpServer {
      const originalTool = server.tool.bind(server);
    
      const filtered = Object.create(server) as McpServer;
      filtered.tool = ((...args: unknown[]) => {
        const name = args[0] as string;
        if (!allowed.has(name)) return;
        return (originalTool as Function).apply(server, args);
      }) as typeof server.tool;
    
      return filtered;
    }
    
    export function registerAllTools(server: McpServer, bm: BrowserManager, profile: ToolProfile = 'full'): void {
      const allowed = PROFILE_TOOLS[profile];
      const effectiveServer = allowed ? createFilteredServer(server, allowed) : server;
    
      registerNavigationTools(effectiveServer, bm);
      registerSnapshotTools(effectiveServer, bm);
      registerInteractionTools(effectiveServer, bm);
      registerPageTools(effectiveServer, bm);
Behavior3/5

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

With no annotations, the description should disclose behavioral traits. It mentions stripping but not whether it waits for page load, handles dynamic content, or returns only visible text. The max_chars limits are noted, but overall transparency is limited.

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 sentence that is clear and front-loaded. Every word is meaningful with no unnecessary 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?

No output schema is provided, so the description should explain the return format (plain text) and handle edge cases (empty page, very large pages). It mentions max_chars but lacks specifics on output structure or error behavior.

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?

Schema coverage is 100%, and the description adds context: default value of 20000 and the purpose of preventing token bloat. This goes beyond the schema's description.

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

Purpose5/5

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

The description clearly states the tool extracts clean text and specifies what it strips (script/style/noscript/svg), distinguishing it from siblings like pilot_page_html or pilot_page_links.

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 on when to use this tool versus alternatives like pilot_page_html or pilot_find. An agent would benefit from knowing this is for plain text extraction, not for structured content.

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/TacosyHorchata/Pilot'

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