Skip to main content
Glama

docs_search

Search Hedera documentation, SDK references, tutorials, and specifications using natural language queries to find relevant information quickly.

Instructions

Semantic search across complete Hedera documentation.

INDEXED: Official docs, SDK references (JS/Java/Go/Rust/Python), tutorials, HIPs, service specs RETURNS: Ranked results with titles, URLs, excerpts, relevance scores FILTERS: By content type (tutorial/api/concept/example), language, code presence

USE FOR: Finding specific documentation, discovering relevant tutorials, locating API references.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query in natural language
limitNoMax results (default: 5, max: 20)
contentTypeNo
languageNo

Implementation Reference

  • The main handler function for the 'docs_search' tool. It initializes RAG services, applies filters based on input parameters, performs semantic search on Hedera documentation, formats the top results with metadata (title, URL, excerpt, score, etc.), and returns the response in MCP-compatible format with sources.
    export async function docsSearch(args: {
      query: string;
      limit?: number;
      contentType?: string;
      language?: string;
      hasCode?: boolean;
      queryType?: string;
    }) {
      try {
        const services = await initializeRAGServices();
    
        if (!services) {
          throw new Error('RAG services not initialized');
        }
    
        // Build filters
        const filters: any = {};
        if (args.contentType) filters.contentType = args.contentType;
        if (args.language) filters.language = args.language;
        if (args.hasCode !== undefined) filters.hasCode = args.hasCode;
    
        // Perform search
        const results = await services.ragService.search(args.query, {
          topK: args.limit || 5,
          filters: Object.keys(filters).length > 0 ? filters : undefined,
        });
    
        if (results.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: 'No relevant documentation found for your query.',
              },
            ],
          };
        }
    
        // Format results
        const formattedResults = results.map((result, index) => ({
          rank: index + 1,
          title: result.chunk.metadata.title,
          url: result.chunk.metadata.url,
          contentType: result.chunk.metadata.contentType,
          excerpt: result.chunk.text.substring(0, 300) + (result.chunk.text.length > 300 ? '...' : ''),
          score: Math.round(result.score * 100) / 100,
          hasCode: result.chunk.metadata.hasCode,
          language: result.chunk.metadata.language,
        }));
    
        // Format sources as a readable list at the bottom
        const sourcesSection = formattedResults.length > 0
          ? '\n\n---\n**Sources:**\n' + formattedResults.map((r, i) =>
              `${i + 1}. [${r.title}](${r.url}) (score: ${Math.round(r.score * 100)}%)`
            ).join('\n') + '\n\n*Answered by HashPilot RAG System*'
          : '\n\n*Answered by HashPilot RAG System*';
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                query: args.query,
                resultsFound: results.length,
                results: formattedResults,
              }, null, 2) + sourcesSection,
            },
          ],
        };
      } catch (error: any) {
        logger.error('docs_search failed', { error: error.message });
        return {
          content: [
            {
              type: 'text',
              text: `Error: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Type definition and input schema for the docs_search tool, including detailed properties for query, limits, filters by content type, language, code presence, and query intent.
    export const docsSearchTool = {
      name: 'docs_search',
      description: 'Search Hedera knowledge base using semantic search. Finds documentation, tutorials, API references, conceptual explanations, best practices, architecture patterns, SDK guides, HIPs (Hedera Improvement Proposals), and implementation examples. Use this tool for finding specific information about Hedera services (HTS, HCS, Smart Contract Service), SDK usage (JavaScript, Java, Go, Python, Rust), network configuration, fee schedules, staking parameters, and development patterns. Supports filtering by content type and programming language.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          query: {
            type: 'string',
            description: 'Search query in natural language. Can be technical terms, concepts, questions, or descriptions of what you are looking for.',
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results to return',
            minimum: 1,
            maximum: 20,
            default: 5,
          },
          contentType: {
            type: 'string',
            enum: ['tutorial', 'api', 'concept', 'example', 'guide', 'reference'],
            description: 'Filter by content type: tutorial (step-by-step guides), api (API references), concept (explanatory docs), example (code samples), guide (how-to guides), reference (technical specifications)',
          },
          language: {
            type: 'string',
            enum: ['javascript', 'typescript', 'java', 'python', 'go', 'solidity'],
            description: 'Filter by programming language for SDK-specific results',
          },
          hasCode: {
            type: 'boolean',
            description: 'Only return results with code examples',
          },
          queryType: {
            type: 'string',
            enum: ['conceptual', 'how_to', 'comparison', 'troubleshooting', 'best_practices', 'use_case', 'general'],
            description: 'Type of query to optimize search: conceptual (what is X?), how_to (how do I?), comparison (X vs Y), troubleshooting (errors/issues), best_practices (recommendations), use_case (suitability), general (default)',
          },
        },
        required: ['query'],
      },
    };
  • src/index.ts:619-620 (registration)
    Registration and dispatch of the docs_search tool in the main MCP server request handler switch statement, calling the imported docsSearch handler function.
    case 'docs_search':
      result = await docsSearch(args as any);
  • src/index.ts:317-341 (registration)
    Tool registration in the optimizedToolDefinitions array, defining name, description, and input schema for listing in MCP tool discovery.
      {
        name: 'docs_search',
        description: `Semantic search across complete Hedera documentation.
    
    INDEXED: Official docs, SDK references (JS/Java/Go/Rust/Python), tutorials, HIPs, service specs
    RETURNS: Ranked results with titles, URLs, excerpts, relevance scores
    FILTERS: By content type (tutorial/api/concept/example), language, code presence
    
    USE FOR: Finding specific documentation, discovering relevant tutorials, locating API references.`,
        inputSchema: {
          type: 'object' as const,
          properties: {
            query: { type: 'string', description: 'Search query in natural language' },
            limit: { type: 'number', description: 'Max results (default: 5, max: 20)' },
            contentType: {
              type: 'string',
              enum: ['tutorial', 'api', 'concept', 'example', 'guide', 'reference'],
            },
            language: {
              type: 'string',
              enum: ['javascript', 'typescript', 'java', 'python', 'go', 'solidity'],
            },
          },
          required: ['query'],
        },
  • The input schema registered for the tool in the MCP server.
    inputSchema: {
      type: 'object' as const,
      properties: {
        query: { type: 'string', description: 'Search query in natural language' },
        limit: { type: 'number', description: 'Max results (default: 5, max: 20)' },
        contentType: {
          type: 'string',
          enum: ['tutorial', 'api', 'concept', 'example', 'guide', 'reference'],
        },
        language: {
          type: 'string',
          enum: ['javascript', 'typescript', 'java', 'python', 'go', 'solidity'],
        },
      },
      required: ['query'],
    },
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by specifying what content is indexed, what the tool returns (ranked results with specific fields), and available filters. It doesn't mention rate limits, authentication requirements, or pagination behavior, but provides substantial operational context for a search tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Excellent structure with clear sections (INDEXED, RETURNS, FILTERS, USE FOR) that are front-loaded and information-dense. Every sentence earns its place by providing distinct, valuable information without repetition or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a search tool with 4 parameters, 50% schema coverage, and no output schema, the description provides strong context about indexed content, return format, and use cases. It could benefit from mentioning the default limit value (mentioned in schema but not description) and result format details, but is largely complete for its complexity level.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 50% (query and limit have descriptions, contentType and language don't). The description compensates by explaining the 'content type' filter options and 'language' filter purpose in the FILTERS section, adding meaningful context beyond the bare enum values in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool performs 'Semantic search across complete Hedera documentation' with specific scope (official docs, SDK references, tutorials, HIPs, service specs). It distinguishes from sibling tools like docs_ask and docs_get_example by focusing on comprehensive search rather than specific question-answering or example retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The 'USE FOR' section explicitly lists three specific use cases: 'Finding specific documentation, discovering relevant tutorials, locating API references.' This provides clear guidance on when this tool is appropriate versus other documentation-related tools like docs_ask or general-purpose tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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