get_balance
Check your current account balance across all assets in the simulated crypto exchange to monitor portfolio value and track holdings.
Instructions
Get your current account balance across all assets.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:280-292 (handler)The handler function for get_balance tool that fetches account balance across all assets via API GET /account/balance and returns the data as JSON text content.
async () => { const data = await apiGet<Array<{ asset: string; available: string; locked: string }>>( "/account/balance" ); return { content: [ { type: "text" as const, text: JSON.stringify(data, null, 2), }, ], }; } - src/index.ts:276-293 (registration)Registration of the get_balance tool with the MCP server using server.tool(), defining the tool name, description, empty schema, and handler function.
server.tool( "get_balance", "Get your current account balance across all assets.", {}, async () => { const data = await apiGet<Array<{ asset: string; available: string; locked: string }>>( "/account/balance" ); return { content: [ { type: "text" as const, text: JSON.stringify(data, null, 2), }, ], }; } ); - src/index.ts:279-279 (schema)Empty schema object {} indicating get_balance takes no input parameters.
{}, - src/index.ts:91-100 (helper)The apiGet helper function that performs authenticated HTTP GET requests to the API, used by get_balance to fetch /account/balance endpoint.
async function apiGet<T>(path: string): Promise<T> { const res = await fetch(`${API_BASE}${path}`, { headers: getAuthHeaders(), }); if (!res.ok) { const text = await res.text(); throw new Error(`API GET ${path} failed (${res.status}): ${text}`); } return res.json() as Promise<T>; }