Expense Tracker MCP Server

Expense Tracker MCP Server

It lets AI assistants create, retrieve, update, delete, search, and summarize expense records in a local SQLite database through natural-language requests.

Category
Visit Server

README

๐Ÿ’ฐ Expense Tracker MCP Server

A local Expense Tracker MCP Server built with Python, FastMCP, and SQLite.

This project allows an MCP-compatible AI client such as Claude Desktop to interact with a local expense database using natural language.

For example:

"Add โ‚น500 for dinner today."

"How much have I spent?"

"Give me a summary of my expenses."

"Show me my biggest expenses."

The AI client communicates with the FastMCP server, which executes the appropriate tools and interacts with the local SQLite database.


๐Ÿ“Œ Project Overview

Architecture

                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ”‚     MCP Client       โ”‚
                โ”‚    Claude Desktop    โ”‚
                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚
                           โ”‚ MCP Protocol
                           โ–ผ
                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ”‚   Expense Tracker    โ”‚
                โ”‚      MCP Server      โ”‚
                โ”‚       FastMCP        โ”‚
                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚            โ”‚            โ”‚
              โ–ผ            โ–ผ            โ–ผ
           MCP Tools   MCP Resources  Prompts
              โ”‚
              โ–ผ
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚    SQLite     โ”‚
        โ”‚  expenses.db  โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Technologies Used

  • Python
  • FastMCP
  • SQLite
  • uv
  • Claude Desktop
  • MCP (Model Context Protocol)

๐Ÿ“‚ Project Structure

expense-tracker/
โ”‚
โ”œโ”€โ”€ server.py
โ”œโ”€โ”€ expenses.db
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ .python-version
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ .gitignore

server.py

Contains the MCP server, database initialization, and MCP tools.

expenses.db

Local SQLite database containing all expense records.

pyproject.toml

Contains project metadata and dependencies.

README.md

Project documentation.


๐Ÿš€ Installation

1. Install uv

Install uv if it is not already installed.

Verify the installation:

uv --version

You should see the installed version of uv.


๐Ÿ“ 2. Create the Project

Create a folder for the project:

mkdir expense-tracker
cd expense-tracker

Open it in VS Code:

code .

๐Ÿ 3. Initialize the Python Project

Run:

uv init

This creates the Python project configuration.


๐Ÿ“ฆ 4. Install FastMCP

Install FastMCP using:

uv add fastmcp

FastMCP is used to create and expose the MCP server and its tools.


๐Ÿ—„๏ธ 5. SQLite Database

This project uses SQLite because the expense tracker is designed to run locally.

The database is automatically created when the server starts.

The database contains an expenses table.

Example structure:

expenses
โ”‚
โ”œโ”€โ”€ id
โ”œโ”€โ”€ date
โ”œโ”€โ”€ amount
โ”œโ”€โ”€ category
โ”œโ”€โ”€ subcategory
โ”œโ”€โ”€ note
โ”œโ”€โ”€ payment_method
โ”œโ”€โ”€ currency
โ””โ”€โ”€ created_at

Example record:

ID:             1
Date:           2026-08-22
Amount:         500
Category:       Food
Subcategory:    Dinner
Note:           Dinner with friends
Payment Method: UPI
Currency:       INR

๐Ÿง  6. MCP Server

The MCP server is created using FastMCP.

Basic structure:

from fastmcp import FastMCP

mcp = FastMCP("Expense Tracker")

The server acts as the bridge between the AI client and the local expense database.


๐Ÿ”ง 7. MCP Tools

The server exposes several tools that the AI can call.

add_expense

Adds a new expense.

Example request:

Add โ‚น500 for dinner today.

The AI can call:

add_expense(
    amount=500,
    category="Food",
    subcategory="Dinner"
)

get_expense

Retrieves a specific expense using its ID.

Example:

Show me expense number 5.


list_expenses

Returns recent expenses.

Example:

Show me my recent expenses.


update_expense

Updates an existing expense.

Example:

Change expense 5 from โ‚น500 to โ‚น650.


delete_expense

Deletes an expense.

Example:

Delete expense number 5.


search_expenses

Searches expenses using category, subcategory, note, or payment method.

Example:

Find all my food expenses.


get_total_expenses

