Skip to main content
Glama

get-native-currency-balance

Retrieve the native currency balance of a specified blockchain address securely through MetaMask MCP, ensuring private keys remain protected in your crypto wallet.

Instructions

Get the native currency balance of an address.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesAddress to get balance for.

Implementation Reference

  • The tool handler that calls wagmi's getBalance to retrieve the native currency balance for the provided address and returns a text content block with the JSON-stringified result.
    execute: async (args) => { const result = await getBalance(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify(result), }, ], }; },
  • Zod-based input schema defining the required 'address' parameter using abitype's Address type.
    parameters: z.object({ address: Address.describe("Address to get balance for."), }),
  • Core registration of the tool using FastMCP's server.addTool, specifying name, description, schema, and handler.
    server.addTool({ name: "get-native-currency-balance", description: "Get the native currency balance of an address.", parameters: z.object({ address: Address.describe("Address to get balance for."), }), execute: async (args) => { const result = await getBalance(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify(result), }, ], }; }, });
  • Invocation of registerGetBalanceTools within the aggregate registerTools function.
    registerGetBalanceTools(server, wagmiConfig);
  • Utility function used in the handler to serialize response objects, handling BigInts and preventing circular reference errors.
    export function JSONStringify(object: object) { return JSON.stringify(object, getCircularReplacer()); }

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/Xiawpohr/metamask-mcp'

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