Skip to main content
Glama
Personal Expense Categorizer

Personal Expense Categorizer

by alihabbache

Personal Expense Categorizer

A Bob Skill + MCP server that reads CSV bank exports and tags every transaction with a category. It runs entirely on your machine: no network calls, no accounts, no API keys.

  • Auto-detects bank CSV layouts (delimiter, header row, date order, debit/credit columns, sign convention)

  • Tags each transaction with category, kind (expense / income / transfer) and merchant, and tells you which rule matched

  • Summarizes spending by category and month; finds subscriptions and other recurring charges

  • Learns: confirm a merchant once and it is categorized correctly from then on

  • Exports a clean categorized CSV

Design details: docs/ARCHITECTURE.md

How it works

flowchart LR
    U[You] <--> B[Bob + Skill]
    B -- MCP stdio --> M[MCP server]
    M --> F[(Bank CSV)]
    M <--> R[(Your rules.json)]

The skill (.bob/skills/personal-expense-categorizer/SKILL.md) guides the conversation: categorize, ask you about unknown merchants in one batch, save your answers, report. The MCP server does the deterministic work: parsing, matching, math, file access.

Related MCP server: local-budget

Install

Requires Node.js 20 or newer.

git clone <your-repo-url> personal-expense-categorizer
cd personal-expense-categorizer
npm install
npm run build
npm test          # builds and runs 27 tests

Register the MCP server in Bob

Add to your workspace or global mcp.json (also in examples/mcp.json), using the absolute path to this checkout:

{
  "mcpServers": {
    "personal-expense-categorizer": {
      "command": "node",
      "args": ["/absolute/path/to/personal-expense-categorizer/build/src/index.js"]
    }
  }
}

For a workspace config opened on this repo, "${workspaceFolder}/build/src/index.js" also works. Bob reconnects automatically when the file is saved.

Install the skill

The skill lives at .bob/skills/personal-expense-categorizer/. It is picked up automatically when this repo is your workspace. To use it in every workspace, copy the folder:

mkdir -p ~/.bob/skills
cp -R .bob/skills/personal-expense-categorizer ~/.bob/skills/

Start a new task afterwards so Bob loads it.

Usage

Try it on the bundled fixtures. Ask Bob:

Categorize /absolute/path/to/test-data/sample-checking-us.csv and show me a spending summary.

Expected shape of the result for that file:

Period

2025-01-02 to 2025-03-28

Income

9,600.00

Expenses

5,765.63 (transfers of 900.00 excluded)

Largest category

Housing, 4,350.00 (75.45%)

Uncategorized

2 rows (MYSTERY VENDOR LLC, 54.00)

Recurring

Rent, PG&E, Shell, Planet Fitness, Netflix, Spotify

Bob will then ask what category MYSTERY VENDOR LLC belongs to, save the rule, and the next run shows 0 uncategorized.

Other prompts:

  • "Which of my subscriptions are recurring, and what do they cost per month?"

  • "Export the categorized transactions next to the original file."

  • "This bank writes dates day-first. Re-run it."

MCP tools

Tool

What it does

categorize_transactions

Parse and tag all rows. only_uncategorized lists what no rule matched

summarize_spending

Totals, by category with share, by month, uncategorized total

find_recurring_charges

Weekly, monthly and yearly repeats with next expected date

list_categories

Categories, kinds and rule counts; shows your rules file path

add_category_rule

Save keyword -> category (idempotent)

export_categorized_csv

Write id,date,description,merchant,amount,category,kind,source to a new .csv

Every parsing tool accepts these options when auto-detection needs help:

Option

Values

date_format

auto (default), MDY, DMY

amount_convention

auto (default), negative_is_expense, positive_is_expense

column_map

{ date, description, amount, debit, credit } exact header names

Supported CSV shapes

Feature

Supported

Delimiters

comma, semicolon, tab

Amount columns

single signed Amount, or separate Debit / Credit

Date formats

2025-01-31, 01/31/2025, 31/01/2025, 31.01.2025, 31 Jan 2025, Jan 31, 2025, 2-digit years

Money formats

$1,234.56, 1.234,56, (19.99), 12.50-

Quirks

BOM, CRLF, quoted fields with commas, lines of account info above the header

Not supported yet: PDF, OFX/QFX, XLSX, live bank connections.

Customizing categories

Defaults are in config/default-categories.json. Your own rules are saved to ~/.personal-expense-categorizer/rules.json (override with the EXPENSE_RULES_PATH environment variable) and always take precedence:

{
  "categories": { "Pets": "expense" },
  "rules": [
    { "category": "Pets", "keyword": "petco" },
    { "category": "Dining", "keyword": "blue bottle" }
  ]
}

Matching is case- and punctuation-insensitive, on whole words. The longest matching keyword wins.

