Skip to main content
Glama

get-block

Fetch blockchain block data by number, hash, or tag to access transaction details and network state information.

Instructions

Fetch information about a block at a block number, hash or tag.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdNoID of chain to use when fetching data.
blockHashNoInformation at a given block hash.
blockNumberNoInformation at a given block number.
blockTagNoInformation at a given block tag. Defaults to 'latest'.latest

Implementation Reference

  • The handler function that executes the get-block tool. It constructs parameters for wagmi's getBlock based on input args and returns the block data as a JSON string in MCP format.
    execute: async (args) => {
      const chainId = args.chainId as typeof wagmiConfig["chains"][number]["id"];
      const blockHash = args.blockHash;
      const blockNumber = args.blockNumber;
      const blockTag = args.blockTag;
    
      const parameters: GetBlockParameters = {
        chainId,
        includeTransactions: false,
      };
      if (blockHash) {
        parameters.blockHash = blockHash;
      }
      else if (blockNumber) {
        parameters.blockNumber = blockNumber;
      }
      else if (blockTag) {
        parameters.blockTag = blockTag;
      }
      const result = await getBlock(wagmiConfig, parameters);
      return {
        content: [
          {
            type: "text",
            text: JSONStringify(result),
          },
        ],
      };
    },
  • Zod schema defining the input parameters (chainId, blockHash, blockNumber, blockTag) for the get-block tool.
    parameters: z.object({
      chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."),
      blockHash: Address.optional().describe("Information at a given block hash."),
      blockNumber: z.coerce.bigint().optional().describe("Information at a given block number."),
      blockTag: z.enum(["latest", "earliest", "pending", "safe", "finalized"]).optional().default("latest").describe("Information at a given block tag. Defaults to 'latest'."),
    }),
  • The server.addTool call that registers the get-block tool with the MCP server, including name, description, schema, and handler.
    server.addTool({
      name: "get-block",
      description: "Fetch information about a block at a block number, hash or tag.",
      parameters: z.object({
        chainId: z.coerce.number().optional().describe("ID of chain to use when fetching data."),
        blockHash: Address.optional().describe("Information at a given block hash."),
        blockNumber: z.coerce.bigint().optional().describe("Information at a given block number."),
        blockTag: z.enum(["latest", "earliest", "pending", "safe", "finalized"]).optional().default("latest").describe("Information at a given block tag. Defaults to 'latest'."),
      }),
      execute: async (args) => {
        const chainId = args.chainId as typeof wagmiConfig["chains"][number]["id"];
        const blockHash = args.blockHash;
        const blockNumber = args.blockNumber;
        const blockTag = args.blockTag;
    
        const parameters: GetBlockParameters = {
          chainId,
          includeTransactions: false,
        };
        if (blockHash) {
          parameters.blockHash = blockHash;
        }
        else if (blockNumber) {
          parameters.blockNumber = blockNumber;
        }
        else if (blockTag) {
          parameters.blockTag = blockTag;
        }
        const result = await getBlock(wagmiConfig, parameters);
        return {
          content: [
            {
              type: "text",
              text: JSONStringify(result),
            },
          ],
        };
      },
    });
  • Invocation of registerGetBlockTools during the overall tools registration process.
    registerGetBlockTools(server, wagmiConfig);
  • src/index.ts:15-15 (registration)
    Top-level call to register all tools, including get-block, in the main application entry point.
    registerTools(server, wagmiConfig);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool fetches information but does not describe what information is returned (e.g., block details like timestamp, transactions), error conditions (e.g., invalid hash), performance traits (e.g., rate limits), or side effects. This is inadequate for a read operation 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 that front-loads the core purpose ('Fetch information about a block') and specifies the input options. There is no wasted wording, and it is appropriately sized for the tool's complexity.

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 does not explain what information is fetched (e.g., block header data, transactions), return format, or error handling. For a tool with four parameters and no structured output documentation, more context is needed to guide effective use by an AI agent.

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 the four parameters (chainId, blockHash, blockNumber, blockTag) with descriptions and enum values. The description adds minimal value by listing the three block identifier types (number, hash, tag) but does not provide additional semantics beyond what the schema already covers, such as usage examples or constraints.

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 action ('Fetch information about a block') and specifies the resource ('a block'), with three alternative identifiers (block number, hash, or tag). However, it does not explicitly distinguish this tool from sibling tools like 'get-block-number' or 'get-transaction', which also retrieve blockchain data but for different resources.

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?

The description provides no guidance on when to use this tool versus alternatives. It mentions three input methods (block number, hash, or tag) but does not specify which to prefer, prerequisites, or exclusions. For example, it does not clarify if this is for general block data retrieval compared to 'get-block-number' (which might only return the number) or 'get-transaction' (for transaction details).

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

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/Xiawpohr/metamask-mcp'

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