Skip to main content
Glama

error_explain

Decode Hedera blockchain error codes and receive debugging guidance to resolve transaction issues, understand error meanings, and find related security recommendations.

Instructions

Explain Hedera error codes and provide debugging guidance.

USE FOR:

  • Understanding cryptic Hedera error codes (e.g., INSUFFICIENT_PAYER_BALANCE)

  • Getting step-by-step solutions for common errors

  • Finding related errors and security recommendations

EXAMPLES:

  • "What does INSUFFICIENT_PAYER_BALANCE mean?"

  • "Explain TOKEN_NOT_ASSOCIATED_TO_ACCOUNT error"

  • "I got CONTRACT_REVERT_EXECUTED - what's wrong?"

  • "List all token-related errors"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
errorCodeNoHedera error code to explain (e.g., INSUFFICIENT_PAYER_BALANCE, TOKEN_NOT_ASSOCIATED_TO_ACCOUNT)
errorMessageNoFull error message to analyze (will extract error code automatically)
categoryNoList all errors in a specific category
searchNoSearch errors by keyword

Implementation Reference

  • The primary handler function executing the 'error_explain' tool logic. It handles error code lookups, message analysis, category listings, keyword searches, and provides debugging guidance using the Hedera error database.
    export async function errorExplain(args: {
      errorCode?: string;
      errorMessage?: string;
      category?: ErrorInfo['category'];
      search?: string;
    }): Promise<{ success: boolean; data?: any; error?: string }> {
      try {
        // If category specified, list all errors in that category
        if (args.category) {
          const categoryErrors = getErrorsByCategory(args.category);
          return {
            success: true,
            data: {
              category: args.category,
              errorCount: categoryErrors.length,
              errors: categoryErrors.map((e) => ({
                code: e.code,
                name: e.name,
                description: e.description,
                solution: e.solution,
              })),
            },
          };
        }
    
        // If search specified, search errors by keyword
        if (args.search) {
          const results = searchErrors(args.search);
          return {
            success: true,
            data: {
              searchTerm: args.search,
              resultCount: results.length,
              results: results.map((e) => ({
                code: e.code,
                name: e.name,
                description: e.description,
                solution: e.solution,
              })),
            },
          };
        }
    
        // If error message provided, analyze it
        if (args.errorMessage) {
          const analysis = analyzeError(args.errorMessage);
          return {
            success: true,
            data: {
              originalError: analysis.originalError,
              detectedCode: analysis.errorCode,
              severity: analysis.severity,
              explanation: analysis.errorInfo
                ? {
                    name: analysis.errorInfo.name,
                    description: analysis.errorInfo.description,
                    cause: analysis.errorInfo.cause,
                    solution: analysis.errorInfo.solution,
                    category: analysis.errorInfo.category,
                  }
                : null,
              guidance: analysis.guidance,
              securityRecommendations: analysis.securityRecommendations,
              optimizationSuggestions: analysis.optimizationSuggestions,
              relatedErrors: analysis.relatedErrors,
            },
          };
        }
    
        // If error code provided, look it up directly
        if (args.errorCode) {
          const errorInfo = getErrorInfo(args.errorCode);
    
          if (!errorInfo) {
            // Try to find similar errors
            const similar = searchErrors(args.errorCode);
            return {
              success: false,
              error: `Error code "${args.errorCode}" not found in database.`,
              data: {
                suggestion: 'Try one of these similar errors:',
                similarErrors: similar.slice(0, 5).map((e) => e.code),
                availableCategories: ['account', 'token', 'contract', 'consensus', 'network', 'transaction', 'key'],
              },
            };
          }
    
          return {
            success: true,
            data: {
              code: errorInfo.code,
              name: errorInfo.name,
              description: errorInfo.description,
              cause: errorInfo.cause,
              solution: errorInfo.solution,
              category: errorInfo.category,
              relatedErrors: getErrorsByCategory(errorInfo.category)
                .filter((e) => e.code !== errorInfo.code)
                .slice(0, 3)
                .map((e) => e.code),
            },
          };
        }
    
        // No input provided - return available error codes summary
        const categories = ['account', 'token', 'contract', 'consensus', 'network', 'transaction', 'key'] as const;
        const summary = categories.map((cat) => ({
          category: cat,
          count: getErrorsByCategory(cat).length,
        }));
    
        return {
          success: true,
          data: {
            message: 'Provide an errorCode, errorMessage, category, or search term',
            totalErrorCodes: Object.keys(HEDERA_ERROR_CODES).length,
            categorySummary: summary,
            exampleUsage: [
              { errorCode: 'INSUFFICIENT_PAYER_BALANCE' },
              { errorMessage: 'Status: TOKEN_NOT_ASSOCIATED_TO_ACCOUNT' },
              { category: 'token' },
              { search: 'balance' },
            ],
          },
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Failed to analyze error',
        };
      }
    }
  • The tool definition object containing the name 'error_explain', detailed description, usage examples, and input schema for parameter validation.
    export const errorAnalysisToolDefinition = {
      name: 'error_explain',
      description: `Explain Hedera error codes and provide debugging guidance.
    
    USE FOR:
    - Understanding cryptic Hedera error codes (e.g., INSUFFICIENT_PAYER_BALANCE)
    - Getting step-by-step solutions for common errors
    - Finding related errors and security recommendations
    
    EXAMPLES:
    - "What does INSUFFICIENT_PAYER_BALANCE mean?"
    - "Explain TOKEN_NOT_ASSOCIATED_TO_ACCOUNT error"
    - "I got CONTRACT_REVERT_EXECUTED - what's wrong?"
    - "List all token-related errors"`,
      inputSchema: {
        type: 'object',
        properties: {
          errorCode: {
            type: 'string',
            description: 'Hedera error code to explain (e.g., INSUFFICIENT_PAYER_BALANCE, TOKEN_NOT_ASSOCIATED_TO_ACCOUNT)',
          },
          errorMessage: {
            type: 'string',
            description: 'Full error message to analyze (will extract error code automatically)',
          },
          category: {
            type: 'string',
            enum: ['account', 'token', 'contract', 'consensus', 'network', 'transaction', 'key', 'file'],
            description: 'List all errors in a specific category',
          },
          search: {
            type: 'string',
            description: 'Search errors by keyword',
          },
        },
      },
    };
  • src/index.ts:529-531 (registration)
    Registration of the error_explain tool by including its definition in the optimizedToolDefinitions array, which is returned by ListToolsRequestSchema handler.
      // Error Analysis (1 tool - 50+ error codes with debugging guidance)
      errorAnalysisToolDefinition,
    ];
  • src/index.ts:665-668 (registration)
    Dispatch registration in the main tool execution switch statement, mapping 'error_explain' calls to the errorExplain handler function.
    // Error Analysis
    case 'error_explain':
      result = await errorExplain(args as any);
      break;
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It states the tool 'explains' and provides 'debugging guidance,' which implies it's a read-only informational tool. However, it doesn't disclose behavioral traits like response format, whether it queries a database or uses AI, rate limits, or authentication needs. The description adds basic context but lacks operational details.

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?

The description is well-structured with clear sections (purpose, USE FOR, EXAMPLES), front-loaded with the core purpose, and every sentence earns its place by providing specific guidance or examples without redundancy. It's appropriately sized for a tool with multiple use cases.

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?

Given the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is fairly complete. It covers purpose, usage guidelines, and examples, which helps an agent understand when and how to invoke it. However, without annotations or output schema, it could benefit from more behavioral context (e.g., response format), but the existing content is sufficient for basic use.

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 100%, so the schema already documents all four parameters well. The description doesn't add parameter-specific semantics beyond what's in the schema, but the 'EXAMPLES' section implicitly illustrates usage patterns (e.g., querying by error code or category). With high schema coverage, the baseline is 3, and the examples provide slight additional value.

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's purpose: 'Explain Hedera error codes and provide debugging guidance.' This is a specific verb ('explain') + resource ('Hedera error codes') combination that distinguishes it from all sibling tools, which focus on account management, contract deployment, token operations, etc., rather than error explanation.

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 scenarios for when to use this tool: understanding cryptic error codes, getting step-by-step solutions, and finding related errors/security recommendations. This provides clear context and distinguishes it from alternatives like general documentation tools (docs_ask, docs_search) or debugging through other means.

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