fetch_docs
Retrieve specific documentation content from Tambo Docs by providing the desired path, enabling efficient access to technical resources.
Instructions
Fetch documentation content from docs.tambo.co
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The documentation path to fetch (e.g., /concepts/components) |
Implementation Reference
- src/doc-handler.ts:76-133 (handler)The main handler function for the 'fetch_docs' tool. Fetches HTML content from 'https://docs.tambo.co' + path, parses it using Cheerio to extract title and main content, cleans the text, caches the result for 10 minutes, and returns a CallToolResult with markdown-formatted output.async fetchDocs(path: string): Promise<CallToolResult> { if (!path) { throw new Error('Path is required'); } const url = `https://docs.tambo.co${path}`; const cacheKey = `docs:${path}`; const cached = this.cache.get(cacheKey); if (cached && Date.now() - cached.timestamp < 10 * 60 * 1000) { return cached.content; } try { const response = await fetch(url); if (!response.ok) { throw new Error(`Failed to fetch ${url}: ${response.status}`); } const html = await response.text(); const $ = cheerio.load(html); const title = $('h1').first().text().trim() || $('[data-title]').first().text().trim() || $('title').text().trim(); let contentElement = $('main').first(); if (contentElement.length === 0) { contentElement = $('article').first(); } if (contentElement.length === 0) { contentElement = $('.content, [data-content], .markdown-body').first(); } const content = contentElement.length > 0 ? contentElement.html() : ''; const cleanContent = content ? cheerio.load(content).text().replace(/\s+/g, ' ').trim() : 'No content found'; const result: CallToolResult = { content: [ { type: 'text', text: `# ${title}\n\nPath: ${path}\nURL: ${url}\n\n${cleanContent}`, }, ], }; this.cache.set(cacheKey, { content: result, timestamp: Date.now() }); return result; } catch (error) { throw new Error(`Failed to fetch documentation: ${error instanceof Error ? error.message : String(error)}`); } }
- src/server.ts:35-48 (registration)Registration of the 'fetch_docs' tool in the ListToolsRequestHandler, including name, description, and input schema.{ name: 'fetch_docs', description: 'Fetch documentation content from docs.tambo.co', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'The documentation path to fetch (e.g., /concepts/components)', }, }, required: ['path'], }, },
- src/server.ts:88-89 (registration)Dispatch/registration in the CallToolRequestHandler switch statement, routing 'fetch_docs' calls to the docHandler.fetchDocs method.case 'fetch_docs': return await this.docHandler.fetchDocs(args?.path as string);
- src/server.ts:38-47 (schema)Input schema definition for the 'fetch_docs' tool, specifying a required 'path' string parameter.inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'The documentation path to fetch (e.g., /concepts/components)', }, }, required: ['path'], },