search_onyx_docs
Search official Onyx programming language documentation to find answers and code examples for development questions.
Instructions
Search official Onyx programming language documentation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query for documentation | |
| limit | No | Maximum number of results |
Implementation Reference
- src/core/mcp-shared.js:198-202 (handler)The primary handler function for the 'search_onyx_docs' tool. It invokes the SearchEngine to perform the documentation search and formats the response with global context and tool-specific message.async searchOnyxDocs(query, limit = 5) { const results = await this.searchEngine.searchDocs(query, limit); const toolMessage = `Searching official Onyx documentation for: "${query}"`; return this.formatResponse(JSON.stringify(results, null, 2), toolMessage); }
- src/core/mcp-shared.js:42-52 (schema)The input schema definition for the 'search_onyx_docs' tool, including name, description, parameters (query required, limit optional), as part of TOOL_DEFINITIONS array.name: 'search_onyx_docs', description: 'Search official Onyx programming language documentation', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query for documentation' }, limit: { type: 'number', description: 'Maximum number of results', default: 5 } }, required: ['query'] } },
- src/core/mcp-shared.js:624-625 (registration)Tool registration in the executeTool dispatcher switch statement, mapping the tool name to its handler function.case 'search_onyx_docs': return await this.searchOnyxDocs(args.query, args.limit);
- src/core/search-engine.js:39-86 (helper)Core search logic helper in SearchEngine class. Loads documentation data from JSON, performs fuzzy search on titles, content, and headings with scoring, sorts results by score, and returns formatted matches.async searchDocs(query, limit = 5) { const docs = await this.loadData('docs'); if (!docs) { return { error: 'Documentation not available. Run crawler first.' }; } const queryLower = query.toLowerCase(); const results = []; for (const doc of docs) { let score = 0; const titleMatch = doc.title.toLowerCase().includes(queryLower); const contentMatch = doc.content.toLowerCase().includes(queryLower); if (titleMatch) score += 10; if (contentMatch) score += 1; // Check headings for (const heading of doc.headings || []) { if (heading.text.toLowerCase().includes(queryLower)) { score += 5; } } if (score > 0) { results.push({ ...doc, score, snippet: this.getSnippet(doc.content, queryLower) }); } } results.sort((a, b) => b.score - a.score); return { query, source: 'documentation', totalFound: results.length, results: results.slice(0, limit).map(r => ({ title: r.title, url: r.url, snippet: r.snippet, headings: (r.headings || []).map(h => h.text).slice(0, 3), score: r.score })) }; }