Privacy and safety

  • Local only: the server contains no network code and sends nothing anywhere.

  • The server reads only .csv, .tsv or .txt files up to 10 MB (checked again after resolving symlinks), and only when a tool call names them.

  • Set EXPENSE_ALLOWED_DIRS (e.g. /Users/you/Downloads, multiple folders separated by :) to restrict all reads and writes to those folders. Recommended; add it under env in your mcp.json.

  • Export never overwrites unless you say so, and even then only replaces files this server exported earlier. It also neutralizes spreadsheet formula injection.

  • rules.json is validated on load and saved with owner-only permissions (600).

  • .gitignore blocks bank-export formats, .env.* and rules.json, except the five synthetic test-data/ files. Do not commit real statements.

  • See SECURITY.md for the threat model and how to report a vulnerability.

  • Your Bob client may send tool results to its model provider. Tool results include transaction descriptions and amounts, so use a provider you are comfortable with for financial data.

Project layout

.bob/skills/personal-expense-categorizer/SKILL.md   conversation workflow
src/                index.ts (tools) | service.ts | parser.ts | csv.ts | rules.ts | analysis.ts | types.ts
config/             default-categories.json
test-data/          5 synthetic CSV fixtures
tests/              unit + end-to-end MCP tests
docs/ARCHITECTURE.md
examples/mcp.json

Development

npm run build     # tsc -> build/
npm test          # build + node:test (unit + stdio e2e)
npm start         # run the server on stdio (waits for an MCP client)

Troubleshooting

Symptom

Fix

Tools do not appear in Bob

Check the absolute path in mcp.json and that npm run build produced build/src/index.js

"Could not find a header row"

Pass column_map with the exact header names from the file

Dates look swapped

Pass date_format: "DMY" or "MDY"

Spending shows as income

Pass amount_convention (credit-card exports usually list purchases as positive)

"Refusing to read"

The file must end in .csv, .tsv or .txt

Skill not listed

Start a new task; confirm the folder name is exactly personal-expense-categorizer

License

MIT, see LICENSE.

Available Tools

6 tools
add_category_ruleA
Idempotent

Teach the categorizer: transactions whose description contains the keyword will be assigned the category. Saved to the user's local rules file and applied on the next call. Only call after the user has confirmed the mapping.

Inputs: keyword (required), category (required), kind.

categorize_transactionsA
Read-only

Parse a CSV bank export and tag every transaction with a category, kind (expense/income/transfer), merchant and the rule that matched. Returns detected format, warnings and per-category counts. Set only_uncategorized to review what rules missed.

Inputs: file_path (required), limit, column_map, date_format, +2 more.

export_categorized_csvA
Destructive

Write the categorized transactions to a new CSV file (id,date,description,merchant,amount,category,kind,source). Refuses to overwrite an existing file unless overwrite is true, and even then only replaces files this tool previously exported. Ask the user before setting overwrite.

Inputs: file_path (required), output_path (required), overwrite, column_map, +2 more.

find_recurring_chargesB
Read-only

Detect subscriptions and other recurring charges (weekly, monthly, yearly) with typical amount and next expected date.

Inputs: file_path (required), column_map, date_format, amount_convention.

list_categoriesA
Read-only

List all categories with their kind and rule counts, and the location of the user's custom rules file.

Inputs: no named parameters.

summarize_spendingA
Read-only

Totals by category and by month for a CSV bank export. Transfers are excluded from income and expense totals; reports how much money is still uncategorized.

Inputs: file_path (required), column_map, date_format, amount_convention.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool targets a distinct stage of the expense workflow: categorizing, summarizing, detecting recurring charges, managing rules/categories, and exporting. There is little overlap between tagging transactions, totaling spending, listing categories, and writing CSV output. An agent can select the correct tool from the descriptions.

    Naming Consistency5/5

    All tool names use a consistent snake_case verb_noun pattern: summarize_spending, categorize_transactions, find_recurring_charges, add_category_rule, list_categories, export_categorized_csv. The convention is predictable and readable throughout.

    Tool Count5/5

    Six tools are well-scoped for a personal expense categorizer. Each tool covers a meaningful operation without bloating the surface, and the set stays comfortably within a manageable range.

    Completeness4/5

    The core workflow is covered: parse/categorize transactions, summarize spending, find recurring charges, add/list category rules, and export results. Minor gaps exist around managing existing rules/categories, such as updating or deleting a rule or creating/renaming categories, though the custom rules file location provides a manual workaround.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables parsing and filtering of mBank CSV operation exports locally. Supports data aggregation and querying through natural language, running entirely offline with no network calls.
      3
      1
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Enables local-first personal finance management through deterministic tools for importing, categorizing, and analyzing bank transactions.
      36
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Deterministic bank-statement parsing for AI agents: messy CSV/OFX exports to clean, categorized ledger rows. In-memory only, no storage, no external calls, no LLM in the loop.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables querying your own local bank and credit card statement files (CSV or PDF) in plain language, so you can discover forgotten recurring subscriptions, compare spending across months and quarters, and look up transactions without any bank logins or network calls.
      MIT