Skip to main content
Glama
yatotm

Tavily MCP Load Balancer

by yatotm

search

Search the web for current information and news using customizable parameters like time range, domain filtering, and result count to gather relevant web content.

Instructions

A powerful web search tool that provides comprehensive, real-time results using Tavily's AI search engine. Returns relevant web content with customizable parameters for result count, content type, and domain filtering. Ideal for gathering current information, news, and detailed web content analysis.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countryNoBoost search results from a specific country. This will prioritize content from the selected country in the search results. Available only if topic is general. Country names MUST be written in lowercase, plain English, with spaces and no underscores.
daysNoThe number of days back from the current date to include in the search results. This specifies the time frame of data to be retrieved. Please note that this feature is only available when using the 'news' search topic
end_dateNoWill return all results before the specified end date. Required to be written in the format YYYY-MM-DD
exclude_domainsNoList of domains to specifically exclude, if the user asks to exclude a domain set this to the domain of the site
include_domainsNoA list of domains to specifically include in the search results, if the user asks to search on specific sites set this to the domain of the site
include_faviconNoWhether to include the favicon URL for each result
include_image_descriptionsNoInclude a list of query-related images and their descriptions in the response
include_imagesNoInclude a list of query-related images in the response
include_raw_contentNoInclude the cleaned and parsed HTML content of each search result
max_resultsNoThe maximum number of search results to return
queryYesSearch query
search_depthNoThe depth of the search. It can be 'basic' or 'advanced'basic
start_dateNoWill return all results after the specified start date. Required to be written in the format YYYY-MM-DD.
time_rangeNoThe time range back from the current date to include in the search results. This feature is available for both 'general' and 'news' search topics
topicNoThe category of the search. This will determine which of our agents will be used for the searchgeneral

