Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getLinks

Extract all hyperlinks from a webpage to collect URLs for analysis, navigation, or data gathering during browser automation tasks.

Instructions

Get all links from the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the getLinks tool in PlaywrightController. Extracts all anchor links (a[href]) from the page, returning array of {href, text, title?} using page.evaluate.
    async getLinks(): Promise<Array<{href: string, text: string, title?: string}>> {
      try {
        if (!this.isInitialized()) {
          throw new Error('Browser not initialized');
        }
        this.log('Getting page links');
        const links = await this.state.page?.evaluate(() => {
          const linkElements = Array.from(document.querySelectorAll('a[href]'));
          return linkElements.map(link => ({
            href: (link as HTMLAnchorElement).href,
            text: link.textContent?.trim() || '',
            title: link.getAttribute('title') || undefined
          }));
        });
        this.log('Links retrieved:', links?.length);
        return links || [];
      } catch (error: any) {
        console.error('Get links error:', error);
        throw new BrowserError('Failed to get links', 'Check if the page is loaded');
      }
    }
  • Tool schema definition for getLinks, specifying no input parameters required.
    const GET_LINKS_TOOL: Tool = {
      name: "getLinks",
      description: "Get all links from the current page",
      inputSchema: {
        type: "object",
        properties: {},
        required: []
      }
    };
  • src/server.ts:529-529 (registration)
    Registration of the getLinks tool in the server's tools object for MCP capabilities.
    getLinks: GET_LINKS_TOOL,
  • src/server.ts:726-731 (registration)
    MCP tool call dispatch in server request handler that calls the controller's getLinks and returns JSON serialized results.
    case 'getLinks': {
      const links = await playwrightController.getLinks();
      return {
        content: [{ type: "text", text: JSON.stringify(links, null, 2) }]
      };
    }
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 fails to describe key traits like the return format (e.g., list of URLs, HTML elements), pagination, or error handling. This leaves significant gaps in understanding how the tool behaves.

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 no wasted words, making it highly concise and front-loaded. It efficiently communicates the core functionality without unnecessary elaboration, which is ideal for a simple tool.

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 lack of annotations and output schema, the description is incomplete for effective use. It does not explain what 'all links' means (e.g., format, scope like internal vs. external), or how results are returned, leaving the agent with insufficient context to handle the tool reliably.

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 does not add parameter details, earning a high baseline score as it avoids redundancy and focuses on the tool's purpose.

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 all links') and the resource ('from the current page'), making the purpose understandable. However, it does not explicitly differentiate from sibling tools like 'getElementContent' or 'getPageText' that might also retrieve link-related information, preventing a perfect score.

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. It lacks context on prerequisites (e.g., needing an open browser) or exclusions, offering minimal usage direction.

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