get_client_info
Retrieve client details and list all accounts and jars from Monobank.
Instructions
Get information about a client and a list of their accounts and jars. The tool can be called not more than 1 time per 60 seconds, otherwise an error will be thrown.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:41-62 (registration)Registers the 'get_client_info' tool on the MCP server via server.tool(). Defines the name, description, empty schema (no input params), and the async handler function.
server.tool( "get_client_info", "Get information about a client and a list of their accounts and jars. The tool can be called not more than 1 time per 60 seconds, otherwise an error will be thrown.", {}, async () => { try { const { baseUrl, monobankApiToken } = getConfig(); const response = await fetchWithErrorHandling( `${baseUrl}/personal/client-info`, { headers: { "X-Token": monobankApiToken, }, }, ); const clientInfo = await parseJsonResponse<ClientInfo>(response); return createSuccessResponse(clientInfo); } catch (error) { return formatErrorAsToolResponse(error, "get client info"); } }, ); - src/index.ts:45-62 (handler)The handler function that executes the tool logic: fetches client info from Monobank API at /personal/client-info using the API token, parses the JSON response as ClientInfo type, and returns a success response.
async () => { try { const { baseUrl, monobankApiToken } = getConfig(); const response = await fetchWithErrorHandling( `${baseUrl}/personal/client-info`, { headers: { "X-Token": monobankApiToken, }, }, ); const clientInfo = await parseJsonResponse<ClientInfo>(response); return createSuccessResponse(clientInfo); } catch (error) { return formatErrorAsToolResponse(error, "get client info"); } }, ); - src/interfaces.ts:32-34 (schema)Defines the ClientInfo interface that represents the structure of the API response returned by the get_client_info tool, including clientId, name, webHookUrl, permissions, accounts, and jars.
export interface ClientInfo { clientId: string; name: string; - src/helpers.ts:43-57 (helper)The fetchWithErrorHandling helper used by the handler to make authenticated HTTP requests to the Monobank API.
export async function fetchWithErrorHandling( url: string, options?: RequestInit, ): Promise<Response> { const response = await fetch(url, options); if (!response.ok) { const errorText = await response .text() .catch(() => response.statusText); throw new Error(`HTTP ${response.status} - ${errorText}`); } return response; } - src/helpers.ts:71-90 (helper)The formatErrorAsToolResponse helper used by the handler to convert errors into proper tool response format.
export function formatErrorAsToolResponse( error: unknown, context: string, ): ToolResponse { if (error instanceof z.ZodError) { return createErrorResponse( `Invalid ${context} format: ${formatZodError(error)}`, ); } if (error instanceof Error) { return createErrorResponse( error.message.startsWith("HTTP") ? `Failed to ${context}: ${error.message}` : `Error ${context}: ${error.message}`, ); } return createErrorResponse(`Error ${context}: Unknown error`); }