Skip to main content
Glama
Soumya26Agrawal

Expense Tracker MCP Server

Expense Tracker MCP Server

A Model Context Protocol (MCP) server that lets Claude track, list, and summarize personal expenses through natural conversation — no spreadsheet or app UI required. Built with FastMCP, backed by SQLite, and deployable both locally and to FastMCP Cloud.

Why this project

MCP is how LLMs like Claude connect to real tools and data sources instead of just generating text. This project implements a complete, working MCP server end-to-end: tool definitions, a structured resource, an async database layer, and a client-connection story — from local stdio transport all the way to a cloud-hosted HTTP deployment proxied back into Claude Desktop.

Related MCP server: Expense Tracker MCP Server

What it does

Once connected, Claude can:

  • Log an expense — "I spent ₹450 on groceries today" → written to the database with date, amount, category, subcategory, and note

  • List expenses — "What did I spend last week?" → returns every expense in a date range

  • Summarize spending — "How much did I spend on food this month?" → aggregates total amount and count per category over a date range

  • Discover valid categories — Claude reads a structured category resource to know what categories/subcategories are valid before logging an expense, rather than guessing

MCP Components

Tools (main.py)

Tool

Description

add_expense(date, amount, category, subcategory, note)

Inserts a new expense row; returns the new row's ID or a structured error

list_expenses(start_date, end_date)

Returns all expenses in an inclusive date range, most recent first

summarize(start_date, end_date, category=None)

Returns total amount and count per category in a date range, optionally filtered to one category

Resource

  • expense:///categories — exposes categories.json, a structured taxonomy of 20 top-level categories (food, transport, housing, utilities, health, education, family & kids, entertainment, shopping, subscriptions, personal care, gifts & donations, finance fees, business, travel, home, pet, taxes, investments, misc), each with realistic subcategories. Falls back to a sensible default category list if the file isn't found.

Data layer

  • SQLite database (expenses.db), with WAL journal mode for better concurrent read/write behavior

  • Synchronous sqlite3 used once at startup to initialize the schema and verify write access; all runtime tool calls use aiosqlite for non-blocking async I/O

  • Database path resolved via the system temp directory, making the server safe to run in ephemeral/cloud filesystem environments

Transport & Deployment (proxy.py)

  • The server runs over Streamable HTTP when deployed (mcp.run(transport="http", ...))

  • A separate proxy (proxy.py) wraps the deployed FastMCP Cloud endpoint and re-exposes it over STDIO, which is the transport Claude Desktop expects for local MCP connections — bridging a cloud-hosted server into a local desktop client

Architecture

flowchart LR
    subgraph Local["Local Machine"]
        CD[Claude Desktop] -->|STDIO| PX["proxy.py<br/>FastMCP.as_proxy"]
    end

    PX -->|Streamable HTTP| Cloud

    subgraph Cloud["FastMCP Cloud"]
        SRV["main.py<br/>FastMCP Server"]
        SRV --> T1[add_expense]
        SRV --> T2[list_expenses]
        SRV --> T3[summarize]
        SRV --> R1["expense:///categories<br/>resource"]
    end

    T1 --> DB[(SQLite<br/>expenses.db<br/>WAL mode)]
    T2 --> DB
    T3 --> DB
    R1 --> CAT[categories.json]

Tech Stack

Layer

Technology

Protocol

Model Context Protocol (MCP)

Server framework

FastMCP

Database

SQLite, aiosqlite (async), sqlite3 (sync init)

Transport

Streamable HTTP (cloud), STDIO (local proxy → Claude Desktop)

Deployment

FastMCP Cloud

Package management

uv (pyproject.toml + uv.lock)

Language

Python 3.11+

Getting Started

Prerequisites

  • Python 3.11+

  • uv for dependency management

  • Claude Desktop (to connect via the local proxy)

Installation

git clone <your-repo-url>
cd <repo-name>

uv sync

Run the server locally

uv run main.py

The server starts on http://0.0.0.0:8000 using Streamable HTTP transport, and initializes the SQLite schema on first run.

Connect Claude Desktop via the proxy

Add the proxy to your Claude Desktop MCP config (claude_desktop_config.json):

{
  "mcpServers": {
    "expense-tracker": {
      "command": "uv",
      "args": ["run", "python", "proxy.py"]
    }
  }
}

The proxy connects to the deployed FastMCP Cloud endpoint over Streamable HTTP and re-exposes it to Claude Desktop over STDIO — restart Claude Desktop after adding the config.

Deploying your own instance

  1. Push the repo to a Git provider

  2. Deploy main.py on FastMCP Cloud (or any host that can run a Streamable HTTP server)

  3. Update the URL in proxy.py to point to your deployed endpoint

Project Structure

.
├── main.py               # MCP server: tools, resource, DB init
├── proxy.py               # STDIO proxy → deployed FastMCP Cloud server
├── categories.json         # Expense category/subcategory taxonomy
├── expenses.db              # SQLite database (created/used at runtime)
├── pyproject.toml            # Project metadata + dependencies (uv)
├── uv.lock                    # Locked dependency versions
└── .python-version              # Pinned Python version

