get_block_count
Retrieve the total number of blocks on the Neo N3 blockchain for a specified network, enabling users to track blockchain progress and verify data integrity.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | No | Network to use: "mainnet" or "testnet" |
Implementation Reference
- src/index.ts:222-244 (handler)Primary MCP tool handler and registration for 'get_block_count'. Retrieves the NeoService for the given network, fetches blockchain information, extracts the block height, and returns it as a formatted text response.this.server.tool( 'get_block_count', { network: z.string().optional().describe('Network to use: "mainnet" or "testnet"'), }, async ({ network }) => { const neoService = await this.getNeoService(network); const info = await neoService.getBlockchainInfo(); const result = { height: info.height, network: neoService.getNetwork() }; return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } );
- src/index.ts:224-226 (schema)Input schema for the 'get_block_count' tool using Zod validation, specifying optional network parameter.{ network: z.string().optional().describe('Network to use: "mainnet" or "testnet"'), },
- src/services/neo-service.ts:524-531 (helper)Helper method in NeoService class that wraps the RPC client's getBlockCount() call to retrieve the current blockchain block height, with error handling.async getBlockCount(): Promise<number> { try { return await this.rpcClient.getBlockCount(); } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; throw new Error(`Failed to get block count: ${errorMessage}`); } }
- src/handlers/tool-handler.ts:37-44 (helper)Alternative or supporting handler function for get_block_count that calls NeoService.getBlockCount() and formats the response (potentially from legacy implementation).async function handleGetBlockCount(input: any, neoService: NeoService): Promise<any> { try { const count = await neoService.getBlockCount(); return createSuccessResponse({ blockCount: count }); } catch (error) { return handleError(error); } }
- src/handlers/tool-handler.ts:375-388 (schema)Detailed input schema definition for the 'get_block_count' tool in tool-handler.ts, including description and network enum validation.name: 'get_block_count', description: 'Get the current block height of the Neo N3 blockchain', inputSchema: { type: 'object', properties: { network: { type: 'string', description: 'Optional: Network to use ("mainnet" or "testnet"). Defaults based on config.', enum: [NeoNetwork.MAINNET, NeoNetwork.TESTNET], }, }, required: [], }, },