mcp-finance-assistant
Enables users to ask plain-English questions about their expenses, query and compare spending, add categorized transactions, forecast future spending, and detect anomalies through natural language.
README
๐ฐ Personal Finance Assistant โ MCP + Gemini
An AI-powered finance assistant that lets you ask questions about your expenses in plain English. Built using the Model Context Protocol (MCP) to connect Google's Gemini to real tools โ a SQL database, forecasting models, and anomaly detection โ instead of a scripted chatbot that only knows how to talk.
๐ Live demo: mcp-finance-assistant-z6txg3k6xparsajcsvftrr.streamlit.app
What it does
Ask it things like:
- "How much did I spend on food this month?"
- "Compare my spending in August vs July"
- "Add an expense of 250 for Uber to the airport" โ it infers the category itself
- "What will I spend on food next month?" โ real ML forecasting, not a guess
It also proactively flags unusual spending the moment the page loads, without being asked.
Why MCP
Most AI finance-tracker demos hardcode a chatbot's responses or bolt an LLM onto static data. This project instead builds a real MCP server โ a standardized way (introduced by Anthropic) for an AI model to discover and call real tools. Gemini reads the available tools, decides which one(s) it needs, calls them through the MCP protocol, and reasons over the actual results. It's the same pattern used by production AI agent systems, not a toy simulation.
Architecture
User question โ Streamlit UI โ Gemini (decides which tool to call)
โ
MCP Server (server.py)
โ
SQLite Database (real transaction data)
โ
Tool result โ back to Gemini โ plain-English answer
For multi-step requests (like adding an expense without a category), Gemini chains multiple tool calls โ first fetching existing categories, then inferring the right one, then adding the expense โ up to 3 steps per question.
Features
- 7 MCP tools: query totals, compare months, list recent expenses, add expenses, get categories, forecast spending, detect anomalies
- Real ML, not rules:
forecast_next_monthuses scikit-learnLinearRegressionon historical trends;detect_anomalyuses an unsupervisedIsolationForestmodel instead of a hardcoded threshold - LLM-inferred categorization: describe an expense in plain English and Gemini picks the right category on its own, chaining tool calls to do it
- Proactive insights: automatic anomaly checks run on page load, no question needed
- Conversation memory: follow-up questions understand context from earlier in the chat
- Real data: 240+ real transaction records, including 231 imported and cleaned from a public Kaggle personal-expense dataset
- Production practices: full error handling and input validation on every tool, structured logging (
app.log), and an 8-testpytestsuite verifying calculations against known data
Tech stack
Python ยท MCP SDK ยท Google Gemini (google-genai) ยท SQLite ยท scikit-learn ยท Streamlit ยท pytest
Running it locally
git clone https://github.com/srushtikochare/mcp-finance-assistant
cd mcp-finance-assistant
pip install -r requirements.txt
Create a .env file:
GOOGLE_API_KEY=your_api_key_here
Then run:
streamlit run app.py
Running the tests
pytest test_server.py -v
8 tests covering correct sums, error handling, and ML tool behavior โ all passing.
A real challenge I hit
The MCP Python SDK's structure had changed since most available documentation was written โ the class I expected (FastMCP) didn't exist in the installed version. Rather than guess, I inspected the actual installed package (dir(mcp.server)) to find the correct current class (MCPServer) and API surface. Debugging against an evolving library with incomplete docs, instead of a stable tutorial-friendly one, was the most valuable part of building this.
Possible next steps
- Multi-user support with individual logins
- Receipt/statement OCR upload for automatic expense entry
- Retry logic with backoff for external API resilience
Author
Srushti Kochare โ B.Tech Artificial Intelligence & Data Science, YCCE Nagpur
Recommended Servers
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.