Skip to main content
Glama
random-robbie

MCP Web Browser Server

get_page_links

Extract all hyperlinks from a webpage to analyze connections, gather URLs, or process web content systematically.

Instructions

Extract all links from the current page.

Args:
    context: Optional context object for logging (ignored)

Returns:
    List of links found on the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'get_page_links' tool. It uses Playwright to evaluate JavaScript on the current page to extract all href attributes from 'a' elements and returns them as a list of strings. Registered via @mcp.tool() decorator.
    @mcp.tool()
    async def get_page_links(context: Optional[Any] = None) -> list[str]:
        """
        Extract all links from the current page.
        
        Args:
            context: Optional context object for logging (ignored)
        
        Returns:
            List of links found on the page
        """
        global _current_page
        
        if not _current_page:
            raise ValueError("No page is currently loaded. Use browse_to first.")
        
        try:
            # Use JavaScript to extract all links
            links = await _current_page.evaluate("""
                () => {
                    const links = document.querySelectorAll('a');
                    return Array.from(links).map(link => link.href);
                }
            """)
            
            print(f"Extracted {len(links)} links from the page", file=sys.stderr)
            
            return links
        
        except Exception as e:
            print(f"Error extracting links: {e}", file=sys.stderr)
            raise ValueError(f"Error extracting links: {e}")
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 the action ('Extract all links') but lacks critical details: whether this requires page interaction, if it works on any loaded page, potential rate limits, error handling, or what 'current page' means in context. The return format is mentioned but without specifics like link structure or pagination.

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 highly concise and well-structured: a clear purpose statement followed by brief, bullet-like sections for Args and Returns. Every sentence earns its place with no redundant information, making it easy to scan and understand quickly.

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 moderate complexity (extracting links from a page), no annotations, and an output schema present (which handles return values), the description is minimally adequate. It covers the basic purpose and parameter semantics but lacks behavioral context and usage guidelines, leaving gaps for an agent to operate effectively.

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 description adds meaningful context for the single parameter: it explains that 'context' is optional and for logging purposes only, and explicitly states it's ignored. Since schema description coverage is 0% and there's only one parameter, this adequately compensates, though it doesn't detail logging specifics.

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 tool's purpose with a specific verb ('Extract') and resource ('all links from the current page'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'extract_text_content' or 'get_page_screenshots', which prevents 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. It doesn't mention prerequisites (e.g., needing to be on a page first), compare to siblings like 'extract_text_content' for non-link content, or specify use cases (e.g., for navigation vs. analysis).

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/random-robbie/mcp-web-browser'

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