get_categories
Retrieve all transaction categories from Monarch Money to organize and analyze financial data for budgeting and spending insights.
Instructions
Get all transaction categories available in Monarch Money
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:554-570 (handler)The main handler function that executes the get_categories tool. It calls the API, handles errors, and returns a formatted response with success status, data, and summary.private async getCategories(): Promise<any> { try { const categories = await this.api.getCategories(); return { success: true, data: categories, summary: `Retrieved ${categories?.length || 0} transaction categories`, }; } catch (error) { throw new Error( `Failed to get categories: ${ error instanceof Error ? error.message : 'Unknown error' }` ); } }
- src/tools.ts:150-159 (registration)Tool registration in getToolDefinitions() that defines the get_categories tool with its name, description, and input schema (no input parameters required).{ name: 'get_categories', description: 'Get all transaction categories available in Monarch Money', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/tools.ts:230-231 (registration)Routing logic in executeTool() that maps the 'get_categories' tool name to the getCategories() handler method.case 'get_categories': return await this.getCategories();
- src/monarch-api.ts:408-437 (helper)The underlying API method that executes a GraphQL query to fetch categories from Monarch Money API. Includes the GraphQL query definition and error handling.async getCategories(): Promise<any[]> { const query = ` query GetCategories { categories { id name systemCategory group { id name } } } `; try { const data: any = await this.graphQLClient.request(query); return data.categories || []; } catch (error: any) { if ( error.message.includes('401') || error.message.includes('unauthorized') ) { throw new Error( 'Authentication failed. Please check your MONARCH_TOKEN environment variable.' ); } throw new Error(`Failed to get categories: ${error.message}`); } }