Skip to main content
Glama

search_google

Execute a Google search directly through the Google Toolbox MCP server to retrieve formatted results. Specify your query and number of results for precise, actionable data.

Instructions

Perform a Google search and return formatted results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
num_resultsNo
queryYes

Implementation Reference

  • The primary handler function for the 'search_google' tool. It is decorated with @mcp.tool which registers it, uses Google Custom Search API (requires GOOGLE_API_KEY and GOOGLE_CSE_ID env vars), performs the search, formats results with title/link/snippet, and returns structured dict with success flag.
    @mcp.tool(
        name="search_google",
        description="Perform a Google search and return formatted results",
    )
    async def search_google(query: str, num_results: int = 5) -> Dict[str, Any]:
        """
        Perform a Google search and return formatted results.
        
        This function uses Google Custom Search API to search the web based on the provided query.
        It formats the results into a consistent structure and handles potential errors.
        
        Args:
            query (str): The search query string
            num_results (int, optional): Number of search results to return. Defaults to 5.
            
        Returns:
            Dict[str, Any]: A dictionary containing:
                - success (bool): Whether the search was successful
                - results (list): List of dictionaries with title, link, and snippet
                - total_results (str): Total number of results found (when successful)
                - error (str): Error message (when unsuccessful)
        """
        try:
            # Initialize Google Custom Search API
            service = build("customsearch", "v1", developerKey=GOOGLE_API_KEY)
            
            # Execute the search
            # pylint: disable=no-member
            result = service.cse().list(
                q=query,
                cx=GOOGLE_CSE_ID,
                num=num_results
            ).execute()
            
            # Format the search results
            formatted_results = []
            if "items" in result:
                for item in result["items"]:
                    formatted_results.append({
                        "title": item.get("title", ""),
                        "link": item.get("link", ""),
                        "snippet": item.get("snippet", "")
                    })
            
            return {
                "success": True,
                "results": formatted_results,
                "total_results": result.get("searchInformation", {}).get("totalResults", "0")
            }
        
        except HttpError as error:
            logger.error(f"API 오류 발생: {error}")
            return {
                "success": False,
                "error": f"API Error: {str(error)}",
                "results": []
            }
        except Exception as error:  # pylint: disable=broad-exception-caught
            logger.error(f"예상치 못한 오류 발생: {error}")
            return {
                "success": False,
                "error": str(error),
                "results": []
            }
  • server.py:200-204 (registration)
    The 'search_google' tool is listed in the available_google_tools array returned by the get_available_google_tools resource, indicating it is one of the available tools on this MCP server.
    available_google_tools = [
        "list_emails", "search_emails", "send_email", "modify_email",
        "list_events", "create_event", "update_event", "delete_event",
        "search_google", "read_gdrive_file", "search_gdrive"
    ]
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'return formatted results,' which adds some context about output format, but lacks details on rate limits, authentication needs, pagination, error handling, or what 'formatted' entails. For a search tool with zero annotation coverage, this leaves significant behavioral gaps.

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, efficient sentence that front-loads the core action and outcome with zero wasted words. It's appropriately sized for a simple search tool, making it easy to parse quickly.

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 tool's moderate complexity (search operation with 2 parameters), no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits, parameter usage, and output structure. The description alone doesn't provide enough context for an agent to use the tool effectively beyond basic invocation.

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

Parameters3/5

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

The input schema has 2 parameters with 0% description coverage, so the schema provides no semantic context. The description doesn't add any parameter-specific information beyond the tool's overall function. It implies the 'query' parameter is used for the search but doesn't explain 'num_results' or other details. Baseline 3 is appropriate as the description doesn't compensate for the schema gap but doesn't mislead.

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 ('Perform') and resource ('Google search'), and specifies the outcome ('return formatted results'). It distinguishes from siblings like search_emails or search_gdrive by specifying Google search, though it doesn't explicitly contrast them. The purpose is unambiguous but lacks explicit sibling differentiation.

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 when to prefer this over other search tools (e.g., search_emails for email content) or general web search contexts. Usage is implied by the name and purpose, but no explicit when/when-not or alternative recommendations are given.

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

Related 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/jikime/py-mcp-google-toolbox'

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