Skip to main content
Glama

tool_compare_sources

Analyze differences and similarities across multiple sources to identify common topics and variations in information.

Instructions

Compare information across multiple sources.

Analyzes differences and similarities between sources.

Args: topic: Topic being compared. sources: List of URLs (2-5) to compare.

Returns: Comparison report with common topics and differences.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topicYes
sourcesYes

Implementation Reference

  • The implementation of compare_sources function.
    async def compare_sources(topic: str, sources: list[str]) -> str:
        """Compare information across multiple sources.
    
        Args:
            topic: Topic being compared.
            sources: List of URLs to compare.
    
        Returns:
            Comparison report showing differences and similarities.
    
        Example:
            >>> report = await compare_sources(
            ...     "Python async",
            ...     ["https://realpython.com/async", "https://docs.python.org/3/library/asyncio.html"]
            ... )
        """
        if len(sources) < 2:
            return "Error: Need at least 2 sources to compare"
    
        if len(sources) > 5:
            sources = sources[:5]  # Limit to 5 sources
    
        # Fetch all sources in parallel
        async def fetch_with_title(url: str) -> tuple[str, str, str | None]:
            """Fetch source and return (url, title, content)."""
            try:
                doc = await _scraper.fetch(url, retry=1)
                return (url, doc.title, doc.content)
            except Exception:
                return (url, "Failed", None)
    
        results = await asyncio.gather(*[fetch_with_title(url) for url in sources])
    
        # Build comparison report
        report_lines = [
            f"# Source Comparison: {topic}\n",
            "## Sources\n",
        ]
    
        for i, (url, title, _) in enumerate(results, 1):
            status = "✓" if results[i - 1][2] else "✗"
            report_lines.append(f"{i}. {status} [{title}]({url})")
    
        report_lines.append("\n## Content Analysis\n")
    
        # Extract key terms from each source
        import re
    
        all_words: list[list[str]] = []
        for _, _, content in results:
  • The MCP tool wrapper tool_compare_sources which calls compare_sources.
    async def tool_compare_sources(topic: str, sources: list[str]) -> str:
        """Compare information across multiple sources.
    
        Analyzes differences and similarities between sources.
    
        Args:
            topic: Topic being compared.
            sources: List of URLs (2-5) to compare.
    
        Returns:
            Comparison report with common topics and differences.
        """
        return await compare_sources(topic, sources)

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