Skip to main content
Glama

get_block

Retrieve VeChain block information using block ID, number, or keywords like best, justified, or finalized. Returns structured data or RLP-encoded blocks with optional transaction expansion.

Instructions

Retrieve information about a VeChain block by its revision (block ID, number, or keywords: best | justified | finalized).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
revisionNoBlock revision: hex ID, block number, or keywords: best | justified | finalizedbest
expandedNoReturn transactions expanded (objects) instead of just IDs (default: false)
rawNoReturn RLP-encoded block instead of structured JSON (default: false)

Implementation Reference

  • The main handler function (callback) for the 'get_block' tool. It constructs the API URL for the Thorest /blocks endpoint, fetches the block data with timeout and error handling, and returns the JSON response or error details.
    callback: async ({ revision, expanded = false, raw = false }: { revision: z.ZodDefault<z.ZodUnion<[z.ZodEnum<[REVISION.Best, REVISION.Justified, REVISION.Finalized]>, z.ZodNumber, z.ZodString]>>, expanded?: boolean, raw?: boolean }) => { const base = isMainnet ? vechainConfig.mainnet.thorestApiBaseUrl : vechainConfig.testnet.thorestApiBaseUrl; const path = `/blocks/${encodeURIComponent(String(revision))}`; const qs = new URLSearchParams(); if (typeof expanded === "boolean") qs.set("expanded", String(expanded)); if (typeof raw === "boolean") qs.set("raw", String(raw)); const url = `${base}${path}${qs.toString() ? `?${qs.toString()}` : ""}`; const controller = new AbortController(); const timeout = setTimeout(() => controller.abort(), isMainnet ? vechainConfig.mainnet.controllerAbortTimeout : vechainConfig.testnet.controllerAbortTimeout); try { const res = await fetch(url, { signal: controller.signal }); if (!res.ok) { const bodyText = await res.text().catch(() => ""); throw new Error( `VeChain node responded ${res.status} ${res.statusText}${bodyText ? `: ${bodyText}` : "" }` ); } const data = await res.json(); if (data == null) { return { content: [ { type: "text", text: JSON.stringify( { message: "Block not found", revision: String(revision), expanded, raw, }, null, 2 ), }, ], }; } return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; } catch (err) { const isAbort = (err as Error)?.name === "AbortError"; return { content: [ { type: "text", text: JSON.stringify( { error: isAbort ? "Request timed out" : "Failed to fetch VeChain block", reason: String((err as Error)?.message ?? err), url, }, null, 2 ), }, ], }; } finally { clearTimeout(timeout); } }
  • Zod input schema defining parameters for the 'get_block' tool: revision (required, default 'best'), optional expanded and raw booleans.
    inputSchema: { revision: z .union([ z.enum([REVISION.Best, REVISION.Justified, REVISION.Finalized]), z.number().int().nonnegative(), z .string() .min(1) .describe("Block ID (hex) or block number as string"), ]) .describe( "Block revision: hex ID, block number, or keywords: best | justified | finalized" ) .default("best"), expanded: z .boolean() .optional() .describe( "Return transactions expanded (objects) instead of just IDs (default: false)" ), raw: z .boolean() .optional() .describe("Return RLP-encoded block instead of structured JSON (default: false)"), },
  • src/server.ts:74-92 (registration)
    Registration loop in the MCP server that registers all vechainTools (including 'get_block') by calling server.registerTool with the tool's name, schema, and a wrapper that invokes the tool's callback.
    for (const t of vechainTools) { server.registerTool( t.name, { title: t.name, description: t.description, inputSchema: t.inputSchema }, async (args) => { const result = await t.callback(args); return { content: result.content.map(item => ({ ...item, type: "text" as const })) }; } ); }

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/leandrogavidia/vechain-mcp-server'

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