Skip to main content
Glama

get_latest_block

Read-only

Retrieve the most recent block from an EVM-compatible blockchain network to access current transaction data and network state.

Instructions

Get the latest block from the network

Input Schema

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

Implementation Reference

  • The main handler function for the 'get_latest_block' MCP tool. It fetches the latest block using the services helper, formats it as JSON, and returns it as MCP content. Handles errors appropriately.
    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
        };
      }
    }
  • Zod input schema for the tool, defining an optional 'network' string parameter.
    {
      network: z
        .string()
        .optional()
        .describe('Network name or chain ID. Defaults to Ethereum mainnet.')
    },
  • Registration of the 'get_latest_block' tool on the MCP server using server.tool(), including name, description, schema, and handler function.
    server.tool(
      'get_latest_block',
      'Get the latest block from the EVM',
      {
        network: z
          .string()
          .optional()
          .describe('Network name or chain ID. Defaults to Ethereum mainnet.')
      },
      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
          };
        }
      }
    );
  • Core helper function that retrieves the latest block using viem's publicClient.getBlock(). Called by the tool handler.
    export async function getLatestBlock(network = 'ethereum'): Promise<Block> {
      const client = getPublicClient(network);
      return await client.getBlock();
    } 
  • Top-level call to registerEVMTools(server), which includes the get_latest_block tool registration.
    registerEVMTools(server);
    registerEVMPrompts(server);
Behavior3/5

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

Annotations already provide readOnlyHint=true, destructiveHint=false, and openWorldHint=true, so the agent knows this is a safe, read-only operation that may query external data. The description adds no behavioral context beyond what annotations provide - no information about rate limits, network availability, or response format.

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 maximally concise - a single clear sentence that states exactly what the tool does with zero wasted words. It's perfectly front-loaded with the core functionality.

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

Completeness3/5

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

For a simple read operation with good annotations and full schema coverage, the description is minimally adequate. However, without an output schema, the description doesn't explain what 'latest block' data will be returned (block number, timestamp, transactions, etc.), leaving a gap in understanding the tool's complete behavior.

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?

With 100% schema description coverage, the input schema already fully documents the single optional 'network' parameter. The description adds no parameter information beyond what's in the schema, so it meets but doesn't exceed the baseline expectation.

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 network'), making the purpose immediately understandable. However, it doesn't distinguish this tool from its sibling 'get_block', which likely retrieves specific blocks by number/hash 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. With sibling tools like 'get_block' and 'get_chain_info' available, there's no indication of when this specific 'latest block' retrieval is preferred over other block-related queries.

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/chulanpro5/evm-mcp-server'

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