get_cosmos_latest_block
Retrieve current block information for Cosmos-based blockchains to monitor network activity and track chain progress.
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)Executes the tool logic by extracting blockchain and network parameters from args, calling cosmosService.getLatestBlock, and returning formatted JSON response 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, }; }
- Defines the tool's input schema, description, and name for registration with the MCP server.{ 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'], }, },
- Implements the core logic to fetch the latest block data via Cosmos REST API endpoint constructed from the blockchain service's RPC URL.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', }; } }
- src/index.ts:97-99 (registration)Registers the cosmos tools (including get_cosmos_latest_block) by calling registerCosmosHandlers and including in the server's tools list for listTools requests....registerSolanaHandlers(server, solanaService), ...registerCosmosHandlers(server, cosmosService), ...registerSuiHandlers(server, suiService),
- src/index.ts:124-124 (registration)Dispatches tool execution calls matching cosmos tools to handleCosmosTool.(await handleCosmosTool(name, args, cosmosService)) ||