Skip to main content
Glama

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
NameRequiredDescriptionDefault
networkNoNetwork to use: "mainnet" or "testnet"

Implementation Reference

  • 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),
            },
          ],
        };
      }
    );
  • 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"'),
    },
  • 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}`);
      }
    }
  • 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);
      }
    }
  • 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: [],
      },
    },

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/r3e-network/neo-n3-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server