Design Notes

  • Sync init, async runtime. Schema creation and a write-access check happen synchronously once at startup (fail fast, fail loud); all subsequent tool calls are fully async so the server doesn't block under concurrent requests.

  • Resource-driven category discovery. Rather than hardcoding categories into the tool schema, Claude is expected to read the expense:///categories resource first — keeping category logic in one editable JSON file instead of scattered across tool code.

  • Cloud-safe file paths. Using the system temp directory for the database avoids permission issues on read-only or ephemeral cloud filesystems.

License

Add a license of your choice (e.g., MIT).

Available Tools

3 tools
add_expenseC

Add a new expense entry to the database.

ParametersJSON Schema
NameRequiredDescriptionDefault
dateYes
noteNo
amountYes
categoryYes
subcategoryNo

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided. The description only states the action but lacks details on idempotency, side effects, or data validation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, concise but lacks structure or front-loading of key information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With five parameters, no output schema, and no annotations, the description is incomplete; it does not explain return values or handle edge cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%. The description adds no meaning to any of the five parameters, not even the required date, amount, or category.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Add') and resource ('expense entry'), clearly distinguishing it from siblings like delete_expense and list_expenses.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. Siblings exist but no differentiation is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_expensesC

List expense entries within an inclusive date range.

ParametersJSON Schema
NameRequiredDescriptionDefault
end_dateYes
start_dateYes

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description bears full responsibility for behavioral disclosure. It only states basic read-only behavior without mentioning pagination, limits, ordering, or potential side effects, leaving significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that front-loads key information. It is appropriately brief, though it could benefit from additional context without sacrificing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity with 2 required parameters and no output schema, the description should cover return format or data structure. It fails to mention what the response contains, leaving the agent uncertain about the output.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, so the description must compensate. It clarifies the date range is inclusive but does not specify date format, timezone handling, or parameter constraints beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'List' and the resource 'expense entries', and specifies the scope as 'within an inclusive date range'. This explicitly differentiates it from sibling tools like add_expense, delete_expense, update_expense, and summarize.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, no exclusion criteria, and no prerequisites. It merely states the function without context for decision-making.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

summarizeB

Summarize expenses by category within an inclusive date range.

ParametersJSON Schema
NameRequiredDescriptionDefault
categoryNo
end_dateYes
start_dateYes

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits. It mentions 'inclusive date range' but does not state that the tool is read-only, lacks details on return format, and omits any side effects or permissions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One sentence with no wasted words. It is front-loaded with the key action but could benefit from additional param details without becoming verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and 0% schema coverage, the description is insufficient. It fails to provide parameter details, return value expectations, or usage context beyond the basic purpose.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%. The description mentions 'category' as a grouping field but does not clarify its optionality or the expected format for date parameters. It adds minimal value beyond the schema structure.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the tool summarizes expenses by category within a date range. The verb 'summarize' and resource 'expenses' are specific, and the grouping by 'category' distinguishes it from sibling tools that perform CRUD operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit when-to-use or when-not-to-use guidance. The usage is implied by the tool name and siblings, but no alternatives or exclusions are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 3 tool updatesv0.1.0
    • First observedadd_expense
    • First observedlist_expenses
    • First observedsummarize

TDQS

B3.2/5.0

Scored across 3 tools

Disambiguation5/5

The three tools have clearly distinct purposes: add_expense creates a record, list_expenses retrieves raw records, and summarize aggregates by category. There is no overlap or ambiguity between them.

Naming Consistency4/5

All tools use lowercase snake_case and a verb-first pattern (add_, list_, summarize). The only minor inconsistency is that 'summarize' omits the explicit noun 'expenses' that the other two include, but it remains predictable and readable.

Tool Count4/5

Three tools is a reasonable size for a focused expense tracker. It is slightly minimal but each tool serves a distinct core function (insert, query, aggregate), so the count feels appropriate rather than inadequate.

Completeness3/5

The surface covers basic recording, viewing, and summarizing expenses, but lacks update and delete operations, which are common expected capabilities in a data management domain. This is a notable gap that agents cannot easily work around.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    B
    quality
    D
    maintenance
    MCP server for tracking personal expenses using FastMCP and SQLite, enabling adding, listing, updating, deleting expenses and summarizing by category via natural language tools.
    5
    1
    -
  • F
    license
    B
    quality
    D
    maintenance
    A powerful SQLite-backed expense tracking server built with the Model Context Protocol (MCP). This server allows AI agents (like Claude) to manage your personal finances by adding, deleting, and listing expenses directly from your chat interface.
    3
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that lets you log and query your own spending through natural conversation with Claude, instead of a spreadsheet or app.
    6
    -
  • F
    license
    Not graded
    quality
    B
    maintenance
    A lightweight MCP server that lets LLM clients track, query, and summarize personal expenses using a local SQLite database.
    -