get_latest_block
Retrieve the most recent block data from EVM-compatible blockchain networks to monitor chain activity and verify transactions. Specify the network or use the default Ethereum mainnet.
Instructions
Get the latest block from the EVM
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | No | Network name or chain ID. Defaults to Ethereum mainnet. |
Implementation Reference
- src/core/tools.ts:233-256 (handler)MCP tool handler: fetches latest block via service, formats as JSON text response, handles errors.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 }; } }
- src/core/tools.ts:227-232 (schema)Input schema: optional network parameter (string).{ network: z .string() .optional() .describe('Network name or chain ID. Defaults to Ethereum mainnet.') },
- src/core/tools.ts:224-257 (registration)Tool registration: server.tool call registering 'get_latest_block' with description, schema, and handler.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 }; } } );
- src/core/services/blocks.ts:37-43 (helper)Core helper function: retrieves latest block using viem public client for given network./** * Get the latest block for a specific network */ export async function getLatestBlock(network = 'ethereum'): Promise<Block> { const client = getPublicClient(network); return await client.getBlock(); }