Skip to main content
Glama
cuongpo

Rootstock MCP Server

by cuongpo

get_block

Retrieve block details from the Rootstock blockchain using either block number or hash for informed blockchain analysis and operations.

Instructions

Get block information by number or hash

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockHashNoBlock hash (alternative to blockNumber)
blockNumberNoBlock number (alternative to blockHash)

Implementation Reference

  • The handler function that executes the 'get_block' tool logic. It calls RootstockClient.getBlock and formats the response as MCP content.
    private async handleGetBlock(params: GetBlockParams) {
      try {
        const block = await this.rootstockClient.getBlock(params.blockNumber, params.blockHash);
        return {
          content: [
            {
              type: 'text',
              text: `Block Information:\n\nNumber: ${block.number}\nHash: ${block.hash}\nTimestamp: ${new Date(block.timestamp * 1000).toISOString()}\nTransactions: ${block.transactionCount}\nGas Used: ${block.gasUsed}\nGas Limit: ${block.gasLimit}\nMiner: ${block.miner}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to get block: ${error}`);
      }
    }
  • src/index.ts:269-285 (registration)
    Registration of the 'get_block' tool in the MCP server's listAvailableTools method, defining name, description, and input schema.
    {
      name: 'get_block',
      description: 'Get block information by number or hash',
      inputSchema: {
        type: 'object',
        properties: {
          blockNumber: {
            type: 'number',
            description: 'Block number (alternative to blockHash)',
          },
          blockHash: {
            type: 'string',
            description: 'Block hash (alternative to blockNumber)',
          },
        },
      },
    },
  • TypeScript interface defining the input parameters for the get_block tool.
    export interface GetBlockParams {
      blockNumber?: number;
      blockHash?: string;
    }
  • Supporting method in RootstockClient that performs the actual blockchain RPC call to retrieve block data using ethers.js.
    async getBlock(blockNumber?: number, blockHash?: string): Promise<BlockInfo> {
      try {
        let block;
        if (blockHash) {
          block = await this.getProvider().getBlock(blockHash);
        } else if (blockNumber !== undefined) {
          block = await this.getProvider().getBlock(blockNumber);
        } else {
          block = await this.getProvider().getBlock('latest');
        }
    
        if (!block) {
          throw new Error('Block not found');
        }
    
        return {
          number: block.number,
          hash: block.hash || '',
          parentHash: block.parentHash,
          timestamp: block.timestamp,
          gasLimit: block.gasLimit.toString(),
          gasUsed: block.gasUsed.toString(),
          miner: block.miner,
          difficulty: block.difficulty?.toString(),
          size: block.length || 0,
          transactionCount: block.transactions.length,
        };
      } catch (error) {
        throw new Error(`Failed to get block: ${error}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden but only states what the tool does, not how it behaves. It lacks details on error handling, rate limits, permissions, or return format, which are critical for a read operation in a blockchain context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded and appropriately sized for a simple lookup tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It doesn't explain what 'block information' includes, error cases, or behavioral traits, leaving gaps for a tool in a complex domain like blockchain.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters fully. The description adds minimal value by implying the parameters are alternatives, but doesn't provide additional syntax or format details beyond what the schema offers.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('block information'), specifying the lookup mechanism ('by number or hash'). It distinguishes from siblings like get_transaction or get_balance by focusing on blocks, though it doesn't explicitly contrast with them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites, context, or exclusions, leaving the agent to infer usage from the purpose alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/cuongpo/rootstock-mcp'

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