Skip to main content
Glama

deep_research_google

Aggregate and score Google search results from multiple related queries. Remove duplicates and return top relevant content for comprehensive research.

Instructions

Perform deep research across multiple search terms using ONLY Google. Aggregates results from multiple Google searches, scores them by relevance, and returns the most relevant content with duplicates removed.

Args: search_terms (List[str]): List of search terms to research. The LLM should provide multiple related search queries for comprehensive coverage. num_results_per_term (int): Number of results to fetch per search term. top_k_per_term (int): Number of top scored results to keep per search term. include_urls (bool): Whether to include URLs in the results.

Returns: Dict containing aggregated research results from all search terms (Google only), with duplicates removed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
search_termsYes
num_results_per_termNo
top_k_per_termNo
include_urlsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'deep_research_google'. Delegates to _deep_research_internal with backend=['google']. Registered via @mcp.tool() decorator.
    @mcp.tool()
    def deep_research_google(search_terms: List[str], num_results_per_term:int=10, top_k_per_term:int=3, include_urls:bool=True) -> Dict:
        """
        Perform deep research across multiple search terms using ONLY Google.
        Aggregates results from multiple Google searches, scores them by relevance,
        and returns the most relevant content with duplicates removed.
        
        Args:
            search_terms (List[str]): List of search terms to research. The LLM should provide 
                                      multiple related search queries for comprehensive coverage.
            num_results_per_term (int): Number of results to fetch per search term.
            top_k_per_term (int): Number of top scored results to keep per search term.
            include_urls (bool): Whether to include URLs in the results.
        
        Returns:
            Dict containing aggregated research results from all search terms (Google only),
            with duplicates removed.
        """
        return _deep_research_internal(
            search_terms=search_terms,
            backends=["google"],
            num_results_per_term=num_results_per_term,
            top_k_per_term=top_k_per_term,
            include_urls=include_urls
        )
  • Internal helper function that executes the actual deep search logic. Used by deep_research_google, deep_research_ddgs, and deep_research. Accepts backends list and performs multi-term web search via ddgs, scores results with embeddings, deduplicates, and fetches content.
    def _deep_research_internal(search_terms:List[str], backends:List[str], num_results_per_term:int=5,top_k_per_term:int=3, include_urls:bool=True)->Dict:
        """
        Internal function to perform deep research across multiple search term with the given backend engine in ddgs.
    
        Args:
            search_terms (List[str]): List of search terms to perform deep research on.
            backends (List[str]): List of search backends to use. 
            num_results (int): Num of results to fetch per search term per engine.
            top_k (int): Number of top score to keep per search term per engine.
            include_urls (bool): whether to include urls in the results.
    
        Returns:
            Dict containing aggregated research results from all search terms and engines.
        """
    
        # lazy load
        from ddgs import DDGS
        from .utils.fetch import fetch_all_content
        from .utils.tools import sort_by_score
    
        ddgs = DDGS()
        all_results = []
        search_summary = {}
        
        # search each term on all specified backends
        for term in search_terms:
            search_summary[term] = {backend: 0 for backend in backends}
            
            for backend in backends:
                try:
                    if backend == "duckduckgo":
                        results = ddgs.text(term, max_results=num_results_per_term)
                    else:
                        results = ddgs.text(term, max_results=num_results_per_term, backend=backend)
                    if results:
                        scored_results = sort_by_score(add_score_to_dict(term, results))
                        top_results = scored_results[0:top_k_per_term]
                        all_results.extend(top_results)
                        search_summary[term][backend] = len(top_results)
                except Exception as e:
                    print(f"Error searching {backend} for '{term}': {e}")
        
        # remove duplicates and keep high scores
        seen_urls = {}
        unique_results = []
        for result in all_results:
            url = result.get('href', '')
            if url:
                # Keep the result with the highest score for duplicate URLs
                if url not in seen_urls or result.get('score', 0) > seen_urls[url].get('score', 0):
                    if url in seen_urls:
                        # Replace lower scored duplicate
                        unique_results.remove(seen_urls[url])
                    seen_urls[url] = result
                    unique_results.append(result)
        
        # fetch content from final list of results
        md_content = fetch_all_content(unique_results, include_urls)
        
        return {
            "search_terms": search_terms,
            "backends": backends,
            "search_summary": search_summary,
            "total_unique_results": len(unique_results),
            "content": md_content
        }
  • Type annotations define input schema: search_terms (List[str]), num_results_per_term (int), top_k_per_term (int), include_urls (bool). Returns Dict.
    @mcp.tool()
    def deep_research_google(search_terms: List[str], num_results_per_term:int=10, top_k_per_term:int=3, include_urls:bool=True) -> Dict:
  • Tool is registered via the @mcp.tool() decorator from FastMCP framework, making 'deep_research_google' available as an MCP tool.
    @mcp.tool()
  • Helper utility sort_by_score: sorts results by their cosine similarity score in descending order.
    def sort_by_score(results: List[Dict]) -> List[Dict]:
        """Sort results by similarity score."""
        return sorted(results, key=lambda x: x['score'], reverse=True)
Behavior5/5

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

Despite no annotations, the description reveals key behaviors: it aggregates results from multiple Google searches, scores by relevance, removes duplicates, and returns the most relevant content. This provides comprehensive insight into the tool's operation.

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 concise, well-structured with clear Args and Returns sections, and contains no redundant or extraneous information. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/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 the presence of sibling tools, the description is remarkably complete. It covers the tool's purpose, parameter details, behavioral traits, and return format, leaving no significant gaps for an LLM to infer.

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

Parameters5/5

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

The description includes an Args section that explains each parameter (search_terms, num_results_per_term, top_k_per_term, include_urls) in plain language, adding meaning beyond the bare input schema which has no property descriptions. It also advises the LLM to provide multiple related search queries for comprehensive coverage.

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 it performs deep research across multiple search terms using ONLY Google, distinguishing it from sibling tools like deep_research_ddgs (DuckDuckGo) and rag_search_google (RAG-based).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly specifies Google as the only source, providing clear context for when to use this tool. However, it does not explicitly state when not to use it or compare with alternatives like deep_research or rag_search_google.

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/nkapila6/mcp-local-rag'

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