search_docs
Locate relevant documentation pages by searching for specific terms within Tambo's technical resources. Streamline access to precise information for efficient problem-solving.
Instructions
Search for documentation pages containing specific terms
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query to find relevant documentation |
Implementation Reference
- src/doc-handler.ts:135-181 (handler)The main handler function that implements the search_docs tool: loads sections if needed, fetches each doc page, checks if query matches, extracts snippets, and returns formatted results.async searchDocs(query: string): Promise<CallToolResult> { if (!query) { throw new Error('Search query is required'); } await this.ensureSectionsLoaded(); const results: SearchResult[] = []; const sectionsToSearch = this.sections.length > 0 ? this.sections : [ { path: '/getting-started/quickstart', title: 'Quickstart' }, { path: '/concepts/components', title: 'Components' }, { path: '/api-reference/react-hooks', title: 'React Hooks' }, ]; for (const section of sectionsToSearch) { try { const response = await this.fetchDocs(section.path); const textContent = response.content[0] && 'text' in response.content[0] ? response.content[0].text : ''; const content = String(textContent || '').toLowerCase(); if (content.includes(query.toLowerCase())) { results.push({ path: section.path, title: section.title, category: section.category, snippet: this.extractSnippet(content, query) }); } } catch (error) { console.error(`Error searching ${section.path}:`, error instanceof Error ? error.message : String(error)); } } return { content: [ { type: 'text', text: results.length > 0 ? `Found ${results.length} results for "${query}":\n\n${results.map(r => `**${r.title}** (${r.path})${r.category ? ` [${r.category}]` : ''}\n${r.snippet}\n` ).join('\n')}` : `No results found for "${query}"`, }, ], }; }
- src/server.ts:50-62 (schema)Input schema definition for the search_docs tool as returned by listTools.name: 'search_docs', description: 'Search for documentation pages containing specific terms', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query to find relevant documentation', }, }, required: ['query'], }, },
- src/server.ts:90-91 (registration)Dispatches calls to the search_docs handler in the CallToolRequest handler.case 'search_docs': return await this.docHandler.searchDocs(args?.query as string);
- src/doc-handler.ts:220-231 (helper)Helper function to extract a relevant snippet around the query match in search results.private extractSnippet(text: string, query: string, length = 150): string { const lowerText = text.toLowerCase(); const lowerQuery = query.toLowerCase(); const index = lowerText.indexOf(lowerQuery); if (index === -1) return text.substring(0, length) + '...'; const start = Math.max(0, index - 50); const end = Math.min(text.length, index + query.length + 100); return '...' + text.substring(start, end) + '...'; }
- src/doc-handler.ts:70-74 (helper)Helper to ensure documentation sections are loaded before searching.async ensureSectionsLoaded(): Promise<void> { if (!this.sectionsLoaded) { await this.discoverDocs(); } }