tavily server
Enables AI assistants to perform up-to-date web searches through the Tavily API, providing comprehensive search results with AI-generated summaries.
Enables AI assistants to perform up-to-date web searches through the Tavily API, providing comprehensive search results with AI-generated summaries.
A Model Context Protocol (MCP) server that provides AI-powered search capabilities using the Tavily API. This server enables AI assistants to perform comprehensive web searches and retrieve relevant, up-to-date information.
Clone the repository:
git clone https://github.com/it-beard/tavily-server.git
cd tavily-mcp-server
Install dependencies:
npm install
Build the project:
npm run build
This server can be used with any MCP client. Below are configuration instructions for popular clients:
If you're using Cline (the VSCode extension for Claude), create or modify the MCP settings file at:
- macOS: ~/Library/Application Support/Cursor/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
- Windows: %APPDATA%CursorUserglobalStoragesaoudrizwan.claude-devsettingscline_mcp_settings.json
- Linux: ~/.config/Cursor/User/globalStorage/saoudrizwan.claude-devsettingscline_mcp_settings.json
Add the following configuration (replace paths and API key with your own):
{
"mcpServers": {
"tavily": {
"command": "node",
"args": ["/path/to/tavily-server/build/index.js"],
"env": {
"TAVILY_API_KEY": "your-api-key-here"
}
}
}
}
If you're using the Claude Desktop app, modify the configuration file at:
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
- Windows: %APPDATA%Claudeclaude_desktop_config.json
- Linux: ~/.config/Claude/claude_desktop_config.json
Use the same configuration format as shown above.
For other MCP clients, consult their documentation for the correct configuration file location and format. The server configuration should include:
1. Command to run the server (typically node
)
2. Path to the compiled server file
3. Environment variables including the Tavily API key
The server provides a single tool named search
with the following parameters:
query
(string): The search query to executesearch_depth
(string): Either "basic" (faster) or "advanced" (more comprehensive)// Example using the MCP SDK
const result = await mcpClient.callTool("tavily", "search", {
query: "latest developments in artificial intelligence",
search_depth: "basic"
});
The server provides both static and dynamic resources for flexible data access:
tavily://last-search/result
: Returns the results of the most recent search querytavily://search/{query}
: Access search results for any querytavily://search/artificial%20intelligence
Resources in MCP provide an alternative way to access data compared to tools: - Tools are for executing operations (like performing a new search) - Resources are for accessing data (like retrieving existing search results) - Resource URIs can be stored and accessed later - Resources support both static (fixed) and dynamic (templated) access patterns
interface SearchResponse {
query: string;
answer: string;
results: Array<{
title: string;
url: string;
content: string;
score: number;
}>;
response_time: number;
}
The server implements comprehensive persistent storage for search results:
data
directorydata/searches.json
contains all historical search resultstavily-server/
├── src/
│ └── index.ts # Main server implementation
├── data/ # Persistent storage directory
│ └── searches.json # Search history and cache storage
├── build/ # Compiled JavaScript files
├── package.json # Project dependencies and scripts
└── tsconfig.json # TypeScript configuration
npm run build
: Compile TypeScript and make the output executablenpm run start
: Start the MCP server (after building)npm run dev
: Run the server in development modeThe server provides detailed error messages for common issues: - Invalid API key - Network errors - Invalid search parameters - API rate limiting - Resource not found - Invalid resource URIs - Storage read/write errors
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.