zetrix_get_latest_block
Retrieve current block data from the Zetrix blockchain to monitor network status and access transaction information.
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 handler implementation: Queries Zetrix RPC /getLedger endpoint (without seq param) to fetch latest block data, processes response into ZetrixBlock interface.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 server tool handler: switch case that invokes ZetrixClient.getLatestBlock() and formats response for MCP protocol.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 and registration in tools[] array used by MCP ListToolsRequestHandler.{ name: "zetrix_get_latest_block", description: "Get the latest block information from Zetrix blockchain", inputSchema: { type: "object", properties: {}, }, },
- src/zetrix-client.ts:26-33 (schema)TypeScript interface defining the return type structure for block data.export interface ZetrixBlock { blockNumber: number; closeTime: number; hash: string; prevHash: string; txCount: number; transactions?: any[]; }