Skip to main content
Glama

helius_get_latest_blockhash

Retrieve the current blockhash from Solana for constructing transactions.

Instructions

Get the latest blockhash from the Solana blockchain

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commitmentNo

Implementation Reference

  • Handler function that calls connection.getLatestBlockhash() and returns the blockhash and last valid block height.
    export const getLatestBlockhashHandler = async (input: GetLatestBlockhashInput): Promise<ToolResultSchema> => {
      try {
        const { blockhash, lastValidBlockHeight } = await (helius as any as Helius).connection.getLatestBlockhash(input.commitment);
        return createSuccessResponse(`Latest blockhash: ${blockhash}, Last valid block height: ${lastValidBlockHeight}`);
      } catch (error) {
        return createErrorResponse(`Error getting latest blockhash: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Type definitions for GetLatestBlockhashInput (optional commitment) and GetLatestBlockhashOutput (blockhash + lastValidBlockHeight).
    export type GetLatestBlockhashInput = {
      commitment?: "confirmed" | "finalized" | "processed";
    }
    
    export type GetLatestBlockhashOutput = {
      blockhash: string;
      lastValidBlockHeight: number;
    }
  • src/tools.ts:91-101 (registration)
    Tool registration defining the name, description, and input schema for helius_get_latest_blockhash.
    {
      name: "helius_get_latest_blockhash",
      description: "Get the latest blockhash from the Solana blockchain",
      inputSchema: {
        type: "object",
        properties: {
          commitment: { type: "string", enum: ["confirmed", "finalized", "processed"] }
        },
        required: []
      }
    },
  • src/tools.ts:555-555 (registration)
    Mapping the tool name string to its handler function in the handlers dictionary.
    "helius_get_latest_blockhash": getLatestBlockhashHandler,
  • Utility functions createSuccessResponse and createErrorResponse used by the handler to format responses.
    export const createSuccessResponse = (message: string): ToolResultSchema => {
      return {
        content: [{
          type: "text",
          text: message
        }],
        isError: false
      };
    };
    
    /**
     * Utility function to validate a public key and return an error response if invalid
     * @param publicKeyString The public key string to validate
     * @returns Either a PublicKey object or a ToolResultSchema with an error message
     */
    export const validatePublicKey = (publicKeyString: string): PublicKey | ToolResultSchema => {
      const { publicKey, error } = createPublicKey(publicKeyString);
      if (error) {
        return createErrorResponse(error);
      }
      return publicKey!;
    }; 
Behavior2/5

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

No annotations are provided, so the description must carry the full burden. It only says 'Get' but does not disclose behavior on errors, network issues, or the nature of the returned data (e.g., format or type).

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 a single concise sentence that front-loads the essential purpose. Every word contributes to clarity without redundancy.

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

Completeness3/5

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

For a simple getter with one parameter and no output schema, the description is adequate but minimal. It could mention that it returns a blockhash string or that commitment affects finality, especially since no output schema exists.

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

Parameters1/5

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

The input schema has one optional parameter 'commitment' with enum values, but the description does not mention it or explain its meaning. With 0% schema description coverage, the description adds no value beyond the raw 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 retrieves the latest blockhash from the Solana blockchain, with a specific verb ('Get') and resource ('latest blockhash'). This distinguishes it from sibling tools like helius_get_block_height.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. The description only states the function without context on prerequisites or use cases.

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/dcSpark/mcp-server-helius'

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