Skip to main content
Glama
balance.ts1.46 kB
/** * Tool implementation for getting MON balance on Monad testnet */ import { z } from "zod"; import { formatUnits } from "viem"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { publicClient } from "../../config/server"; /** * Register the balance tool with the MCP server */ export function balanceProvider(server: McpServer) { server.tool( "get-mon-balance", "Get MON balance for an address on Monad testnet", { address: z.string().describe("Monad testnet address to check balance for"), }, async ({ address }) => { try { const balance = await publicClient.getBalance({ address: address as `0x${string}`, }); return { content: [ { type: "text", text: `Balance for ${address}: ${formatUnits(balance, 18)} MON`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to retrieve balance for address: ${address}. Error: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } ); }

Implementation Reference

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/lispking/monad-mcp-server'

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