Skip to main content
Glama
mnhlt

WebSearch-MCP

by mnhlt

web_search

Perform real-time web searches to retrieve up-to-date information, news, blogs, or details about companies, products, events, or people. Configure results by language, region, domains, or result type for precise data retrieval.

Instructions

Search the web for information. Use this tool when you need to search the web for information. You can use this tool to search for news, blogs, or all types of information. You can also use this tool to search for information about a specific company or product. You can also use this tool to search for information about a specific person. You can also use this tool to search for information about a specific product. You can also use this tool to search for information about a specific company. You can also use this tool to search for information about a specific event. You can also use this tool to search for information about a specific location. You can also use this tool to search for information about a specific thing. If you request search with 1 result number and failed, retry with bigger results number.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
excludeDomainsNoDomains to exclude from results
excludeTermsNoTerms to exclude from results
includeDomainsNoOnly include these domains in results
languageNoLanguage code for search results (e.g., 'en')
numResultsNoNumber of results to return (default: 5)
queryYesThe search query to look up
regionNoRegion code for search results (e.g., 'us')
resultTypeNoType of results to return

Implementation Reference

  • The handler function that executes the web_search tool logic. It prepares a crawl request, sends it to an external API using axios, formats the results into a JSON string, and returns them as MCP content. Handles errors appropriately.
    async (params) => {
      try {
        console.error(`Performing web search for: ${params.query}`);
    
        // Prepare request payload for crawler API
        const requestPayload: CrawlRequest = {
          query: params.query,
          numResults: params.numResults ?? MAX_SEARCH_RESULT,
          language: params.language,
          region: params.region,
          filters: {
            excludeDomains: params.excludeDomains,
            includeDomains: params.includeDomains,
            excludeTerms: params.excludeTerms,
            resultType: params.resultType as "all" | "news" | "blogs",
          },
        };
    
        // Call the crawler API
        console.error(`Sending request to ${API_URL}/crawl`);
        const response = await axios.post<CrawlResponse>(
          `${API_URL}/crawl`,
          requestPayload
        );
    
        // Format the response for the MCP client
        const results = response.data.results.map((result) => ({
          title: result.title,
          snippet: result.excerpt,
          text: result.text,
          url: result.url,
          siteName: result.siteName || "",
          byline: result.byline || "",
        }));
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  query: response.data.query,
                  results: results,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        console.error("Error performing web search:", error);
    
        if (axios.isAxiosError(error)) {
          const errorMessage = error.response?.data?.error || error.message;
          return {
            content: [{ type: "text", text: `Error: ${errorMessage}` }],
            isError: true,
          };
        }
    
        return {
          content: [
            {
              type: "text",
              text: `Error: ${
                error instanceof Error ? error.message : "Unknown error"
              }`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema for the web_search tool defined using Zod validators for parameters like query, numResults, language, region, filters, etc.
    {
      query: z.string().describe("The search query to look up"),
      numResults: z
        .number()
        .optional()
        .describe(
          `Number of results to return (default: ${MAX_SEARCH_RESULT})`
        ),
      language: z
        .string()
        .optional()
        .describe("Language code for search results (e.g., 'en')"),
      region: z
        .string()
        .optional()
        .describe("Region code for search results (e.g., 'us')"),
      excludeDomains: z
        .array(z.string())
        .optional()
        .describe("Domains to exclude from results"),
      includeDomains: z
        .array(z.string())
        .optional()
        .describe("Only include these domains in results"),
      excludeTerms: z
        .array(z.string())
        .optional()
        .describe("Terms to exclude from results"),
      resultType: z
        .enum(["all", "news", "blogs"])
        .optional()
        .describe("Type of results to return"),
    },
  • src/index.ts:52-172 (registration)
    Registration of the 'web_search' tool on the MCP server using server.tool(), including description, input schema, and handler function.
    server.tool(
      "web_search",
      "Search the web for information.\n"
      + "Use this tool when you need to search the web for information.\n"
      + "You can use this tool to search for news, blogs, or all types of information.\n"
      + "You can also use this tool to search for information about a specific company or product.\n"
      + "You can also use this tool to search for information about a specific person.\n"
      + "You can also use this tool to search for information about a specific product.\n"
      + "You can also use this tool to search for information about a specific company.\n"
      + "You can also use this tool to search for information about a specific event.\n"
      + "You can also use this tool to search for information about a specific location.\n"
      + "You can also use this tool to search for information about a specific thing.\n"
      + "If you request search with 1 result number and failed, retry with bigger results number.",
      {
        query: z.string().describe("The search query to look up"),
        numResults: z
          .number()
          .optional()
          .describe(
            `Number of results to return (default: ${MAX_SEARCH_RESULT})`
          ),
        language: z
          .string()
          .optional()
          .describe("Language code for search results (e.g., 'en')"),
        region: z
          .string()
          .optional()
          .describe("Region code for search results (e.g., 'us')"),
        excludeDomains: z
          .array(z.string())
          .optional()
          .describe("Domains to exclude from results"),
        includeDomains: z
          .array(z.string())
          .optional()
          .describe("Only include these domains in results"),
        excludeTerms: z
          .array(z.string())
          .optional()
          .describe("Terms to exclude from results"),
        resultType: z
          .enum(["all", "news", "blogs"])
          .optional()
          .describe("Type of results to return"),
      },
      async (params) => {
        try {
          console.error(`Performing web search for: ${params.query}`);
    
          // Prepare request payload for crawler API
          const requestPayload: CrawlRequest = {
            query: params.query,
            numResults: params.numResults ?? MAX_SEARCH_RESULT,
            language: params.language,
            region: params.region,
            filters: {
              excludeDomains: params.excludeDomains,
              includeDomains: params.includeDomains,
              excludeTerms: params.excludeTerms,
              resultType: params.resultType as "all" | "news" | "blogs",
            },
          };
    
          // Call the crawler API
          console.error(`Sending request to ${API_URL}/crawl`);
          const response = await axios.post<CrawlResponse>(
            `${API_URL}/crawl`,
            requestPayload
          );
    
          // Format the response for the MCP client
          const results = response.data.results.map((result) => ({
            title: result.title,
            snippet: result.excerpt,
            text: result.text,
            url: result.url,
            siteName: result.siteName || "",
            byline: result.byline || "",
          }));
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    query: response.data.query,
                    results: results,
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } catch (error) {
          console.error("Error performing web search:", error);
    
          if (axios.isAxiosError(error)) {
            const errorMessage = error.response?.data?.error || error.message;
            return {
              content: [{ type: "text", text: `Error: ${errorMessage}` }],
              isError: true,
            };
          }
    
          return {
            content: [
              {
                type: "text",
                text: `Error: ${
                  error instanceof Error ? error.message : "Unknown error"
                }`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • TypeScript interfaces defining the structure for crawl requests, results, and responses used internally by the web_search handler.
    interface CrawlRequest {
      query: string;
      numResults?: number;
      language?: string;
      region?: string;
      filters?: {
        excludeDomains?: string[];
        includeDomains?: string[];
        excludeTerms?: string[];
        resultType?: "all" | "news" | "blogs";
      };
    }
    
    interface CrawlResult {
      url: string;
      title: string;
      excerpt: string;
      text?: string;
      html?: string;
      siteName?: string;
      byline?: string;
      error?: string | null;
    }
    
    interface CrawlResponse {
      query: string;
      results: CrawlResult[];
      error: string | null;
    }
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. It mentions a retry behavior for failed searches with 1 result, which adds some context, but fails to disclose critical traits like rate limits, authentication needs, pagination, error handling beyond retries, or what the output looks like. For a web search tool with no annotations, this is a significant gap in behavioral disclosure.

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

Conciseness1/5

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

The description is highly repetitive and poorly structured, with multiple sentences repeating similar ideas (e.g., 'You can also use this tool to search for information about a specific...' listed multiple times). It lacks front-loading of key information and contains redundant phrases that do not earn their place, making it inefficient and verbose.

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 complexity of a web search tool with 8 parameters and no output schema or annotations, the description is incomplete. It fails to explain return values, error cases beyond one retry scenario, or operational constraints. The repetitive examples don't compensate for the lack of critical context needed for effective tool 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 schema already documents all 8 parameters thoroughly. The description does not add any meaningful information about parameters beyond implying general search use cases. It mentions 'result number' vaguely, but this doesn't enhance the schema's detailed parameter descriptions. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'Search the web for information' which is clear but vague. It doesn't specify what kind of search engine or service is being used, nor does it differentiate from siblings (though none exist). The purpose is understandable but lacks specificity about the implementation or scope.

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 some examples of when to use the tool (e.g., for news, blogs, companies, products, people, events, locations, or 'things'), but this is repetitive and lacks explicit guidance on when NOT to use it or alternatives. No prerequisites or constraints are mentioned beyond the retry advice, which is minimal guidance.

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/mnhlt/WebSearch-MCP'

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