Skip to main content
Glama
elias-michaias

Onyx Documentation MCP Server

search_github_examples

Find Onyx code examples by topic from GitHub repositories using AI-powered search. Specify a topic and optional limit to retrieve relevant examples for programming tasks.

Instructions

Search Onyx code examples from GitHub repositories by topic

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of examples
topicYesTopic to search for

Implementation Reference

  • MCP tool handler that executes the search_github_examples logic by delegating to SearchEngine and formatting the response for MCP.
    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);
  • Core helper function implementing the GitHub examples search logic using cached data from 'github/examples-by-topic.json'.
    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() }; }
  • Schema definition for the search_github_examples tool, including input parameters and description.
    { 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'] } },
  • Registration of the tool handler in the MCP tool dispatcher switch statement.
    case 'search_github_examples': return await this.searchGitHubExamples(args.topic, args.limit);

Other Tools

Related Tools

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