zetrix_get_block
Retrieve detailed information about a specific Zetrix blockchain block by providing its height or number to access transaction data and network state.
Instructions
Get information about a specific block by height
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blockNumber | Yes | The block height/number to query |
Implementation Reference
- src/index.ts:83-96 (schema)Tool schema definition including name, description, and input schema requiring blockNumber.{ name: "zetrix_get_block", description: "Get information about a specific block by height", inputSchema: { type: "object", properties: { blockNumber: { type: "number", description: "The block height/number to query", }, }, required: ["blockNumber"], }, },
- src/index.ts:804-817 (registration)Tool registration in the MCP server switch statement, dispatching to zetrixClient.getBlock().case "zetrix_get_block": { if (!args) { throw new Error("Missing arguments"); } const result = await zetrixClient.getBlock(args.blockNumber as number); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
- src/zetrix-client.ts:212-239 (handler)Core handler logic in ZetrixClient.getBlock(): Calls Zetrix API /getLedger with seq parameter, processes response, maps to ZetrixBlock interface, handles errors.async getBlock(blockNumber: number): Promise<ZetrixBlock> { try { const response = await this.client.get("/getLedger", { params: { seq: blockNumber }, }); if (response.data.error_code !== 0) { throw new Error( response.data.error_desc || `API Error: ${response.data.error_code}` ); } const block = response.data.result.header; return { blockNumber: block.seq || blockNumber, closeTime: block.close_time || 0, hash: block.hash || "", prevHash: block.previous_hash || "", txCount: block.tx_count || 0, transactions: response.data.result.transactions, }; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Failed to get block: ${error.message}`); } throw error; } }