Skip to main content
Glama
Bankless

Bankless Onchain MCP Server

Official
by Bankless

get_block_info

Retrieve detailed information about a specific block by its number or hash across supported blockchain networks using the Bankless Onchain MCP Server.

Instructions

Gets detailed information about a specific block by number or hash

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockIdYesThe block number or block hash to fetch information for
networkYesThe blockchain network (e.g., "ethereum", "base")

Implementation Reference

  • The core handler function that performs the API call to retrieve block information, handles various Bankless API errors, and returns a BlockInfoVO object.
    export async function getBlockInfo(
        network: string,
        blockId: string
    ): Promise<BlockInfoVO> {
        const token = process.env.BANKLESS_API_TOKEN;
    
        if (!token) {
            throw new BanklessAuthenticationError('BANKLESS_API_TOKEN environment variable is not set');
        }
    
        const endpoint = `${BASE_URL}/chains/${network}/block/${blockId}`;
    
        try {
            const response = await axios.get(
                endpoint,
                {
                    headers: {
                        'Content-Type': 'application/json',
                        'X-BANKLESS-TOKEN': `${token}`
                    }
                }
            );
    
            // Convert server response to match our BlockInfoVO structure
            return response.data
        } catch (error) {
            if (axios.isAxiosError(error)) {
                const statusCode = error.response?.status || 'unknown';
                const errorMessage = error.response?.data?.message || error.message;
    
                if (statusCode === 401 || statusCode === 403) {
                    throw new BanklessAuthenticationError(`Authentication Failed: ${errorMessage}`);
                } else if (statusCode === 404) {
                    throw new BanklessResourceNotFoundError(`Block not found: ${blockId}`);
                } else if (statusCode === 422) {
                    throw new BanklessValidationError(`Validation Error: ${errorMessage}`, error.response?.data);
                } else if (statusCode === 429) {
                    // Extract reset timestamp or default to 60 seconds from now
                    const resetAt = new Date();
                    resetAt.setSeconds(resetAt.getSeconds() + 60);
                    throw new BanklessRateLimitError(`Rate Limit Exceeded: ${errorMessage}`, resetAt);
                }
    
                throw new Error(`Bankless API Error (${statusCode}): ${errorMessage}`);
            }
            throw new Error(`Failed to get block info: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
  • Input schema (BlockInfoSchema) using Zod for validation of network and blockId parameters, and output type definition (BlockInfoVO).
    export const BlockInfoSchema = z.object({
        network: z.string().describe('The blockchain network (e.g., "ethereum", "base")'),
        blockId: z.string().describe('The block number or block hash to fetch information for')
    });
    
    // Block Info Response type - matches the Kotlin model
    export type BlockInfoVO = {
        number: string; // BigInteger in Kotlin
        hash: string;
        timestamp: string; // BigInteger in Kotlin
        baseFeePerGas: string; // BigInteger in Kotlin
        blobGasUsed: string; // BigInteger in Kotlin
        gasUsed: string; // BigInteger in Kotlin
        gasLimit: string; // BigInteger in Kotlin
        readableTimestamp: string; // Instant in Kotlin, ISO string in TypeScript
        network: string; // Added to maintain consistency with other response types
    };
  • src/index.ts:130-134 (registration)
    Registration of the 'get_block_info' tool in the MCP server's tool list for ListToolsRequest, including name, description, and reference to the input schema.
    {
        name: "get_block_info",
        description: "Gets detailed information about a specific block by number or hash",
        inputSchema: zodToJsonSchema(blocks.BlockInfoSchema),
    }
  • src/index.ts:257-266 (registration)
    Dispatch handler in the CallToolRequest switch statement that parses arguments using the schema, calls the getBlockInfo handler, and formats the response for MCP.
    case "get_block_info": {
        const args = blocks.BlockInfoSchema.parse(request.params.arguments);
        const result = await blocks.getBlockInfo(
            args.network,
            args.blockId
        );
        return {
            content: [{type: "text", text: JSON.stringify(result, null, 2)}],
        };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral context. It implies a read-only operation ('Gets'), but doesn't disclose permissions needed, rate limits, error conditions, or what 'detailed information' includes (e.g., block structure, timestamp, transactions). This is inadequate for a tool with zero 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 with zero waste. It front-loads the core purpose ('Gets detailed information about a specific block') and adds necessary qualification ('by number or hash'). Every word earns its place.

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, no output schema, and a read operation with two parameters, the description is incomplete. It doesn't explain what 'detailed information' returns, error handling, or behavioral constraints, leaving significant gaps for the agent to operate effectively in a blockchain context.

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 already documents both parameters fully. The description adds no additional meaning beyond implying blockId can be 'number or hash', which is already stated in the schema. Baseline 3 is appropriate when the schema does the heavy lifting.

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 verb ('Gets') and resource ('detailed information about a specific block'), specifying the action and target. It distinguishes the resource type (block) from siblings like events, contracts, or transactions, but doesn't explicitly differentiate from similar read operations like get_transaction_info beyond the resource type.

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 doesn't mention prerequisites, exclusions, or compare it to sibling tools like get_events or get_transaction_info, leaving the agent to infer usage solely from the tool name and parameters.

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/Bankless/onchain-mcp'

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