Skip to main content
Glama
adenot

MCP Google Server

by adenot

search

Perform a web search and receive up to 10 results using Google's search engine.

Instructions

Perform a web search query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
numNoNumber of results (1-10)

Implementation Reference

  • Handler logic for the 'search' tool. Validates args, calls Google Custom Search API, maps results to SearchResult objects, and returns JSON-formatted results.
    if (request.params.name === 'search') {
      if (!isValidSearchArgs(request.params.arguments)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid search arguments'
        );
      }
    
      const { query, num = 5 } = request.params.arguments;
    
      try {
        const response = await this.axiosInstance.get('', {
          params: {
            q: query,
            num: Math.min(num, 10),
          },
        });
    
        const results: SearchResult[] = response.data.items.map((item: any) => ({
          title: item.title,
          link: item.link,
          snippet: item.snippet,
        }));
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(results, null, 2),
            },
          ],
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          return {
            content: [
              {
                type: 'text',
                text: `Search API error: ${
                  error.response?.data?.error?.message ?? error.message
                }`,
              },
            ],
            isError: true,
          };
        }
        throw error;
      }
  • Type definition for search result items returned from the API.
    interface SearchResult {
      title: string;
      link: string;
      snippet: string;
    }
  • Type guard that validates search tool input arguments.
    const isValidSearchArgs = (
      args: any
    ): args is { query: string; num?: number } =>
      typeof args === 'object' &&
      args !== null &&
      typeof args.query === 'string' &&
      (args.num === undefined || typeof args.num === 'number');
  • src/index.ts:120-139 (registration)
    Registration of the 'search' tool with its name, description, and JSON Schema input definition.
    {
      name: 'search',
      description: 'Perform a web search query',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query',
          },
          num: {
            type: 'number',
            description: 'Number of results (1-10)',
            minimum: 1,
            maximum: 10,
          },
        },
        required: ['query'],
      },
    },
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It only states the action, omitting details such as result format, rate limits, data sources, or any side effects. This is insufficient for a tool with no structural safety hints.

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, straightforward sentence with no extraneous information. It is appropriately concise for the tool's simple purpose.

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 has no output schema and no annotations, the description is too minimal to be considered complete. It does not address limitations, result handling, or how to interpret outputs, leaving gaps for an AI agent.

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 already provides descriptions for both parameters (100% coverage). The description adds no additional meaning beyond what the schema offers, so a baseline score of 3 is appropriate per the guidelines.

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 'Perform a web search query' clearly states the action and resource, but does not differentiate from the sibling tool 'read_webpage', which likely fetches content from a single URL. A more specific purpose, such as indicating it searches the entire web, would improve clarity.

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 the sibling tool 'read_webpage'. There is no mention of when a web search is appropriate or when to avoid it, leaving the agent without decision-making context.

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/adenot/mcp-google-search'

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