binance_account_balances
Retrieve current account balances from Binance using API credentials to monitor cryptocurrency holdings and track portfolio value.
Instructions
Get account balances (requires API key & secret).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/account.ts:13-21 (handler)The execute handler for the binance_account_balances tool. It validates input with balancesSchema, calls the binance.account API endpoint with common params, and returns the balances.async run(input) { balancesSchema.parse(input); try { const res = await binance.account(withCommonParams({})); return res.data?.balances ?? res.data; } catch (err) { throw toToolError(err); } }
- src/tools/account.ts:6-6 (schema)Zod schema for the tool input parameters (empty object, no params required). Used in parameters and parsed in run.const balancesSchema = z.object({});
- src/index.ts:25-40 (registration)Registration of the tool (imported as tool_account_balances and included in tools array at line 19) by adding it to the FastMCP server instance via a loop over all tools.tools.forEach((tool) => { server.addTool({ name: tool.name, description: tool.description, parameters: tool.parameters, execute: async (args) => { try { const result = await tool.run(args); return JSON.stringify(result, null, 2); } catch (error) { const handled = error instanceof ToolError ? error : new ToolError((error as Error).message); throw handled; } }, }); });
- src/binance/client.ts:16-18 (helper)Helper function used in the handler to add recvWindow parameter to API calls.export function withCommonParams<T extends Record<string, unknown>>(params: T) { return { ...params, recvWindow }; }
- src/binance/client.ts:14-15 (helper)Binance Spot client instance used by the tool handler to make the account API call.export const binance = new Spot(apiKey, apiSecret, { baseURL });