get_onyx_structs
Retrieve Onyx struct definitions and practical examples directly from GitHub, enabling developers to explore and implement structs with ease. Specify struct names or set limits for precise results.
Instructions
Get Onyx struct definitions and examples from GitHub
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of examples | |
| structName | No | Struct name to search for (optional) |
Implementation Reference
- src/core/search-engine.js:164-189 (handler)Core handler logic for retrieving Onyx struct examples from pre-crawled GitHub patterns data, filtering by structName if provided, and formatting results.async getOnyxStructExamples(structName = null, limit = 10) { const patterns = await this.loadData('githubPatterns'); if (!patterns) { return { error: 'GitHub patterns not available. Run GitHub crawler first.' }; } let structs = patterns.structs || []; if (structName) { // Filter by struct name (partial match) structs = structs.filter(struct => struct.definition.toLowerCase().includes(structName.toLowerCase()) ); } return { query: structName, totalFound: structs.length, examples: structs.slice(0, limit).map(struct => ({ definition: struct.definition, file: struct.file, repository: struct.repository, url: struct.url })) }; }
- src/core/mcp-shared.js:219-225 (handler)MCP tool handler for 'get_onyx_structs' that delegates to SearchEngine, generates tool-specific message, and formats the MCP response.async getOnyxStructs(structName, limit = 10) { const results = await this.searchEngine.getOnyxStructExamples(structName, limit); const toolMessage = structName ? `Searching for Onyx struct definitions: "${structName}"` : 'Searching for all available Onyx struct definitions'; return this.formatResponse(JSON.stringify(results, null, 2), toolMessage); }
- src/core/mcp-shared.js:78-88 (schema)Tool schema definition specifying input parameters: optional structName (string) and limit (number, default 10). Used for validation and documentation.{ name: 'get_onyx_structs', description: 'Get Onyx struct definitions and examples from GitHub', inputSchema: { type: 'object', properties: { structName: { type: 'string', description: 'Struct name to search for (optional)' }, limit: { type: 'number', description: 'Maximum number of examples', default: 10 } } } },
- src/mcp-server.js:37-41 (registration)Registers all tools (including get_onyx_structs via TOOL_DEFINITIONS) for MCP listTools request.this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TOOL_DEFINITIONS }; });
- src/core/mcp-shared.js:634-635 (helper)Dispatcher switch case that routes 'get_onyx_structs' tool calls to the handler method.case 'get_onyx_structs': return await this.getOnyxStructs(args.structName, args.limit);