Calculates the total amount spent.

Example:

How much have I spent in total?


get_category_summary

Groups expenses by category.

Example:

How much did I spend on food, transport and shopping?

Example result:

Food        โ‚น5,200
Shopping    โ‚น3,400
Transport   โ‚น2,100
Bills       โ‚น1,750

get_monthly_summary

Returns spending information for a specific month.

Example:

How much did I spend in August 2026?


get_expenses_by_date_range

Returns expenses between two dates.

Example:

Show my expenses from August 1 to August 15.


get_top_expenses

Returns the largest expenses.

Example:

What are my five biggest expenses?


get_expense_summary

Provides an overall financial summary.

It can include:

Total spending
Number of transactions
Average expense
Category breakdown
Largest expense

Example:

Total Spent: โ‚น12,450
Transactions: 32
Average Expense: โ‚น389

Top Categories:

Food        โ‚น4,500
Shopping    โ‚น3,200
Transport   โ‚น2,100
Bills       โ‚น1,800

Largest Expense:

โ‚น2,500
Category: Shopping

๐Ÿ“š 8. MCP Resources

MCP resources are used to expose information/context to the MCP client.

For example:

@mcp.resource(
    "expenses://categories",
    mime_type="application/json"
)
def expense_categories():
    return """
    {
        "categories": [
            "Food",
            "Transport",
            "Shopping",
            "Bills",
            "Entertainment"
        ]
    }
    """

The important difference is:

Tool      โ†’ Performs an action

Resource  โ†’ Provides information

Prompt    โ†’ Provides a reusable instruction/template

โ–ถ๏ธ 9. Run the Server

You can run the server using:

uv run python server.py

The MCP server will start locally.


๐Ÿ” 10. Inspect/Test the MCP Server

FastMCP provides development tooling.

You can use:

uv run fastmcp dev server.py

This is useful for testing and inspecting the MCP server during development.


๐Ÿค– 11. Connect to Claude Desktop

To use the expense tracker through Claude Desktop, add the MCP server to the Claude Desktop configuration.

The configuration generally looks like:

{
  "mcpServers": {
    "expense-tracker": {
      "command": "/path/to/uv",
      "args": [
        "run",
        "--directory",
        "/path/to/expense-tracker",
        "python",
        "server.py"
      ]
    }
  }
}

Replace:

/path/to/uv

with the actual path to your uv executable.

On Linux, find it using:

which uv

Also replace:

/path/to/expense-tracker

with the actual project directory.


โš ๏ธ 12. If Claude Desktop Shows a Connection Error

If Claude cannot connect to the MCP server:

Step 1

Check that the server works independently:

uv run python server.py

Step 2

Check the uv path:

which uv

Step 3

Make sure the Claude configuration uses the correct absolute path.

Step 4

Restart Claude Desktop after changing the configuration.

Step 5

Check:

Claude Desktop
    โ†“
Settings
    โ†“
Developer
    โ†“
Configuration

Then verify the MCP server configuration.


๐Ÿ’ฌ 13. How to Use the Expense Tracker

Once the MCP server is connected to Claude, you don't need to manually call the functions.

You can simply use natural language.

Add an expense

I spent โ‚น250 on dinner today.

Claude can use:

add_expense()

Check total spending

How much have I spent so far?

Claude can use:

get_total_expenses()

Get a summary

Give me a summary of all my expenses.

Claude can use:

get_expense_summary()

Search

Show me all my shopping expenses.

Claude can use:

search_expenses()

Find largest expenses

What are my five biggest expenses?

Claude can use:

get_top_expenses()

Monthly analysis

How much did I spend in August 2026?

Claude can use:

get_monthly_summary()

Date range

Show me everything I spent between August 1 and August 15.

Claude can use:

get_expenses_by_date_range()

Update an expense

Change expense 12 from โ‚น300 to โ‚น450.

Claude can use:

update_expense()

Delete an expense

Delete expense number 12.

Claude can use:

delete_expense()

๐Ÿ”„ 14. Complete Request Flow

When you say:

"I spent โ‚น500 on dinner today."

The flow is:

You
 โ”‚
 โ–ผ
Claude Desktop
 โ”‚
 โ”‚ Understands request
 โ–ผ
