Skip to main content
Glama
rayss868

Web-curl MCP Server

google_search

Perform web searches using Google Custom Search API to retrieve relevant information from the internet for research, data gathering, or content discovery.

Instructions

Search the web using Google Custom Search API. Requires google_search_config resource.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query, including any operators like site:, filetype:, etc.
numNoNumber of results to return (1-10, optional)
startNoIndex of the first result to return (optional)

Implementation Reference

  • Main handler for 'google_search' tool: validates input args, checks env vars for API key/CX, builds and fetches Google Custom Search API URL with timeout, formats results (title/link/snippet), handles errors.
    } else if (toolName === 'google_search') {
      // Validate google_search arguments
      const isValidGoogleSearchArgs = (a: any): boolean =>
        typeof a === 'object' &&
        a !== null &&
        typeof a.query === 'string' &&
        (a.num === undefined || (typeof a.num === 'number' && a.num >= 1 && a.num <= 10)) &&
        (a.start === undefined || typeof a.start === 'number');
    
      if (!isValidGoogleSearchArgs(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid google_search arguments'
        );
      }
      // Accept advanced arguments; apiKey/cx from resource
      const { query, num, start } = args as {
        query: string;
        num?: number;
        start?: number;
      };
    
      // Use config from resource
      const apiKey = process.env.APIKEY_GOOGLE_SEARCH;
      const cx = process.env.CX_GOOGLE_SEARCH;
      if (!apiKey || !cx) {
        throw new McpError(ErrorCode.InvalidParams, 'Google Search API key and cx not set. Please set APIKEY_GOOGLE_SEARCH and CX_GOOGLE_SEARCH in environment variable.');
      }
    
      const url = new URL('https://www.googleapis.com/customsearch/v1');
      url.searchParams.set('key', apiKey);
      url.searchParams.set('cx', cx);
      url.searchParams.set('q', query);
      if (num !== undefined) url.searchParams.set('num', String(num));
      if (start !== undefined) url.searchParams.set('start', String(start));
    
        try {
          const controller = new AbortController();
          const timeoutId = setTimeout(() => controller.abort(), 20000); // Apply timeout manually
    
          const response = await fetch(url.toString(), {
            method: 'GET',
            headers: {
              'Content-Type': 'application/json'
            },
            signal: controller.signal // Use abort signal for timeout
          });
          clearTimeout(timeoutId);
    
          if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
          }
    
          const data = await response.json(); // Parse JSON directly
    
          let formatted;
          if (data && Array.isArray(data.items)) {
            formatted = data.items.map((item: any) => ({
              title: item.title,
              link: item.link,
              snippet: item.snippet,
            }));
          } else {
            formatted = data; // Fallback to full data if items not found
          }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(formatted, null, 2),
            },
          ],
        };
      } catch (error: any) {
        console.error('Error calling google_search:', error);
        return {
          content: [
            {
              type: 'text',
              text: `Error calling google_search: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
  • JSON Schema definition for input arguments of the 'google_search' tool: requires 'query' string, optional 'num' (1-10), 'start' number.
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'Search query, including any operators like site:, filetype:, etc.'
        },
        num: {
          type: 'number',
          description: 'Number of results to return (1-10, optional)'
        },
        start: {
          type: 'number',
          description: 'Index of the first result to return (optional)'
        }
      },
      required: ['query'],
      additionalProperties: false,
      description: 'Search the web using Google Custom Search API.'
    },
  • src/index.ts:212-235 (registration)
    Registration of 'google_search' tool in the tools list returned by listTools handler, including name, description, and inputSchema.
    {
      name: 'google_search',
      description: 'Search the web using Google Custom Search API. Requires google_search_config resource.',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query, including any operators like site:, filetype:, etc.'
          },
          num: {
            type: 'number',
            description: 'Number of results to return (1-10, optional)'
          },
          start: {
            type: 'number',
            description: 'Index of the first result to return (optional)'
          }
        },
        required: ['query'],
        additionalProperties: false,
        description: 'Search the web using Google Custom Search API.'
      },
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the API dependency but lacks critical details: it doesn't specify rate limits, authentication needs beyond the config resource, error handling, or the format/scope of search results. For a web search tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise (two sentences) and front-loaded with the core purpose. The second sentence adds necessary context about the config requirement. There's no wasted verbiage, though it could be slightly more structured (e.g., separating prerequisites from usage notes).

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 complexity (web search with API integration), lack of annotations, and no output schema, the description is incomplete. It misses key contextual details: what the search results look like (format, fields), limitations (e.g., commercial vs. academic use), error cases, or how it differs from sibling tools. The config requirement is noted, but overall coverage is insufficient for effective agent use.

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?

Schema description coverage is 100%, so the input schema already documents all three parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain how 'query' operators work in practice or typical use cases for 'start'). The baseline score of 3 reflects adequate but minimal value added over the schema.

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: 'Search the web using Google Custom Search API.' It specifies the verb ('Search') and resource ('the web'), and mentions the specific API used. However, it doesn't differentiate this tool from potential siblings like 'fetch_webpage' or 'smart_command' that might also retrieve web content.

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 minimal usage guidance: it mentions a prerequisite ('Requires google_search_config resource.') but offers no explicit advice on when to use this tool versus alternatives like 'fetch_webpage' or 'smart_command'. There's no mention of scenarios where this tool is preferred or when it should be avoided.

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/rayss868/MCP-Web-Curl'

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