Skip to main content
Glama

pilot_page_links

Return all links from a web page as text and URL pairs, with an option to limit the total characters retrieved.

Instructions

Get all links on the page as text + href pairs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_charsNoMax characters to return (default: 20000)

Implementation Reference

  • The main handler for the pilot_page_links tool. Registers the tool on the MCP server with a max_chars optional parameter, then either uses the browser extension (extSend) to collect links via content script, or falls back to evaluating document.querySelectorAll('a[href]') directly via Playwright. Returns text + href pairs formatted as 'text → href' per line.
    server.tool(
      'pilot_page_links',
      'Get all links on the page as text + href pairs.',
      {
        max_chars: z.number().optional().describe('Max characters to return (default: 20000)'),
      },
      async ({ max_chars }) => {
        await bm.ensureBrowser();
        try {
          const ext = bm.getExtension();
          if (ext) {
            const res = await bm.extSend<{ links: Array<{ text: string; href: string }> }>('page_links');
            const result = res.links.map(l => `${l.text} → ${l.href}`).join('\n');
            return { content: [{ type: 'text' as const, text: truncate(result || '(no links found)', max_chars) }] };
          }
          const links = await bm.getPage().evaluate(() =>
            [...document.querySelectorAll('a[href]')].map(a => ({
              text: a.textContent?.trim().slice(0, 120) || '',
              href: (a as HTMLAnchorElement).href,
            })).filter(l => l.text && l.href)
          );
          const result = links.map(l => `${l.text} → ${l.href}`).join('\n');
          return { content: [{ type: 'text' as const, text: truncate(result || '(no links found)', max_chars) }] };
        } catch (err) {
          return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
        }
      }
    );
  • Input schema for pilot_page_links: accepts an optional 'max_chars' number parameter (default 20000) to limit output size.
    {
      max_chars: z.number().optional().describe('Max characters to return (default: 20000)'),
    },
  • Registration entry point: registerAllTools calls registerPageTools (line 80), which registers the pilot_page_links tool. The tool is not in the CORE or STANDARD sets, so it is only available under the 'full' profile.
    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);
      registerInspectionTools(effectiveServer, bm);
      registerVisualTools(effectiveServer, bm);
      registerTabTools(effectiveServer, bm);
      registerSettingsTools(effectiveServer, bm);
      registerIframeTools(effectiveServer, bm);
      registerAutomationTools(effectiveServer, bm);
    }
  • Browser extension content script helper that collects up to 100 links from the page with their text (trimmed to 80 chars) and href. Used when the browser extension is active (ext is truthy).
    function pageLinks() {
      const links = Array.from(document.querySelectorAll('a[href]')).slice(0, 100).map(a => ({
        text: a.textContent.trim().slice(0, 80),
        href: a.href,
      }));
      return { links, count: links.length };
    }
  • Background script relay: routes 'page_links' messages to the content script via relayToContent.
    case 'page_links':
    case 'page_forms':
    case 'element_state':
    case 'evaluate':
    case 'page_text':
    case 'page_html':
      return await relayToContent(type, payload, tabId);
Behavior2/5

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

With no annotations, the description must disclose behavior but only states 'Get all links'. It omits important details like whether URLs are absolute/relative, handling of duplicates, or the default truncation at 20000 characters (from max_chars param).

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 conveys the core functionality without any extra words. It is perfectly concise and front-loaded.

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?

Despite a simple schema and no output schema, the description is too minimal. It does not explain the return format (e.g., array of objects), the effect of max_chars, or any edge cases. Siblings like pilot_page_text provide more context.

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

Parameters3/5

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

Schema coverage is 100% (max_chars described). The description adds no extra meaning beyond the schema, so baseline 3 is appropriate. The parameter is simple and well-documented in the schema.

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 'Get all links on the page as text + href pairs', providing a specific verb and resource. It distinguishes itself from siblings like pilot_page_text (gets text) and pilot_page_html (gets HTML) by focusing on 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. There is no mention of prerequisites, when not to use, or comparison with related tools like pilot_find or pilot_click.

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