Skip to main content
Glama
akutishevsky

LunchMoney MCP Server

add_to_category_group

Organize financial categories by adding existing categories or creating new ones within a specified category group to improve budget management.

Instructions

Add categories (either existing or new) to a single category group.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYes

Implementation Reference

  • The handler function for the 'add_to_category_group' tool. It constructs a request body from category_ids and/or new_categories, then performs a POST request to the LunchMoney API endpoint `/categories/group/${group_id}/add` to add categories to the specified group, returning the JSON response or an error message.
    async ({ input }) => { const { group_id, category_ids, new_categories } = input; const { baseUrl, lunchmoneyApiToken } = getConfig(); const requestBody: any = {}; if (category_ids && category_ids.length > 0) { requestBody.category_ids = category_ids; } if (new_categories && new_categories.length > 0) { requestBody.new_categories = new_categories; } const response = await fetch( `${baseUrl}/categories/group/${group_id}/add`, { method: "POST", headers: { Authorization: `Bearer ${lunchmoneyApiToken}`, "Content-Type": "application/json", }, body: JSON.stringify(requestBody), } ); if (!response.ok) { return { content: [ { type: "text", text: `Failed to add to a single category group: ${response.statusText}`, }, ], }; } return { content: [ { type: "text", text: JSON.stringify(await response.json()), }, ], }; }
  • Zod input schema defining parameters for the 'add_to_category_group' tool: group_id (required number), optional category_ids (array of numbers), and optional new_categories (array of strings).
    input: z.object({ group_id: z.number().describe("Id of the parent group to add to."), category_ids: z .array(z.number()) .optional() .describe( "Array of category_id to include in the category group." ), new_categories: z .array(z.string()) .optional() .describe( "Array of strings representing new categories to create and subsequently include in the category group." ), }),
  • The server.tool() registration call that defines and registers the 'add_to_category_group' tool, including its name, description, input schema, and handler function within the registerCategoryTools function.
    server.tool( "add_to_category_group", "Add categories (either existing or new) to a single category group.", { input: z.object({ group_id: z.number().describe("Id of the parent group to add to."), category_ids: z .array(z.number()) .optional() .describe( "Array of category_id to include in the category group." ), new_categories: z .array(z.string()) .optional() .describe( "Array of strings representing new categories to create and subsequently include in the category group." ), }), }, async ({ input }) => { const { group_id, category_ids, new_categories } = input; const { baseUrl, lunchmoneyApiToken } = getConfig(); const requestBody: any = {}; if (category_ids && category_ids.length > 0) { requestBody.category_ids = category_ids; } if (new_categories && new_categories.length > 0) { requestBody.new_categories = new_categories; } const response = await fetch( `${baseUrl}/categories/group/${group_id}/add`, { method: "POST", headers: { Authorization: `Bearer ${lunchmoneyApiToken}`, "Content-Type": "application/json", }, body: JSON.stringify(requestBody), } ); if (!response.ok) { return { content: [ { type: "text", text: `Failed to add to a single category group: ${response.statusText}`, }, ], }; } return { content: [ { type: "text", text: JSON.stringify(await response.json()), }, ], }; } );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/akutishevsky/lunchmoney-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server