mcp-finance-assistant
💰 Personal Finance Assistant — MCP + Gemini
一个由 AI 驱动的财务助手,让你可以用日常英语查询自己的支出情况。它通过Model Context Protocol(MCP) 将 Google 的 Gemini 连接到真实工具——SQL 数据库、预测模型和异常检测——而不是一个只会照本宣科聊天的脚本化聊天机器人。
🔗 在线演示: mcp-finance-assistant-z6txg3k6xparsajcsvftrr.streamlit.app
它能做什么
可以这样问它:
“我这个月花在食物上的钱有多少?”
“比较我 8 月和 7 月的支出”
“添加一笔 250 元的 Uber 到机场的费用” —— 它会自己推断分类
“下个月我在食物上会花多少钱?” —— 真正的机器学习预测,而不是凭空猜测
它还会在页面加载的那一刻主动标记异常支出,完全不需要被询问。
Related MCP server: Expense Tracker MCP Server
为什么要用 MCP
大多数 AI 财务跟踪器的演示要么是把聊天机器人的回复写死,要么是把大型语言模型硬塞到静态数据上。而本项目构建了一个真正的 MCP 服务器 —— 一种标准化方式(由 Anthropic 引入),让 AI 模型能自己发现并调用真实工具。Gemini 读取可用工具,决定需要哪个或哪些工具,再通过 MCP 协议调用它们,并基于真实的返回结果进行推理。这与生产级 AI 代理系统所用的模式一致,而不是一个玩具式模拟。
架构
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对于多步骤请求(例如在没有指定类别的情况下新增一笔支出),Gemini 会串联多次工具调用——先获取现有类别,再推断出正确的类别,然后添加上这笔支出——每个问题最多可执行 3 个步骤。
功能特性
7 个 MCP 工具:汇总总额、按月比较、列出近期支出、添加支出、获取类别、预测支出、检测异常
真正的机器学习,而非规则判断:
forecast_next_month使用 scikit-learn 的LinearRegression对历史趋势建模;detect_anomaly使用无监督的IsolationForest模型,而不是硬编码的阈值LLM 推断分类:用日常语言描述一笔支出,Gemini 自己挑选正确的类别,并通过链式工具调用去完成
主动洞察:页面加载时自动执行异常检查,无需用户提问
对话记忆:后续提问会结合对话上文中的上下文思考
真实数据:240+ 条真实交易记录,其中 231 条来自公开的 Kaggle 个人支出数据集,经导入和清洗后使用
生产级实践:每个工具均有完整错误处理和输入验证,附带结构化日志(
app.log),以及 8 个pytest测试,用于根据已知数据验证计算的正确性
技术栈
Python · MCP SDK · Google Gemini (google-genai) · SQLite · scikit-learn · Streamlit · pytest
本地运行
git clone https://github.com/srushtikochare/mcp-finance-assistant
cd mcp-finance-assistant
pip install -r requirements.txt创建 .env 文件:
GOOGLE_API_KEY=your_api_key_here然后运行:
streamlit run app.py运行测试
pytest test_server.py -v8 个测试,覆盖了金额总和、错误处理和机器学习工具行为等实际问题的验证——全部通过。
一个真实遇到的挑战
MCP Python SDK 的接口比我可用的大多数文档中的版本已有变化——我在所装的版本里并没有找到预期的 FastMCP 类。话说不喜欢直接猜,所以我检查了实际安装的包(dir(mcp.server)),找到了当前正确的类(MCPServer)以及完整的 API 边界。为了调一个持续演进的库而面对不完整的文档本身,而不是去选一个稳定的教学库,这才是本项目中我收获最大的部分。
可能的后续方向
支持多用户登录
支持发票/对账单 OCR 自动录入
使用带退避的重试逻辑,更好应对外部 API 的弹性
作者
Srushti Kochare — B.Tech 人工智能与数据科学,YCCE Nagpur
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to manage personal expenses through natural language conversations. Supports adding, searching, and analyzing transactions with automatic categorization and financial insights.3MIT
- FlicenseNot gradedqualityCmaintenanceEnables users to track expenses by adding, listing, and summarizing them with category support through natural language.
- AlicenseAqualityBmaintenanceEnables financial professionals to interact with QuickBooks Online using natural language for reports, journal entries, bills, expenses, and more.3659211MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI-driven expense tracking and budget management, including adding expenses, setting budgets, analyzing trends, forecasting, and managing savings goals via natural language.
Related MCP Connectors
Personal finance by conversation: expenses, receipts, statement import, budgets, net worth.
Capture receipts, scan Gmail, analyze spending, and create reviewed reports from AI assistants.
Ask your AI about bank accounts, spending, debts, holdings, and investment activity.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/srushtikochare/mcp-finance-assistant'
If you have feedback or need assistance with the MCP directory API, please join our Discord server