get_cosmos_validators
Retrieve validator lists for Cosmos blockchains with status filtering to monitor network participation and stake distribution across mainnet or testnet environments.
Instructions
Get list of validators on a Cosmos chain
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blockchain | Yes | Blockchain name | |
| network | No | Network type (defaults to mainnet) | |
| status | No | Validator status filter (defaults to bonded) |
Implementation Reference
- src/handlers/cosmos-handlers.ts:458-474 (handler)The main handler logic for the 'get_cosmos_validators' tool within the handleCosmosTool switch statement. It parses arguments, calls the service method, and formats the response.case 'get_cosmos_validators': { const blockchain = args?.blockchain as string; const status = (args?.status as 'bonded' | 'unbonded' | 'unbonding' | 'all') || 'bonded'; const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet'; const result = await cosmosService.getValidators(blockchain, status, network); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; }
- The input schema and tool definition for 'get_cosmos_validators' used for registration and validation.{ name: 'get_cosmos_validators', description: 'Get list of validators on a Cosmos chain', inputSchema: { type: 'object', properties: { blockchain: { type: 'string', description: 'Blockchain name', }, status: { type: 'string', enum: ['bonded', 'unbonded', 'unbonding', 'all'], description: 'Validator status filter (defaults to bonded)', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['blockchain'], }, },
- src/index.ts:98-98 (registration)Registration of Cosmos tools (including 'get_cosmos_validators') by calling registerCosmosHandlers and adding to the tools list....registerCosmosHandlers(server, cosmosService),
- The supporting service method getValidators that performs the actual API call to fetch validators from the Cosmos chain REST endpoint.async getValidators( blockchain: string, status: 'bonded' | 'unbonded' | 'unbonding' | 'all' = 'bonded', network: 'mainnet' | 'testnet' = 'mainnet' ): Promise<EndpointResponse> { try { const baseUrl = this.getRestUrl(blockchain, network); const statusFilter = status === 'all' ? '' : `?status=${status.toUpperCase()}`; const url = `${baseUrl}/cosmos/staking/v1beta1/validators${statusFilter}`; return this.fetchRest(url); } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Failed to get Cosmos validators', }; } }
- src/index.ts:124-124 (registration)Dispatch/registration of the Cosmos tool handler (handleCosmosTool) in the main tool execution chain.(await handleCosmosTool(name, args, cosmosService)) ||