get_cosmos_latest_block
Retrieve current block data from Cosmos-based blockchains to monitor network activity and verify transactions.
Instructions
Get latest block information on a Cosmos chain
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blockchain | Yes | Blockchain name | |
| network | No | Network type (defaults to mainnet) |
Implementation Reference
- src/handlers/cosmos-handlers.ts:614-629 (handler)MCP tool handler case: extracts blockchain and network parameters from args, calls cosmosService.getLatestBlock, and returns formatted MCP response content or error.case 'get_cosmos_latest_block': { const blockchain = args?.blockchain as string; const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet'; const result = await cosmosService.getLatestBlock(blockchain, network); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; }
- src/handlers/cosmos-handlers.ts:302-320 (registration)Tool registration: defines the tool name, description, and input schema for validation in the registerCosmosHandlers function.{ name: 'get_cosmos_latest_block', description: 'Get latest block information on a Cosmos chain', inputSchema: { type: 'object', properties: { blockchain: { type: 'string', description: 'Blockchain name', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['blockchain'], }, },
- Core implementation: constructs the Cosmos REST API URL for the latest block and performs the HTTP GET request using fetchRest.async getLatestBlock( blockchain: string, network: 'mainnet' | 'testnet' = 'mainnet' ): Promise<EndpointResponse> { try { const baseUrl = this.getRestUrl(blockchain, network); const url = `${baseUrl}/cosmos/base/tendermint/v1beta1/blocks/latest`; return this.fetchRest(url); } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Failed to get Cosmos latest block', }; } }