Skip to main content
Glama
elias-michaias

Onyx Documentation MCP Server

search_github_examples

Find Onyx programming code examples on GitHub by topic to help developers learn from real implementations.

Instructions

Search Onyx code examples from GitHub repositories by topic

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topicYesTopic to search for
limitNoMaximum number of examples

Implementation Reference

  • Core handler implementation: Searches pre-crawled GitHub Onyx code examples organized by topic from 'github/examples-by-topic.json'. Matches topics fuzzily and returns relevant code snippets.
    async searchGitHubExamples(topic, limit = 5) { const examplesByTopic = await this.loadData('examplesByTopic'); if (!examplesByTopic) { return { error: 'GitHub examples not available. Run GitHub crawler first.' }; } const availableTopics = Object.keys(examplesByTopic); // Find matching topics (exact match or contains) const matchingTopics = availableTopics.filter(t => t.toLowerCase().includes(topic.toLowerCase()) || topic.toLowerCase().includes(t.toLowerCase()) ); if (matchingTopics.length === 0) { return { query: topic, availableTopics: availableTopics.sort(), examples: [], message: `No examples found for topic "${topic}". Try one of the available topics.` }; } const examples = []; for (const matchingTopic of matchingTopics) { const topicExamples = examplesByTopic[matchingTopic] || []; examples.push(...topicExamples.slice(0, Math.ceil(limit / matchingTopics.length))); } return { query: topic, matchingTopics, examples: examples.slice(0, limit).map(example => ({ file: example.path, repository: example.repository, url: example.url, code: example.code.length > 1000 ? example.code.substring(0, 1000) + '\n... (truncated)' : example.code, fullCodeLength: example.code.length })), totalAvailable: examples.length, availableTopics: availableTopics.sort() }; }
  • Tool registration in TOOL_DEFINITIONS array, including name, description, and input schema for MCP integration.
    { name: 'search_github_examples', description: 'Search Onyx code examples from GitHub repositories by topic', inputSchema: { type: 'object', properties: { topic: { type: 'string', description: 'Topic to search for' }, limit: { type: 'number', description: 'Maximum number of examples', default: 5 } }, required: ['topic'] } },
  • MCP wrapper handler: Delegates to SearchEngine, adds tool-specific message, and formats response with global context.
    async searchGitHubExamples(topic, limit = 5) { const results = await this.searchEngine.searchGitHubExamples(topic, limit); const toolMessage = `Searching GitHub repositories for Onyx code examples related to: "${topic}"`; return this.formatResponse(JSON.stringify(results, null, 2), toolMessage); }
  • Dispatcher switch case in executeTool method that invokes the tool wrapper handler.
    case 'search_github_examples': return await this.searchGitHubExamples(args.topic, args.limit);
  • JSON schema defining input parameters: topic (required string), limit (optional number, default 5).
    inputSchema: { type: 'object', properties: { topic: { type: 'string', description: 'Topic to search for' }, limit: { type: 'number', description: 'Maximum number of examples', default: 5 } }, required: ['topic'] }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/elias-michaias/onyx_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server