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
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Address to get balance for. |
Implementation Reference
- src/tools/get-balance.ts:15-25 (handler)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), }, ], }; },
- src/tools/get-balance.ts:12-14 (schema)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."), }),
- src/tools/get-balance.ts:9-26 (registration)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), }, ], }; }, });
- src/tools/register-tools.ts:41-41 (registration)Invocation of registerGetBalanceTools within the aggregate registerTools function.registerGetBalanceTools(server, wagmiConfig);
- src/utils/json-stringify.ts:17-19 (helper)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()); }