MCP Client
 โ”‚
 โ”‚ Calls tool
 โ–ผ
add_expense()
 โ”‚
 โ–ผ
FastMCP Server
 โ”‚
 โ–ผ
SQLite
 โ”‚
 โ–ผ
expenses.db
 โ”‚
 โ–ผ
Success Response
 โ”‚
 โ–ผ
Claude
 โ”‚
 โ–ผ
"Expense added successfully."

๐Ÿงฉ 15. Why MCP Is Useful Here

Without MCP:

User โ†’ Application โ†’ Database

With MCP:

User
  โ†“
AI
  โ†“
MCP
  โ†“
Expense Tools
  โ†“
Database

The AI can decide which tool is appropriate based on the user's natural-language request.

This makes the expense tracker a good example of AI + tools + local data.


๐Ÿ” 16. Local Data and Privacy

This project stores expense data locally in:

expenses.db

The database is not inherently hosted on a cloud server.

This makes the project useful for experimenting with personal/local financial data.

However, when using an external AI client, prompts and tool results may still be processed according to that client's policies. Avoid assuming that "local MCP server" means every piece of data stays entirely on your machine.


๐Ÿงช 17. Example Session

User

I spent โ‚น300 on lunch today.

AI

Expense added successfully.

User

I also spent โ‚น120 on an auto.

AI

Expense added successfully.

User

How much did I spend today?

AI

You spent โ‚น420 today.

User

Give me my complete expense summary.

AI

Total Spending: โ‚น420

Transactions: 2

Average Expense: โ‚น210

Categories:

Food: โ‚น300
Transport: โ‚น120

Largest Expense:

Lunch โ€” โ‚น300

๐ŸŽฏ 18. What I Learned From This Project

This project demonstrates knowledge of:

  • Python
  • SQLite
  • Database CRUD operations
  • FastMCP
  • MCP tools
  • MCP resources
  • MCP client/server architecture
  • Tool calling
  • Natural-language interaction with databases
  • Local AI integrations
  • JSON-based configuration
  • uv project management

๐Ÿš€ 19. Future Improvements

The project can be extended with:

Budget Management

set_budget()
get_budget_status()

Example:

My monthly budget is โ‚น20,000.


Spending Insights

get_spending_insights()

Example:

Where am I overspending?


Monthly Comparison

compare_months()

Example:

Did I spend more this month than last month?


Recurring Expenses

add_recurring_expense()
get_recurring_expenses()

Export

Add support for:

CSV
JSON
Excel
PDF

Visualization

Generate:

Monthly spending charts
Category charts
Spending trends

AI Financial Assistant

Eventually, the MCP server can become the backend for an AI financial assistant:

                    AI Expense Assistant
                            โ”‚
                            โ–ผ
                     MCP Server
                            โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ”‚                 โ”‚                 โ”‚
       Expenses           Budget          Analytics
          โ”‚                 โ”‚                 โ”‚
          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ–ผ
                         SQLite

The user could ask:

"Analyze my spending this month and tell me three areas where I can reduce expenses."

The AI could retrieve the required data through MCP tools and generate an analysis.


โœ… Final Workflow

The complete development workflow is:

1. Install uv
       โ†“
2. Create project folder
       โ†“
3. Open in VS Code
       โ†“
4. uv init
       โ†“
5. uv add fastmcp
       โ†“
6. Create server.py
       โ†“
7. Initialize SQLite
       โ†“
8. Create MCP tools
       โ†“
9. Create MCP resources
       โ†“
10. Run server
       โ†“
11. Test/inspect with FastMCP
       โ†“
12. Configure Claude Desktop
       โ†“
13. Restart Claude
       โ†“
14. Use natural language
       โ†“
15. Claude calls MCP tools
       โ†“
16. Tools interact with SQLite
       โ†“
17. Results return to Claude

๐Ÿ† Project Summary

Expense Tracker MCP Server is a local AI-enabled expense management system that uses FastMCP to expose expense-management tools and resources, with SQLite as the local persistence layer and an MCP-compatible client such as Claude Desktop as the natural-language interface.

It demonstrates how an AI application can safely interact with structured local data through the Model Context Protocol (MCP) instead of directly accessing the database.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured