Skip to main content
Glama

tavily-search

Search the web for real-time information with customizable parameters for result count, content type, and domain filtering. Gather current news and detailed web content analysis using Tavily's AI search engine.

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
queryYesSearch query
search_depthNoThe depth of the search. It can be 'basic' or 'advanced'basic
topicNoThe category of the search. This will determine which of our agents will be used for the searchgeneral
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
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
max_resultsNoThe maximum number of search results to return
include_imagesNoInclude a list of query-related images in the response
include_image_descriptionsNoInclude a list of query-related images and their descriptions in the response
include_raw_contentNoInclude the cleaned and parsed HTML content of each search result
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
exclude_domainsNoList of domains to specifically exclude, if the user asks to exclude a domain set this to the domain of the site

Implementation Reference

  • The core implementation of the tavily-search tool: makes HTTP POST request to Tavily's search API endpoint with the provided search parameters, handles topic inference for news queries, and manages API errors like invalid key or rate limits.
    async search(params: any): Promise<TavilyResponse> {
      try {
        // Choose endpoint based on whether it's an extract request
        const endpoint = params.url ? this.baseURLs.extract : this.baseURLs.search;
        
        // Add topic: "news" if query contains the word "news"
        const searchParams = {
          ...params,
          api_key: API_KEY,
          topic: params.query.toLowerCase().includes('news') ? 'news' : undefined
        };
        
        const response = await this.axiosInstance.post(endpoint, searchParams);
        return response.data;
      } catch (error: any) {
        if (error.response?.status === 401) {
          throw new Error('Invalid API key');
        } else if (error.response?.status === 429) {
          throw new Error('Usage limit exceeded');
        }
        throw error;
      }
    }
  • JSON schema defining the input parameters for the tavily-search tool, including query, search depth, topic, time filters, result limits, image inclusion, and domain filtering.
    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"],
        },
        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,
        },
        /*
        // Since the mcp server is using AI clients to generate answers form the search results, we don't need to include this feature.
        include_answer: { 
          type: ["boolean", "string"],
          enum: [true, false, "basic", "advanced"],
          description: "Include an answer to original query, generated by an LLM based on Tavily's search results. Can be boolean or string ('basic'/'advanced'). 'basic'/true answer will be quick but less detailed, 'advanced' answer will be more detailed but take longer to generate",
          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: []
        }
      },
      required: ["query"]
  • src/index.ts:357-371 (registration)
    Dispatch case in the CallToolRequestSchema handler that maps tavily-search tool invocation to the search method with parsed arguments.
    case "tavily-search":
      response = await this.search({
        query: args.query,
        search_depth: args.search_depth,
        topic: args.topic,
        days: args.days,
        time_range: args.time_range,
        max_results: args.max_results,
        include_images: args.include_images,
        include_image_descriptions: args.include_image_descriptions,
        include_raw_content: args.include_raw_content,
        include_domains: Array.isArray(args.include_domains) ? args.include_domains : [],
        exclude_domains: Array.isArray(args.exclude_domains) ? args.exclude_domains : []
      });
      break;
  • src/index.ts:112-190 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining name, description, and schema for tavily-search.
    {
      name: "tavily-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"],
          },
          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,
          },
          /*
          // Since the mcp server is using AI clients to generate answers form the search results, we don't need to include this feature.
          include_answer: { 
            type: ["boolean", "string"],
            enum: [true, false, "basic", "advanced"],
            description: "Include an answer to original query, generated by an LLM based on Tavily's search results. Can be boolean or string ('basic'/'advanced'). 'basic'/true answer will be quick but less detailed, 'advanced' answer will be more detailed but take longer to generate",
            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: []
          }
        },
        required: ["query"]
      }
    },
  • Helper function to format the Tavily search response into a human-readable text string for the tool output.
    function formatResults(response: TavilyResponse): string {
      // Format API response into human-readable text
      const output: string[] = [];
    
      // Include answer if available
      if (response.answer) {
        output.push(`Answer: ${response.answer}`);
      }
    
      // Format detailed search results
      output.push('Detailed Results:');
      response.results.forEach(result => {
        output.push(`\nTitle: ${result.title}`);
        output.push(`URL: ${result.url}`);
        output.push(`Content: ${result.content}`);
        if (result.raw_content) {
          output.push(`Raw Content: ${result.raw_content}`);
        }
      });
    
        // Add images section if available
        if (response.images && response.images.length > 0) {
          output.push('\nImages:');
          response.images.forEach((image, index) => {
            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}`);
              }
            }
          });
        }  
    
      return output.join('\n');
    }
Behavior3/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' which are useful, but doesn't cover important aspects like rate limits, authentication requirements, error conditions, or what the response structure looks like. The description provides basic behavioral context but leaves significant gaps.

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 efficiently structured in two sentences that each earn their place. The first sentence establishes the core functionality and key features, while the second sentence provides usage context. There's zero wasted language or redundancy.

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?

For a complex tool with 11 parameters and no output schema, the description provides adequate but incomplete context. It covers the purpose and high-level capabilities well, but given the parameter complexity and absence of annotations, it should do more to explain behavioral aspects like response format, error handling, or performance characteristics.

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?

With 100% schema description coverage, the schema already documents all 11 parameters thoroughly. The description mentions 'customizable parameters for result count, content type, and domain filtering' which aligns with some parameters but doesn't add meaningful semantic context beyond what the schema provides. The baseline score of 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.

Purpose5/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 search engine' and returns 'relevant web content', which is a specific verb+resource combination. It distinguishes from sibling tools by focusing on search rather than crawling, extraction, or mapping operations mentioned in the sibling list.

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?

The description provides clear context for when to use this tool ('gathering current information, news, and detailed web content analysis'), but doesn't explicitly state when not to use it or mention alternatives like the sibling tools (tavily-crawl, tavily-extract, tavily-map). The guidance is helpful but lacks explicit exclusion criteria.

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

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