Skip to main content
Glama
Zetrix-Chain

Zetrix MCP Server

Official
by Zetrix-Chain

zetrix_get_ledger

Retrieve block or ledger information from the Zetrix blockchain with optional details including validator lists, consensus values, and fee configurations.

Instructions

Get block/ledger information with optional details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
seqNoBlock sequence number (optional)
withValidatorNoInclude validator list (optional)
withConsValueNoInclude consensus value (optional)
withFeeNoInclude fee configuration (optional)

Implementation Reference

  • Core handler implementation: Makes HTTP GET request to Zetrix RPC /getLedger endpoint with optional seq, with_validator, with_consvalue, with_fee parameters and returns ledger data.
    async getLedger(
      seq?: number,
      withValidator?: boolean,
      withConsValue?: boolean,
      withFee?: boolean
    ): Promise<ZetrixLedger> {
      try {
        const params: any = {};
        if (seq) params.seq = seq;
        if (withValidator) params.with_validator = withValidator;
        if (withConsValue) params.with_consvalue = withConsValue;
        if (withFee) params.with_fee = withFee;
    
        const response = await this.client.get("/getLedger", { params });
    
        if (response.data.error_code !== 0) {
          throw new Error(
            response.data.error_desc || `API Error: ${response.data.error_code}`
          );
        }
    
        return response.data.result;
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new Error(`Failed to get ledger: ${error.message}`);
        }
        throw error;
      }
    }
  • src/index.ts:229-253 (registration)
    Tool registration in the MCP tools list, including name, description, and input schema.
    {
      name: "zetrix_get_ledger",
      description: "Get block/ledger information with optional details",
      inputSchema: {
        type: "object",
        properties: {
          seq: {
            type: "number",
            description: "Block sequence number (optional)",
          },
          withValidator: {
            type: "boolean",
            description: "Include validator list (optional)",
          },
          withConsValue: {
            type: "boolean",
            description: "Include consensus value (optional)",
          },
          withFee: {
            type: "boolean",
            description: "Include fee configuration (optional)",
          },
        },
      },
    },
  • MCP server dispatch handler: Extracts arguments and calls ZetrixClient.getLedger, formats response for MCP protocol.
    case "zetrix_get_ledger": {
      const result = await zetrixClient.getLedger(
        args?.seq as number | undefined,
        args?.withValidator as boolean | undefined,
        args?.withConsValue as boolean | undefined,
        args?.withFee as boolean | undefined
      );
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • TypeScript interface defining the structure of ledger response data.
    export interface ZetrixLedger {
      header: {
        seq: number;
        hash: string;
        previous_hash: string;
        account_tree_hash: string;
        close_time: number;
        consensus_value_hash: string;
        fees_hash: string;
        tx_count: number;
        validators_hash: string;
        version: number;
      };
      transactions?: any[];
      validators?: any[];
      consensus_value?: any;
      fees?: any;
    }

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/Zetrix-Chain/zetrix-mcp-server'

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