Skip to main content
Glama
williamvd4

Web Search MCP Server

by williamvd4

search

Search the web using Google to find information, websites, and answers to queries without requiring an API key.

Instructions

Search the web using Google (no API key required)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
limitNoMaximum number of results to return (default: 5)

Implementation Reference

  • The performSearch method implements the core logic of the 'search' tool: performs a Google search using axios, parses the HTML with cheerio, extracts up to the specified number of results including title, URL, and description.
    private async performSearch(query: string, limit: number): Promise<SearchResult[]> {
      const response = await axios.get('https://www.google.com/search', {
        params: { q: query },
        headers: {
          'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
        }
      });
    
      const $ = cheerio.load(response.data);
      const results: SearchResult[] = [];
    
      $('div.g').each((i, element) => {
        if (i >= limit) return false;
    
        const titleElement = $(element).find('h3');
        const linkElement = $(element).find('a');
        const snippetElement = $(element).find('.VwiC3b');
    
        if (titleElement.length && linkElement.length) {
          const url = linkElement.attr('href');
          if (url && url.startsWith('http')) {
            results.push({
              title: titleElement.text(),
              url: url,
              description: snippetElement.text() || '',
            });
          }
        }
      });
    
      return results;
    }
  • Defines the TypeScript interface for a single search result returned by the tool.
    interface SearchResult {
      title: string;
      url: string;
      description: string;
    }
  • JSON schema defining the input parameters for the 'search' tool: query (required string) and optional limit (number 1-10).
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'Search query',
        },
        limit: {
          type: 'number',
          description: 'Maximum number of results to return (default: 5)',
          minimum: 1,
          maximum: 10,
        },
      },
      required: ['query'],
    },
  • src/index.ts:51-74 (registration)
    Registers the 'search' tool in the MCP server by handling ListToolsRequestSchema and providing the tool's metadata, description, and input schema.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: 'search',
          description: 'Search the web using Google (no API key required)',
          inputSchema: {
            type: 'object',
            properties: {
              query: {
                type: 'string',
                description: 'Search query',
              },
              limit: {
                type: 'number',
                description: 'Maximum number of results to return (default: 5)',
                minimum: 1,
                maximum: 10,
              },
            },
            required: ['query'],
          },
        },
      ],
    }));
  • Type guard function to validate the arguments passed to the 'search' tool.
    const isValidSearchArgs = (args: any): args is { query: string; limit?: number } =>
      typeof args === 'object' &&
      args !== null &&
      typeof args.query === 'string' &&
      (args.limit === undefined || typeof args.limit === 'number');
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 'no API key required,' which adds some context about authentication, but fails to describe other critical behaviors such as rate limits, response format, error handling, or any constraints beyond the input schema. This leaves significant gaps for an agent to understand how the tool behaves.

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 extremely concise and front-loaded, consisting of a single sentence that directly states the tool's function and a key feature ('no API key required'). There is no wasted language, making it efficient and easy to parse for an agent.

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 as a web search function with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits, response format, and operational constraints, which are crucial for an agent to use the tool effectively. The high schema coverage helps with inputs, but overall context is insufficient.

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 100% description coverage, clearly documenting both parameters ('query' and 'limit') with details like default values and constraints. The description does not add any additional meaning beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage without compensating with extra insights.

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 specific verb ('search') and resource ('the web using Google'), making it immediately understandable. However, since there are no sibling tools mentioned, it cannot demonstrate differentiation from alternatives, which prevents a perfect score.

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 guidance by mentioning 'no API key required,' which implies ease of use but lacks explicit instructions on when to use this tool versus alternatives or any context about limitations. No sibling tools exist, so no comparison is possible, but the description still lacks usage 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/williamvd4/web-search'

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