Skip to main content
Glama

tool_find_related

Discover web pages with similar content to a given URL by analyzing page content to identify related resources for research and development.

Instructions

Find pages related to a given URL.

Uses the page content to discover similar resources.

Args: url: Base URL to find related content for. limit: Max related pages (1-10, default 5).

Returns: List of related pages with descriptions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
limitNo

Implementation Reference

  • The core implementation of the logic for finding related pages. It fetches content from the provided URL, extracts a search query, performs a web search, and returns a formatted report of related URLs.
    async def find_related(url: str, limit: int = 5) -> str:
        """Find related pages to a given URL.
    
        Args:
            url: Base URL to find related content for.
            limit: Maximum related pages (1-10).
    
        Returns:
            List of related pages with descriptions.
    
        Example:
            >>> related = await find_related("https://docs.python.org/3/library/asyncio.html")
        """
        limit = min(max(limit, 1), 10)
    
        # Extract topic from URL
        try:
            doc = await _scraper.fetch(url, retry=1)
            # Use title as search query
            search_query = f"{doc.title} related documentation"
        except Exception:
            # Fallback to URL-based query
            parsed = urlparse(url)
            path_parts = parsed.path.strip("/").split("/")
            search_query = " ".join(path_parts[-2:] if len(path_parts) > 1 else path_parts)
    
        # Search for related content
        try:
            results = await _ddg.search(search_query, limit=limit + 5)
        except SearchError:
            return f"# Related Pages\n\nFailed to find related content for: {url}"
    
        # Filter out the original URL
        related = [r for r in results if r.url != url][:limit]
    
        if not related:
            return f"# Related Pages\n\nNo related pages found for: {url}"
    
        # Build report
        report_lines = [
            "# Related Pages\n",
            f"> Based on: {url}\n",
            "## Recommendations\n",
        ]
    
        for i, r in enumerate(related, 1):
            report_lines.append(f"\n### {i}. {r.title}\n")
            report_lines.append(f"**URL**: {r.url}\n")
            report_lines.append(f"{r.snippet}\n")
    
        return "\n".join(report_lines)
  • The MCP-exposed wrapper function for the `tool_find_related` tool, which calls the underlying `find_related` implementation.
    async def tool_find_related(url: str, limit: int = 5) -> str:
        """Find pages related to a given URL.
    
        Uses the page content to discover similar resources.
    
        Args:
            url: Base URL to find related content for.
            limit: Max related pages (1-10, default 5).
    
        Returns:
            List of related pages with descriptions.
        """
        return await find_related(url, limit)

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/Y4NN777/devlens-mcp'

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