zetrix_get_latest_block
Retrieve current block data from the Zetrix blockchain to monitor network status and transaction activity.
Instructions
Get the latest block information from Zetrix blockchain
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/zetrix-client.ts:241-267 (handler)Core implementation of getLatestBlock method in ZetrixClient class. Fetches latest ledger via GET /getLedger RPC, processes header into structured ZetrixBlock, handles errors.async getLatestBlock(): Promise<ZetrixBlock> { try { // Get latest ledger without seq parameter const response = await this.client.get("/getLedger"); 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, 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 latest block: ${error.message}`); } throw error; } }
- src/index.ts:819-829 (handler)MCP tool handler in switch statement: calls zetrixClient.getLatestBlock() and returns JSON-formatted result as MCP content.case "zetrix_get_latest_block": { const result = await zetrixClient.getLatestBlock(); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
- src/index.ts:97-104 (schema)Tool schema definition: name, description, and empty inputSchema (no parameters required).{ name: "zetrix_get_latest_block", description: "Get the latest block information from Zetrix blockchain", inputSchema: { type: "object", properties: {}, }, },
- src/index.ts:819-829 (registration)Tool registration in the CallToolRequestSchema switch dispatcher.case "zetrix_get_latest_block": { const result = await zetrixClient.getLatestBlock(); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }