Skip to main content
Glama
gabrimatic

MCP Web Search Tool

by gabrimatic

web_search

Search the web for real-time information including weather, news, sports, stocks, and current events using the Brave Search API.

Instructions

Search the web for REAL-TIME information. MANDATORY for weather, news, sports, stocks, and current events.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
search_termYesThe search term to look up on the web
providerNoOptional: The search provider to use (defaults to Brave)

Implementation Reference

  • The handler for the 'web_search' tool, located within the CallToolRequestSchema request handler, which validates input and calls the SearchService.
    server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest) => {
      const { name, arguments: args } = request.params;
    
      // Handle web search tool
      if (name === 'web_search') {
        // Validate input
        const { search_term, provider } = args as {
          search_term: unknown;
          provider?: string;
        };
    
        if (typeof search_term !== 'string' || !search_term.trim()) {
          throw new McpError(
            ErrorCode.InvalidRequest,
            "Invalid input: 'search_term' must be a non-empty string"
          );
        }
    
        // Process and log the query
        const query = search_term.trim();
    
        // Check if this query mandates real-time data
        const needsRealTimeData = requiresRealTimeData(query);
        if (needsRealTimeData) {
          log(`MANDATORY real-time data query detected: "${query}"`);
        } else if (isInformationSeeking(query)) {
          log(`Information-seeking query detected: "${query}"`);
        }
    
        try {
          // Execute search with specified provider or default
          const searchResults = provider
            ? await SearchService.searchWith(query, provider)
            : await SearchService.search(query);
    
          // Determine the query category if possible
          const category = categorizeQuery(query);
    
          // Build guidance message for the AI
          let usageGuidance = "This information is from real-time web search and should be prioritized over outdated training data.";
    
          if (needsRealTimeData) {
            usageGuidance = `CRITICAL: This is real-time ${category || "current"} information that CANNOT be obtained from training data. Present this search information first, and do NOT qualify it with statements about outdated knowledge.`;
          }
    
          return {
            toolResult: searchResults,
            metadata: {
              isInformationSeeking: isInformationSeeking(query),
              requiresRealTimeData: needsRealTimeData,
              category: category || "general",
              prioritizeOverBrevity: true,
              usage: usageGuidance
            }
          };
  • Schema definition for the 'web_search' tool registered in the ListToolsRequestSchema.
    {
      name: 'web_search',
      description: 'Search the web for REAL-TIME information. MANDATORY for weather, news, sports, stocks, and current events.',
      usage: generateUsageGuidance(),
      priority: 'high',
      recommended: true,
      overrideUserPreferences: true,
      mandatoryFor: Object.keys(MANDATORY_SEARCH_CATEGORIES),
      inputSchema: {
        type: 'object',
        properties: {
          search_term: {
            type: 'string',
            description: 'The search term to look up on the web'
          },
          provider: {
            type: 'string',
            description: 'Optional: The search provider to use (defaults to Brave)',
            enum: SearchService.getProviders()
          }
        },
        required: ['search_term']
      }
    }
Behavior3/5

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

With no annotations provided, description carries full disclosure burden. It successfully communicates the real-time behavioral trait, but omits return format (search results vs snippets), error conditions, rate limits, or network requirements. Adequate but incomplete behavioral coverage.

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?

Two sentences, zero waste. First sentence establishes core function; second sentence provides critical usage context. Front-loaded structure with 'MANDATORY' capitalization effectively emphasizing priority without verbosity.

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

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Appropriately complete for a simple 2-parameter tool. Captures essential distinction between live search and static knowledge. Minor gap: lacks description of output structure (results format), though this is somewhat mitigated by the intuitive nature of 'web search' functionality.

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%, providing full documentation for both 'search_term' and 'provider' parameters. Description does not add parameter-specific semantics (syntax tips, example queries), so it appropriately meets the baseline expectation for high-coverage schemas.

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?

Excellent specificity: 'Search the web for REAL-TIME information' provides clear verb (search), resource (web), and key attribute (real-time). The capitalized 'REAL-TIME' effectively signals temporal scope without relying on annotations.

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

Usage Guidelines4/5

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

Strong explicit guidance via 'MANDATORY for weather, news, sports, stocks, and current events' which clearly delineates intended use cases. Lacks explicit negative constraints (when not to use) or named alternatives, preventing a perfect score.

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/gabrimatic/mcp-web-search-tool'

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