Skip to main content
Glama
Doriandarko

Claude Web Search MCP Server

by Doriandarko

web_search

Search the web for real-time information to verify current facts and access up-to-date data not available in training materials.

Instructions

Search the web for real-time information about any topic. Use this tool when you need up-to-date information that might not be available in your training data, or when you need to verify current facts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query to look up on the web
maxResultsNoMaximum number of search results to return (default: 5)
allowedDomainsNoOnly include results from these domains
blockedDomainsNoNever include results from these domains

Implementation Reference

  • Tool schema definition for web_search, including input schema with parameters for query, maxResults, allowedDomains, and blockedDomains.
    const WEB_SEARCH_TOOL: Tool = {
      name: "web_search",
      description: "Search the web for real-time information about any topic. Use this tool when you need up-to-date information that might not be available in your training data, or when you need to verify current facts.",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "The search query to look up on the web"
          },
          maxResults: {
            type: "number",
            description: "Maximum number of search results to return (default: 5)"
          },
          allowedDomains: {
            type: "array",
            items: {
              type: "string"
            },
            description: "Only include results from these domains"
          },
          blockedDomains: {
            type: "array",
            items: {
              type: "string"
            },
            description: "Never include results from these domains"
          }
        },
        required: ["query"]
      }
    };
  • src/index.ts:88-92 (registration)
    Registration of the web_search tool by returning it in the ListToolsRequestSchema handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [WEB_SEARCH_TOOL]
      };
    });
  • The handler for CallToolRequestSchema that executes the web_search tool by invoking Anthropic Claude API with web_search_20250305 tool, processing the results, and returning formatted search results.
    server.setRequestHandler(CallToolRequestSchema, async (request: any) => {
      try {
        const { name, arguments: args } = request.params;
    
        if (name !== "web_search") {
          throw new Error(`Unknown tool: ${name}`);
        }
    
        if (!args || typeof args !== 'object') {
          throw new Error("No arguments provided");
        }
    
        const { query, maxResults = 5, allowedDomains, blockedDomains } = args as any;
    
        if (!query || typeof query !== 'string') {
          throw new Error("Invalid query parameter");
        }
    
        // Prepare the web search tool configuration
        const webSearchTool = {
          type: "web_search_20250305",
          name: "web_search",
          max_uses: maxResults
        };
    
        // Add domain filtering if provided
        if (allowedDomains && Array.isArray(allowedDomains) && allowedDomains.length > 0) {
          (webSearchTool as any).allowed_domains = allowedDomains;
        }
        
        if (blockedDomains && Array.isArray(blockedDomains) && blockedDomains.length > 0) {
          (webSearchTool as any).blocked_domains = blockedDomains;
        }
    
        // Create a Claude message with the web search
        const response = await anthropic.messages.create({
          model: "claude-3-7-sonnet-latest",
          max_tokens: 1024,
          messages: [
            {
              role: "user",
              content: query
            }
          ],
          // @ts-ignore - Ignoring TypeScript error since Claude API does support this
          tools: [webSearchTool]
        });
    
        // Extract and format the search results
        let results = "";
        
        for (const item of response.content) {
          if (item.type === 'text') {
            results += item.text + "\n\n";
          } else if (item.type === 'web_search_tool_result' && 'content' in item && Array.isArray(item.content)) {
            results += "### Search Results\n\n";
            for (const result of item.content) {
              if (result.type === 'web_search_result') {
                results += `- [${result.title}](${result.url})\n`;
                results += `  Last updated: ${result.page_age || 'Unknown'}\n\n`;
              }
            }
          }
        }
    
        // Return the formatted results
        return {
          content: [{ type: "text", text: results.trim() }]
        };
      } catch (error) {
        console.error('Error performing web search:', error);
        return {
          content: [{ type: "text", text: `Error performing web search: ${(error as Error).message}` }],
          isError: true
        };
      }
    });
Behavior3/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 the tool's purpose and usage context but lacks details on behavioral traits such as rate limits, authentication needs, or specific output format. The description does not contradict any annotations, but it could be more informative about operational constraints.

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 front-loaded and concise, consisting of two sentences that directly address purpose and usage guidelines without unnecessary details. Every sentence earns its place by providing essential information efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/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 4 parameters) and no output schema, the description is adequate but could be more complete. It covers purpose and usage well but lacks details on behavioral aspects like result format or limitations. With no annotations, it should ideally provide more context to fully guide the 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 has 100% description coverage, so the schema already documents all parameters well. The description does not add any parameter-specific information beyond what the schema provides, such as examples or additional context. This meets the baseline for high schema coverage, but no extra value is added.

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

Purpose5/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 verbs ('search the web') and resources ('real-time information about any topic'). It distinguishes the tool's function from potential alternatives by emphasizing real-time, up-to-date information that might not be in training data, which is essential for a web search tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use this tool: 'when you need up-to-date information that might not be available in your training data, or when you need to verify current facts.' This provides clear context and guidance for the agent, even though no sibling tools are listed, making it comprehensive for decision-making.

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/Doriandarko/claude-search-mcp'

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