Skip to main content
Glama
yatotm

Tavily MCP Load Balancer

by yatotm

tavily-search

Search the web for current information and news using AI-powered results, with customizable filters for content type, time range, and domains 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

  • Primary handler function for the 'tavily-search' tool in the stdio MCP server. Prepares search parameters from tool arguments, calls TavilyClient.search(), formats the result, and returns MCP-standard content response.
    private async handleSearch(args: any) {
      const searchParams: TavilySearchParams = {
        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);
    
      return {
        content: [
          {
            type: 'text',
            text: formatResults(result),
          },
        ],
      };
    }
  • JSON Schema defining the input parameters and validation for the 'tavily-search' tool.
    const searchToolSchema = {
      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"]
        },
        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: []
        },
        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: ""
        },
        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"]
    };
  • src/index.ts:442-446 (registration)
    Registration of the 'tavily-search' tool in the ListTools response within the stdio MCP server.
    {
      name: "tavily-search",
      description: searchToolDescription,
      inputSchema: searchToolSchema
    } as Tool,
  • Core implementation of the search functionality in TavilyClient: automatically detects news queries, constructs parameters, and invokes the generic API request maker for Tavily's search 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);
    }
  • Helper function that formats, sanitizes, and structures the raw Tavily search API response into a human-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 behavioral details such as rate limits, authentication requirements, error handling, pagination behavior, or what happens when parameters conflict. For a complex 15-parameter tool with no annotation coverage, this is a significant gap in behavioral transparency.

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 appropriately sized with three sentences that efficiently convey the tool's purpose and key features. It's front-loaded with the core functionality and follows with supporting details. While every sentence earns its place, the third sentence could be slightly more specific about the 'detailed web content analysis' aspect.

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 (15 parameters, no annotations, no output schema), the description is insufficiently complete. It doesn't explain what the tool returns (only mentioning 'relevant web content' vaguely), doesn't address potential parameter conflicts or dependencies, and provides minimal guidance on when to use which parameters. For such a rich parameter set with no structured output documentation, the description should do more to guide effective usage.

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 description mentions 'customizable parameters for result count, content type, and domain filtering,' which adds some context beyond the schema. However, with 100% schema description coverage, the schema already comprehensively documents all 15 parameters. The description provides only high-level categorization without adding meaningful semantic details about specific parameters or their interactions.

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 and returns results, which is a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'search' or 'tavily-crawl', only mentioning it's 'ideal for gathering current information, news, and detailed web content analysis' without sibling comparison.

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 provides implied usage guidance by stating the tool is 'ideal for gathering current information, news, and detailed web content analysis,' which suggests appropriate contexts. However, it doesn't explicitly state when to use this tool versus the sibling tools like 'search', 'tavily-crawl', 'tavily-extract', or 'tavily-map', nor does it provide any exclusion criteria or alternative recommendations.

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