Skip to main content
Glama

get-mon-balance

Check MON token balances on the Monad testnet by providing a wallet address to monitor cryptocurrency holdings.

Instructions

查询 Monad 测试网地址的 MON 代币余额

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes需要查询的 Monad 测试网地址

Implementation Reference

  • The handler function for the 'get-mon-balance' tool. It queries the MON balance for the given address on Monad testnet using viem's publicClient.getBalance, formats the balance using formatUnits with 18 decimals, and returns a text response or error message.
    async ({ address }) => {
        try {
            // 调用接口查询余额
            const balance = await publicClient.getBalance({
                address: address as `0x${string}`,
            });
    
            // 返回格式化的查询结果
            return {
                content: [
                    {
                        type: "text",
                        text: `地址 ${address} 的 MON 余额为:${formatUnits(balance, 18)} MON`,
                    },
                ],
            };
        } catch (error) {
            // 错误处理
            return {
                content: [
                    {
                        type: "text",
                        text: `查询地址 ${address} 的余额失败:${
                        error instanceof Error ? error.message : String(error)
                        }`,
                    },
                ],
            };
        }
    }
  • Zod schema defining the input parameter 'address' as a string for the Monad testnet address.
    {
        address: z.string().describe("需要查询的 Monad 测试网地址"),
    },
  • src/index.ts:23-28 (registration)
    MCP server creation declaring capabilities including 'get-mon-balance'.
    const server = new McpServer({
        name: "monad-testnet",
        version: "0.0.1",
        // 定义服务器支持的功能列表
        capabilities: ["get-mon-balance", "get-nft-count"]
      });
  • src/index.ts:31-33 (registration)
    Start of the server.tool registration for 'get-mon-balance' tool.
    server.tool(
        // 功能标识符
        "get-mon-balance",
  • Viem publicClient instance for Monad testnet, used by the get-mon-balance handler to query balances.
    const publicClient = createPublicClient({
        chain: monadTestnet,
        transport: http(),
    });
Install Server

Other 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/bble/monad-mcp'

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