UNPKG

@baruchiro/actual-mcp

Version:

Actual Budget MCP server exposing API functionality

26 lines (25 loc) 1.12 kB
// Fetches accounts, categories, groups, and transactions for spending-by-category tool import { getAccounts, getCategories, getCategoryGroups, getTransactions } from "../../actual-api.js"; export class SpendingByCategoryDataFetcher { /** * Fetch all required data for the spending-by-category tool. * If accountId is provided, only fetch transactions for that account. */ async fetchAll(accountId, start, end) { const accounts = await getAccounts(); const categories = await getCategories(); const categoryGroups = await getCategoryGroups(); let transactions = []; if (accountId) { transactions = await getTransactions(accountId, start, end); } else { const onBudgetAccounts = accounts.filter((a) => !a.offbudget && !a.closed); for (const account of onBudgetAccounts) { const tx = await getTransactions(account.id, start, end); transactions = [...transactions, ...tx]; } } return { accounts, categories, categoryGroups, transactions }; } }