Skip to main content
Glama

get-mon-balance

Retrieve the MON token balance for a specified address on the Monad testnet using the Model Context Protocol server. Check token holdings with a simple address input.

Instructions

Get MON balance for an address on Monad testnet

Input Schema

NameRequiredDescriptionDefault
addressYesMonad testnet address to check balance for

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "address": { "description": "Monad testnet address to check balance for", "type": "string" } }, "required": [ "address" ], "type": "object" }

Implementation Reference

  • The handler function that implements the core logic of the 'get-mon-balance' tool. It queries the MON balance for the given address on the Monad testnet using viem's publicClient, formats the result using formatUnits with 18 decimals, and returns a formatted text response or error message.
    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)}`, }, ], }; }
  • The input schema for the 'get-mon-balance' tool, defined using Zod. Requires a single 'address' parameter as a string describing the Monad testnet address.
    { address: z.string().describe("Monad testnet address to check balance for"), },
  • The balanceProvider function that registers the 'get-mon-balance' tool with the MCP server using server.tool(), including the tool name, description, input schema, and handler function.
    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)}`, }, ], }; } } );
  • Within walletProvider, calls balanceProvider to register the get-mon-balance tool as part of wallet tools.
    balanceProvider(server); sendMonProvider(server);
  • src/index.ts:24-24 (registration)
    In the main server initialization, calls walletProvider(server) which chains to registering get-mon-balance.
    walletProvider(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/lispking/monad-mcp-server'

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