MCP Agent - AI Expense Tracker
A practical demonstration of AI Agent implementation with custom MCP server.
This project showcases how to build intelligent AI agents using the Model Context Protocol (MCP). Through a real-world expense tracking application, you'll see how AI agents can interact with tools, databases, and APIs to perform complex tasks through natural conversation.
šÆ What This Demonstrates
Custom MCP Server: Build your own MCP server using FastAPI
AI Agent Integration: Connect AI agents to tools via MCP protocol
Real-world Application: Practical expense tracking use case
Natural Language Interface: Chat with AI to manage your data
Tool Discovery: AI automatically discovers and uses available tools
šļø Architecture
š For detailed architecture documentation, request flows, and deployment options, see
š Features
AI-Powered Agent: Natural language expense tracking using OpenAI GPT-4
SQLite Database: Persistent storage for all transactions
Auto-Initialization: Automatic database setup with seed data
MCP Integration: Extensible tool system for AI agents
REST API: Full CRUD operations for expense management
Multiple Clients: Web UI, Telegram bot, and direct agent interface
Smart Categorization: Automatic expense categorization and insights
Currency-Agnostic: Clean numerical formatting without currency symbols
š Project Structure
š Quick Start
1. Install Dependencies
2. Set Environment Variables
3. Initialize and Start Servers
4. Run the AI Agent
Access the agent at: http://localhost:7777
š¬ Usage Examples
Chat with the AI agent:
"Add a 50 grocery expense"
"I spent 75 on dinner last night"
"How much did I spend on food this month?"
"Show me my financial summary"
"What's my biggest expense category?"
"Add income of 5000 from salary"
š ļø Tech Stack
Protocol: Model Context Protocol (MCP) - Custom server implementation
Agent Framework: Agno
AI Model: OpenAI GPT-4
MCP Server: FastAPI-MCP (converts REST API to MCP tools)
Backend: FastAPI + SQLite
Frontend: Next.js + React
Bot: Python Telegram Bot
š How MCP Works Here
FastAPI Backend (
server/main.py) - Standard REST API with CRUD operationsMCP Server (
server/mcp_server.py) - Wraps the API and exposes it as MCP toolsAI Agent (
agent/agent.py) - Connects to MCP server and automatically discovers toolsNatural Language - User chats with agent, agent uses tools to complete tasks
š API Endpoints
GET /transactions- List all transactionsPOST /transactions- Create new transactionPUT /transactions/{id}- Update transactionDELETE /transactions/{id}- Delete transactionGET /transactions/search?q=- Search transactionsGET /summary- Financial summaryGET /summary/categories- Category breakdownGET /health- Health check
Full API docs: http://localhost:8002/docs
šÆ Server Commands
The start.py script manages server initialization and startup:
What
ā Checks all required dependencies
ā Verifies environment variables
ā Initializes SQLite database
ā Seeds database with sample transactions (first run only)
ā Starts requested server(s)
š¤ Agent Capabilities
The AI agent can:
Create, read, update, and delete expenses
Search transactions by keyword
Generate financial summaries and insights
Analyze spending patterns by category
Provide budgeting recommendations
Filter transactions by date, type, or category
š§ Configuration
Environment Variables (.env)
Server Configuration (server/config.py)
Server host/port settings
Database path
MCP server configuration
Agent Configuration (agent/agent.py)
AI model selection (default: gpt-4.1)
System prompt customization
Agent behavior settings
Database location
š Troubleshooting
Dependencies missing?
Database not initialized?
Port already in use?
Agent can't connect to MCP?
Ensure MCP server is running:
python start.py --mcpCheck MCP URL in
agent/agent.py(default: http://localhost:9002/mcp)
š Presentation
This project includes a presentation about practical AI agent implementation:
š Live Demo
š Local Files
English Slides: docs/en/index.html
Russian Slides: docs/ru/index.html
Open the slides to learn more about AI agents and MCP protocol.
š Resources
This project is built with and inspired by amazing open-source projects:
Model Context Protocol (MCP) - Standard protocol for connecting AI agents to tools
FastAPI-MCP - FastAPI integration for MCP servers
Agno - Modern framework for building AI agents
Agent UI - Beautiful chat interface for AI agents
Special thanks to these projects and their maintainers for making AI agent development accessible and enjoyable! š
š License
MIT
Built with ā¤ļø using AI agents and MCP
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Enables AI agents to manage personal expenses through natural language conversations. Supports adding, searching, and analyzing transactions with automatic categorization and financial insights.
- šÆ What This Demonstrates
- šļø Architecture
- š Features
- š Project Structure
- š Quick Start
- š¬ Usage Examples
- š ļø Tech Stack
- š How MCP Works Here
- š API Endpoints
- šÆ Server Commands
- š¤ Agent Capabilities
- š§ Configuration
- š Troubleshooting
- š Presentation
- š Resources
- š License