mcp-finance-assistant

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.

Category
访问服务器

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_month uses scikit-learn LinearRegression on historical trends; detect_anomaly uses an unsupervised IsolationForest model 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-test pytest suite 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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选