MCP server for integrating Tavily search API with LLMs, providing web search, RAG context generation, and QnA capabilities
npm install mcp-tavily-searchA Model Context Protocol (MCP) server for integrating Tavily's search
API with LLMs. This server provides intelligent web search
capabilities optimized for high-quality, factual results, including
context generation for RAG applications and direct question answering.
- 🔍 Advanced web search capabilities through Tavily API
- 🤖 AI-generated summaries of search results
- 🎯 Domain filtering for higher quality results
- 📊 Configurable search depth and parameters
- 🧠 Context generation for RAG applications
- ❓ Direct question answering capabilities
- 💾 Response caching with TTL support
- 📝 Multiple response formats (text, JSON, markdown)
- 🔄 Structured result formatting optimized for LLMs
- 🏗️ Built on the Model Context Protocol
This server requires configuration through your MCP client. Here are
examples for different environments:
Add this to your Cline MCP settings:
``json`
{
"mcpServers": {
"mcp-tavily-search": {
"command": "npx",
"args": ["-y", "mcp-tavily-search"],
"env": {
"TAVILY_API_KEY": "your-tavily-api-key"
}
}
}
}
For WSL environments, add this to your Claude Desktop configuration:
`json`
{
"mcpServers": {
"mcp-tavily-search": {
"command": "wsl.exe",
"args": [
"bash",
"-c",
"source ~/.nvm/nvm.sh && TAVILY_API_KEY=your-tavily-api-key /home/username/.nvm/versions/node/v20.12.1/bin/npx mcp-tavily-search"
]
}
}
}
The server requires the following environment variable:
- TAVILY_API_KEY: Your Tavily API key (required)
The server implements three MCP tools with configurable parameters:
Search the web using Tavily Search API, optimized for high-quality,
factual results.
Parameters:
- query (string, required): Search querysearch_depth
- (string, optional): "basic" (faster) or "advanced"topic
(more thorough). Defaults to "basic"
- (string, optional): "general" or "news". Defaults todays
"general"
- (number, optional): Number of days back to search (news topictime_range
only). Defaults to 3
- (string, optional): Time range for results ('day',max_results
'week', 'month', 'year' or 'd', 'w', 'm', 'y')
- (number, optional): Maximum number of results.include_answer
Defaults to 5
- (boolean, optional): Include AI-generated summary.include_images
Defaults to true
- (boolean, optional): Include related images.include_image_descriptions
Defaults to false
- (boolean, optional): Include imageinclude_raw_content
descriptions. Defaults to false
- (boolean, optional): Include raw HTML content.include_domains
Defaults to false
- (string[], optional): List of trusted domains toexclude_domains
include
- (string[], optional): List of domains to excluderesponse_format
- (string, optional): 'text', 'json', or 'markdown'.cache_ttl
Defaults to 'text'
- (number, optional): Cache time-to-live in seconds.force_refresh
Defaults to 3600
- (boolean, optional): Force fresh results ignoring
cache. Defaults to false
Generate context for RAG applications using Tavily search.
Parameters:
- query (string, required): Search query for context generationmax_tokens
- (number, optional): Maximum length of generatedsearch_depth
context. Defaults to 2000
- (string, optional): "basic" or "advanced". Defaultstopic
to "advanced"
- (string, optional): "general" or "news". Defaults to
"general"
- Other parameters same as tavily_search
Get direct answers to questions using Tavily search.
Parameters:
- query (string, required): Question to be answeredinclude_sources
- (boolean, optional): Include source citations.search_depth
Defaults to true
- (string, optional): "basic" or "advanced". Defaultstopic
to "advanced"
- (string, optional): "general" or "news". Defaults to
"general"
- Other parameters same as tavily_search
The server supports flexible domain filtering through two optional
parameters:
- include_domains: Array of trusted domains to include in searchexclude_domains
results
- : Array of domains to exclude from search results
This allows you to:
- Target specific trusted sources for academic or technical searches
- Exclude potentially unreliable or irrelevant sources
- Customize sources based on your specific needs
- Access all available sources when no filtering is specified
Example domain filtering:
`json`
{
"include_domains": ["arxiv.org", "science.gov"],
"exclude_domains": ["example.com"]
}
1. Clone the repository
2. Install dependencies:
`bash`
pnpm install
3. Build the project:
`bash`
pnpm build
4. Run in development mode:
`bash`
pnpm dev
The project uses changesets for version management. To publish:
1. Create a changeset:
`bash`
pnpm changeset
2. Version the package:
`bash`
pnpm changeset version
3. Publish to npm:
`bash``
pnpm release
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see the LICENSE file for details.
- Built on the
Model Context Protocol
- Powered by Tavily Search API