Skip to main content
Glama

docs_get_example

Find working code examples for Hedera blockchain functionality across multiple programming languages to implement SDK features and learn patterns.

Instructions

Find working code examples for Hedera functionality.

SEARCHES: SDK examples, tutorials, implementation patterns RETURNS: Annotated code with explanations and source references LANGUAGES: JavaScript, TypeScript, Java, Python, Go, Rust, Solidity

USE FOR: Getting implementation code, learning patterns, finding SDK usage.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesWhat code you need
languageNo
complexityNo
limitNoMax examples (default: 5)

Implementation Reference

  • The primary handler function that executes the docs_get_example tool logic. It initializes RAG services, retrieves code examples via ragService.findCodeExamples based on the description, formats them with rankings, code, explanations, sources, and handles errors gracefully.
    export async function docsGetExample(args: { description: string; language?: string; limit?: number; complexity?: string; }) { try { const services = await initializeRAGServices(); if (!services) { throw new Error('RAG services not initialized'); } // Find code examples const examples = await services.ragService.findCodeExamples(args.description, { language: args.language, limit: args.limit || 5, }); if (examples.length === 0) { return { content: [ { type: 'text', text: 'No code examples found matching your description.', }, ], }; } // Format examples const formattedExamples = examples.map((example, index) => ({ rank: index + 1, title: example.title, language: example.language, code: example.code, explanation: example.explanation, sourceUrl: example.sourceUrl, relevance: Math.round(example.score * 100) / 100, })); // Format sources as a readable list at the bottom const sourcesSection = formattedExamples.length > 0 ? '\n\n---\n**Sources:**\n' + formattedExamples.map((ex, i) => `${i + 1}. [${ex.title}](${ex.sourceUrl}) (relevance: ${Math.round(ex.relevance * 100)}%)` ).join('\n') + '\n\n*Answered by HashPilot RAG System*' : '\n\n*Answered by HashPilot RAG System*'; return { content: [ { type: 'text', text: JSON.stringify({ description: args.description, examplesFound: examples.length, examples: formattedExamples, }, null, 2) + sourcesSection, }, ], }; } catch (error: any) { logger.error('docs_get_example failed', { error: error.message }); return { content: [ { type: 'text', text: `Error: ${error.message}`, }, ], isError: true, }; } }
  • The tool schema definition including name, detailed description, and inputSchema specifying parameters like description (required), language, limit, and complexity for validating tool inputs.
    export const docsGetExampleTool = { name: 'docs_get_example', description: 'Find working code examples and implementation patterns for ANY Hedera functionality. Search by feature description: account creation, token operations (create, mint, burn, transfer, freeze), HCS messaging (topic create, message submit), smart contract deployment, file service operations, key management, scheduled transactions, multi-signature workflows, and more. Retrieves annotated code snippets from official Hedera SDKs (JavaScript/TypeScript, Java, Python, Go, Rust) and Solidity smart contracts. Returns code with explanations, context, and source references. Use this when you need actual implementation code, not just conceptual explanations.', inputSchema: { type: 'object' as const, properties: { description: { type: 'string', description: 'Description of the functionality you need code for. Be specific about the operation (e.g., "create fungible token with custom fees", "submit message to HCS topic", "deploy ERC-20 contract on Hedera")', }, language: { type: 'string', enum: ['javascript', 'typescript', 'java', 'python', 'go', 'rust', 'solidity'], description: 'Preferred programming language for the code example', }, limit: { type: 'number', description: 'Maximum number of examples to return', minimum: 1, maximum: 10, default: 5, }, complexity: { type: 'string', enum: ['simple', 'intermediate', 'advanced'], description: 'Desired complexity level of the code example', }, }, required: ['description'], }, };
  • src/index.ts:625-626 (registration)
    The registration of the docs_get_example handler in the main MCP server switch statement, mapping the tool name to the imported docsGetExample function call.
    case 'docs_get_example': result = await docsGetExample(args as any);
  • Inline tool schema definition in the optimizedToolDefinitions array used for listing available tools in the MCP server.
    name: 'docs_get_example', description: `Find working code examples for Hedera functionality. SEARCHES: SDK examples, tutorials, implementation patterns RETURNS: Annotated code with explanations and source references LANGUAGES: JavaScript, TypeScript, Java, Python, Go, Rust, Solidity USE FOR: Getting implementation code, learning patterns, finding SDK usage.`, inputSchema: { type: 'object' as const, properties: { description: { type: 'string', description: 'What code you need' }, language: { type: 'string', enum: ['javascript', 'typescript', 'java', 'python', 'go', 'rust', 'solidity'], }, complexity: { type: 'string', enum: ['simple', 'intermediate', 'advanced'], }, limit: { type: 'number', description: 'Max examples (default: 5)' }, }, required: ['description'], }, },
  • src/index.ts:51-51 (registration)
    Import statement bringing the docsGetExample handler function into the main index file for use in tool registration.
    import { docsSearch, docsAsk, docsGetExample, codeGenerate } from './tools/rag.js';

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/justmert/hashpilot'

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