tavily_search_context
Generate search results optimized for RAG context by providing relevant web content based on your query, with adjustable depth and result limits.
Instructions
Generate context for RAG applications. Returns search results optimized for context generation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The search query | |
| search_depth | No | Search depth | basic |
| max_results | No | Maximum number of results |
Implementation Reference
- index.js:264-280 (handler)Handler implementation for the 'tavily_search_context' tool. Executes a Tavily search with query, optional search_depth and max_results, forces include_raw_content: true, and returns the JSON-stringified result.case "tavily_search_context": { const result = await tavilyClient.search({ query: args.query, search_depth: args.search_depth || "basic", max_results: args.max_results || 5, include_raw_content: true, }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
- index.js:174-199 (registration)Tool registration in the ListTools response, including name, description, and input schema definition for 'tavily_search_context'.{ name: "tavily_search_context", description: "Generate context for RAG applications. Returns search results optimized for context generation.", inputSchema: { type: "object", properties: { query: { type: "string", description: "The search query", }, search_depth: { type: "string", enum: ["basic", "advanced"], description: "Search depth", default: "basic", }, max_results: { type: "number", description: "Maximum number of results", default: 5, }, }, required: ["query"], }, },
- index.js:17-34 (helper)TavilyClient.search helper method that performs the actual API call to Tavily's search endpoint, used by the tavily_search_context handler.async search(params) { const response = await fetch(`${this.baseUrl}/search`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ api_key: this.apiKey, ...params, }), }); if (!response.ok) { throw new Error(`Tavily API error: ${response.statusText}`); } return await response.json(); }