Implementation Reference

  • Registration of the 'search' tool in the tools/list MCP response, including name, description, and full input schema definition.
    {
      name: 'search',
      description: 'A powerful web search tool that provides comprehensive, real-time results using Tavily\'s AI search engine. Returns relevant web content with customizable parameters for result count, content type, and domain filtering. Ideal for gathering current information, news, and detailed web content analysis.',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query'
          },
          search_depth: {
            type: 'string',
            enum: ['basic', 'advanced'],
            description: 'The depth of the search. It can be \'basic\' or \'advanced\'',
            default: 'basic'
          },
          topic: {
            type: 'string',
            enum: ['general', 'news'],
            description: 'The category of the search. This will determine which of our agents will be used for the search',
            default: 'general'
          },
          days: {
            type: 'number',
            description: 'The number of days back from the current date to include in the search results. This specifies the time frame of data to be retrieved. Please note that this feature is only available when using the \'news\' search topic',
            default: 3
          },
          time_range: {
            type: 'string',
            description: 'The time range back from the current date to include in the search results. This feature is available for both \'general\' and \'news\' search topics',
            enum: ['day', 'week', 'month', 'year', 'd', 'w', 'm', 'y']
          },
          start_date: {
            type: 'string',
            description: 'Will return all results after the specified start date. Required to be written in the format YYYY-MM-DD.',
            default: ''
          },
          end_date: {
            type: 'string',
            description: 'Will return all results before the specified end date. Required to be written in the format YYYY-MM-DD',
            default: ''
          },
          max_results: {
            type: 'number',
            description: 'The maximum number of search results to return',
            default: 10,
            minimum: 5,
            maximum: 20
          },
          include_images: {
            type: 'boolean',
            description: 'Include a list of query-related images in the response',
            default: false
          },
          include_image_descriptions: {
            type: 'boolean',
            description: 'Include a list of query-related images and their descriptions in the response',
            default: false
          },
          include_raw_content: {
            type: 'boolean',
            description: 'Include the cleaned and parsed HTML content of each search result',
            default: false
          },
          include_domains: {
            type: 'array',
            items: { type: 'string' },
            description: 'A list of domains to specifically include in the search results, if the user asks to search on specific sites set this to the domain of the site',
            default: []
          },
          exclude_domains: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of domains to specifically exclude, if the user asks to exclude a domain set this to the domain of the site',
            default: []
          },
          country: {
            type: 'string',
            description: 'Boost search results from a specific country. This will prioritize content from the selected country in the search results. Available only if topic is general. Country names MUST be written in lowercase, plain English, with spaces and no underscores.',
            default: ''
          },
          include_favicon: {
            type: 'boolean',
            description: 'Whether to include the favicon URL for each result',
            default: false
          }
        },
        required: ['query']
      }
    },
  • Handler logic in handleToolCall for the 'search' tool (shared with 'tavily-search'), prepares parameters, calls TavilyClient.search(), formats result with formatResults, and returns MCP content block.
    case 'tavily-search':
    case 'search':
      const query = args?.query ? String(args.query).substring(0, 100) : 'undefined';
      logWithTimestamp('INFO', `Executing search with query: ${query}`);
    
      const searchParams = {
        query: args?.query as string,
        search_depth: (args?.search_depth as 'basic' | 'advanced') || 'basic',
        topic: (args?.topic as 'general' | 'news') || 'general',
        days: (args?.days as number) || 3,
        time_range: args?.time_range as 'day' | 'week' | 'month' | 'year' | 'd' | 'w' | 'm' | 'y',
        start_date: args?.start_date as string,
        end_date: args?.end_date as string,
        max_results: (args?.max_results as number) || 10,
        include_images: (args?.include_images as boolean) || false,
        include_image_descriptions: (args?.include_image_descriptions as boolean) || false,
        include_raw_content: (args?.include_raw_content as boolean) || false,
        include_domains: Array.isArray(args?.include_domains) ? args.include_domains : [],
        exclude_domains: Array.isArray(args?.exclude_domains) ? args.exclude_domains : [],
        country: args?.country as string,
        include_favicon: (args?.include_favicon as boolean) || false
      };
    
      const result = await this.tavilyClient.search(searchParams);
      logWithTimestamp('INFO', `Search completed successfully, response size: ${JSON.stringify(result).length} bytes`);
    
      return {
        content: [
          {
            type: 'text',
            text: formatResults(result),
          },
        ],
      };
  • Core handler/executor in TavilyClient.search(): constructs final params with topic auto-detection and calls makeRequest to POST to Tavily's search API endpoint.
    async search(params: TavilySearchParams): Promise<TavilyResponse> {
      // Add automatic topic detection for news
      const searchParams = {
        ...params,
        topic: params.query.toLowerCase().includes('news') ? 'news' : params.topic
      };
      
      return this.makeRequest(this.baseURLs.search, searchParams);
    }
  • TypeScript interface defining the input parameters for the search tool, matching the JSON schema.
    export interface TavilySearchParams {
      query: string;
      search_depth?: 'basic' | 'advanced';
      topic?: 'general' | 'news';
      days?: number;
      time_range?: 'day' | 'week' | 'month' | 'year' | 'd' | 'w' | 'm' | 'y';
      start_date?: string;
      end_date?: string;
      max_results?: number;
      include_images?: boolean;
      include_image_descriptions?: boolean;
      include_raw_content?: boolean;
      include_domains?: string[];
      exclude_domains?: string[];
      country?: string;
      include_favicon?: boolean;
    }
  • Helper function formatResults that sanitizes, truncates, and formats the raw Tavily search response into a readable text output for the MCP tool response.
    export function formatResults(response: any): string {
      const safeResponse = validateAndSanitizeResponse(response);
    
      if (safeResponse.error) {
        return `Error: ${safeResponse.error}`;
      }
    
      const output = [];
    
      if (safeResponse.answer) {
        output.push(`Answer: ${safeResponse.answer}`);
      }
    
      output.push('Detailed Results:');
      safeResponse.results.forEach((result: any, index: number) => {
        output.push(`\n[${index + 1}] Title: ${result.title}`);
        output.push(`URL: ${result.url}`);
        output.push(`Content: ${result.content}`);
        if (result.raw_content) {
          output.push(`Raw Content: ${result.raw_content}`);
        }
        if (result.score) {
          output.push(`Relevance Score: ${result.score}`);
        }
      });
    
      if (safeResponse.images && safeResponse.images.length > 0) {
        output.push('\nImages:');
        safeResponse.images.forEach((image: any, index: number) => {
          if (typeof image === 'string') {
            output.push(`\n[${index + 1}] URL: ${image}`);
          } else {
            output.push(`\n[${index + 1}] URL: ${image.url}`);
            if (image.description) {
              output.push(`   Description: ${image.description}`);
            }
          }
        });
      }
    
      const result = output.join('\n');
    
      // 最终检查结果大小
      if (result.length > 50000) {
        return result.substring(0, 50000) + '\n\n... [响应内容过长,已截断]';
      }
    
      return result;
    }
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 'real-time results' and 'customizable parameters,' but lacks critical details such as rate limits, authentication requirements, error handling, or what the output format looks like (since there's no output schema). For a complex tool with 15 parameters, this is insufficient.

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 efficiently structured in two sentences, front-loaded with the core purpose and key features. It avoids redundancy, though it could be slightly more concise by integrating the 'ideal for' clause into the first sentence.

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 (15 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain the return format, error conditions, or behavioral constraints like rate limits or data freshness. For a search tool with rich parameters, more contextual guidance is needed to help the agent use it effectively.

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 schema description coverage is 100%, so the schema already documents all 15 parameters thoroughly. The description adds minimal value beyond the schema, mentioning 'customizable parameters for result count, content type, and domain filtering' but without specific details. Baseline 3 is appropriate when the schema does the heavy lifting.

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 performs web search using Tavily's AI engine, providing real-time results. It specifies the verb ('search') and resource ('web content'), but doesn't explicitly differentiate from sibling tools like 'tavily-search' or 'tavily-crawl', which likely have overlapping functionality.

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

Usage Guidelines3/5

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

The description mentions the tool is 'ideal for gathering current information, news, and detailed web content analysis,' which implies usage contexts. However, it doesn't provide explicit guidance on when to use this tool versus the sibling tools (tavily-crawl, tavily-extract, tavily-map, tavily-search), leaving the agent to infer differences.

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/yatotm/tavily-mcp-loadbalancer'

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