Skip to main content
Glama

get_latest_block

Retrieve the most recent block from Ethereum or compatible networks using the EVM MCP Server, specifying the network or using Ethereum mainnet by default.

Instructions

Get the latest block from the EVM

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkNoNetwork name or chain ID. Defaults to Ethereum mainnet.

Implementation Reference

  • The handler function for the 'get_latest_block' tool. It calls the getLatestBlock service helper, formats the block data as JSON, and handles errors by returning an error response.
    async ({ network = "ethereum" }) => {
      try {
        const block = await services.getLatestBlock(network);
        return { content: [{ type: "text", text: services.helpers.formatJson(block) }] };
      } catch (error) {
        return {
          content: [{ type: "text", text: `Error fetching latest block: ${error instanceof Error ? error.message : String(error)}` }],
          isError: true
        };
      }
    }
  • Schema definition for the 'get_latest_block' tool, including description, input schema (optional network parameter), and annotations indicating it's read-only and not idempotent.
    {
      description: "Get the latest block from the network",
      inputSchema: {
        network: z.string().optional().describe("Network name or chain ID. Defaults to Ethereum mainnet.")
      },
      annotations: {
        title: "Get Latest Block",
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: false,
        openWorldHint: true
      }
    },
  • Registration of the 'get_latest_block' tool with the MCP server using server.registerTool, including name, schema, and handler.
    server.registerTool(
      "get_latest_block",
      {
        description: "Get the latest block from the network",
        inputSchema: {
          network: z.string().optional().describe("Network name or chain ID. Defaults to Ethereum mainnet.")
        },
        annotations: {
          title: "Get Latest Block",
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: false,
          openWorldHint: true
        }
      },
      async ({ network = "ethereum" }) => {
        try {
          const block = await services.getLatestBlock(network);
          return { content: [{ type: "text", text: services.helpers.formatJson(block) }] };
        } catch (error) {
          return {
            content: [{ type: "text", text: `Error fetching latest block: ${error instanceof Error ? error.message : String(error)}` }],
            isError: true
          };
        }
      }
    );
  • Helper function getLatestBlock that uses the viem public client to fetch the latest block for the given network.
    export async function getLatestBlock(network = 'ethereum'): Promise<Block> {
      const client = getPublicClient(network);
      return await client.getBlock();
    } 
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 what the tool does without mentioning whether it's read-only, requires authentication, has rate limits, or what the output format might be (e.g., block object details). This is inadequate for a tool that likely returns critical blockchain data.

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 directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it easy for an agent 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 lack of annotations and output schema, the description is insufficiently complete. It doesn't explain what the tool returns (e.g., block hash, timestamp, transactions) or behavioral aspects like error handling, which are crucial for an EVM block query tool in a server with many blockchain-related siblings.

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?

The input schema has 100% description coverage, with the 'network' parameter clearly documented. The description adds no additional parameter information beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage.

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 ('Get') and resource ('latest block from the EVM'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_block_by_number', which could retrieve blocks by specific numbers rather than the latest one.

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. For example, it doesn't mention using 'get_block_by_number' for historical blocks or 'get_chain_info' for broader network data, leaving the agent to infer usage from tool 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/mcpdotdirect/evm-mcp-server'

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