Skip to main content
Glama

get_block_by_number

Retrieve block details by specifying the block number and network for BNB Chain or other supported networks. Defaults to BSC mainnet if no network is provided.

Instructions

Get a block by number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockNumberYesThe block number to look up
networkNoNetwork name (e.g. 'bsc', 'opbnb', 'ethereum', 'base', etc.) or chain ID. Supports others main popular networks. Defaults to BSC mainnet.bsc

Implementation Reference

  • MCP tool registration for 'get_block_by_number', including description, Zod input schema (blockNumber as string, network), and handler that parses blockNumber to int, calls service.getBlockByNumber, and returns wrapped success/error response.
    server.tool(
      "get_block_by_number",
      "Get a block by number",
      {
        blockNumber: z.string().describe("The block number to look up"),
        network: defaultNetworkParam
      },
      async ({ network, blockNumber }) => {
        try {
          const block = await services.getBlockByNumber(
            parseInt(blockNumber),
            network
          )
          return mcpToolRes.success(block)
        } catch (error) {
          return mcpToolRes.error(error, "fetching block by number")
        }
      }
    )
  • Core handler function that retrieves the specified block using viem's public client for the given network.
    export async function getBlockByNumber(
      blockNumber: number,
      network = "ethereum"
    ): Promise<Block> {
      const client = getPublicClient(network)
      return await client.getBlock({ blockNumber: BigInt(blockNumber) })
    }
  • Shared Zod schema parameter for network input, used in the tool's input schema with default 'bsc'.
    export const defaultNetworkParam = z
      .string()
      .describe(
        "Network name (e.g. 'bsc', 'opbnb', 'ethereum', 'base', etc.) or chain ID. Supports others main popular networks. Defaults to BSC mainnet."
      )
      .default("bsc")
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the action without detailing traits like read-only nature (implied but not explicit), potential rate limits, error conditions, or what the output contains (e.g., block data structure). This is inadequate for a tool with no annotation coverage.

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 wasted words. It's front-loaded and appropriately sized for the tool's purpose, making it easy to parse quickly.

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 the tool's complexity (blockchain data retrieval), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the return value includes (e.g., block details like transactions, timestamps) or behavioral aspects, leaving significant gaps for the agent to operate effectively.

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 fully documents both parameters (blockNumber and network). The description adds no additional meaning beyond what's in the schema, such as format examples or constraints. Baseline score of 3 is appropriate as the schema handles parameter documentation.

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

Purpose3/5

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

The description 'Get a block by number' states the basic action (get) and resource (block), but it's vague about what 'get' entails (e.g., retrieve block details) and doesn't differentiate from sibling tools like 'get_block_by_hash' or 'get_latest_block'. It lacks specificity about the type of data returned or the blockchain context.

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 such as 'get_block_by_hash' or 'get_latest_block'. The description doesn't mention prerequisites, exclusions, or contextual cues for selection, leaving the agent to infer usage based on parameter names 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/bnb-chain/bnbchain-mcp'

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