Skip to main content
Glama

bnbchain-mcp

Official
by bnb-chain
tools.ts1.81 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" import type { Hash } from "viem" import { z } from "zod" import * as services from "@/evm/services/index.js" import { mcpToolRes } from "@/utils/helper" import { defaultNetworkParam } from "../common/types" export function registerBlockTools(server: McpServer) { // Get block by hash for a specific network server.tool( "get_block_by_hash", "Get a block by hash", { blockHash: z.string().describe("The block hash to look up"), network: defaultNetworkParam }, async ({ network, blockHash }) => { try { const block = await services.getBlockByHash(blockHash as Hash, network) return mcpToolRes.success(block) } catch (error) { return mcpToolRes.error(error, "fetching block by hash") } } ) // Get block by number for a specific network server.tool( "get_block_by_number", "Get a block by number", { blockNumber: z.string().describe("The block number to look up"), network: defaultNetworkParam }, async ({ network, blockNumber }) => { try { const block = await services.getBlockByNumber( parseInt(blockNumber), network ) return mcpToolRes.success(block) } catch (error) { return mcpToolRes.error(error, "fetching block by number") } } ) // Get latest block for a specific network server.tool( "get_latest_block", "Get the latest block", { network: defaultNetworkParam }, async ({ network }) => { try { const block = await services.getLatestBlock(network) return mcpToolRes.success(block) } catch (error) { return mcpToolRes.error(error, "fetching latest block") } } ) }

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/bnb-chain/bnbchain-mcp'

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