Finance MCP Server
Provides schema discovery and validated read-only SQL query execution against a SQLite database, enabling analysis of financial data such as customers, branches, loans, and payments.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Finance MCP ServerWhat is the total outstanding loan amount?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Finance MCP Server
An MCP server that lets an LLM such as Claude explore and query a synthetic financial SQLite database through two controlled, read-only tools — schema discovery and validated SQL execution.
Note: All financial/customer information in this repository is synthetic data generated for demonstration purposes and does not represent real customers or financial records.
What is this?
A small, self-contained example of connecting an LLM to a real relational database via MCP: the model can inspect the schema on its own, then write and run SQL to answer natural-language questions like "which branch has the highest outstanding loan amount?" — without the database ever being at risk of a mutation, an injection, or a runaway result set.
Related MCP server: Business MCP Server
Features
MCP server (
server.py) built on the officialmcpPython SDKSQLite database with a normalized, foreign-key-enforced schema
Dynamic schema discovery (tables, columns, types, primary/foreign keys)
Read-only SQL querying with multi-layer validation
Relational financial dataset: branches → customers → loans → payments
Synthetic data generation with internally consistent numbers
Query resource limits (row count and output size)
Clean, traceback-free error handling
Example natural-language queries with real, executed output
Architecture
User
│
▼
Claude / MCP Client
│
│ MCP
▼
Finance MCP Server
│
├── Schema Discovery
├── Query Validation
├── Read-only Query Execution
│
▼
SQLite Database
│
├── customers
├── loans
├── payments
└── branchesThe client asks the server what tools are available, calls
get_database_schema() to learn the tables and relationships, then calls
execute_query(sql) with a SELECT statement to answer the user's question.
Full details in docs/architecture.md.
Database Schema
erDiagram
BRANCHES ||--o{ CUSTOMERS : serves
CUSTOMERS ||--o{ LOANS : has
LOANS ||--o{ PAYMENTS : receivesbranches — bank branches
customers — each attached to a home branch
loans — 1-4 loans per customer, with derived
outstanding_amountandstatuspayments — 1-10 payments per loan, chronologically consistent with the loan
Full column-level documentation: docs/database-schema.md.
Example natural-language queries
Once connected, you can ask Claude things like:
"Show me the top 10 customers by annual income."
"Which customers have overdue loans?"
"What is the total outstanding loan amount?"
"Which loan types have the highest average principal?"
"Which branch has the highest total outstanding loan amount?"
"Show customers who have both high income and overdue loans."
Claude answers each of these by calling get_database_schema() once, then
writing and running the appropriate SELECT/JOIN query through
execute_query(). Real output for each example (executed against the
shipped database) is in examples/sample-queries.md.
Installation
git clone https://github.com/DanieloTony/finance-mcp-server.git
cd finance-mcp-server
pip install -r requirements.txtRegenerate the demo database (optional)
A finance.db is already included, but you can regenerate it (with a fresh
random seed's worth of consistent data) at any time:
python generate_database.pyRun the server directly
python server.pyThis starts the MCP server on stdio, which is how an MCP client such as Claude Desktop launches it — you normally won't run this by hand except to confirm it starts without errors.
Run the tests
python -m pytest test.py -vClaude Desktop / MCP client configuration
Add the server to your MCP client's configuration, replacing the path with your own local clone of this repository:
{
"mcpServers": {
"finance-database": {
"command": "python",
"args": ["/absolute/path/to/finance-mcp-server/server.py"]
}
}
}Replace /absolute/path/to/finance-mcp-server with wherever you cloned this
repository — do not hard-code another machine's path or username.
Security considerations
The SQLite database is opened in read-only URI mode (
file:...?mode=ro), plusPRAGMA query_only = ON, so writes are refused at the database layer regardless of what SQL is submitted.SQL is validated before execution: only a single
SELECT/WITHstatement is allowed;INSERT,UPDATE,DELETE,DROP,ALTER,CREATE,REPLACE,ATTACH,PRAGMAand similar mutating keywords are rejected, as are multiple statements in one call.Query results are capped (row count and output size) to protect against an unintentionally huge query.
All demo data is synthetic (generated with Faker); no real personal or financial information is used anywhere in this project.
Limitations, stated plainly: the SQL validator is a keyword/shape check, not a full SQL parser — it is a defense-in-depth layer on top of the read-only connection, not a standalone guarantee. This project is intended for local/demo use and is not a production banking system or a hardened database proxy.
Project structure
finance-mcp-server/
│
├── server.py # MCP server: schema + query tools
├── generate_database.py # Synthetic data generator
├── test.py # Test suite (database, schema, query tools)
├── finance.db # Shipped demo database (synthetic data)
│
├── requirements.txt
├── README.md
├── LICENSE
├── .gitignore
│
├── docs/
│ ├── architecture.md
│ └── database-schema.md
│
└── examples/
└── sample-queries.mdLicense
MIT — see LICENSE.
This server cannot be deployed
Maintenance
Related MCP Connectors
Personal-finance workspace for AI agents: accounts, spending, budgets, goals, and investments.
- Era ContextOAuthapp.era
Personal finance, bank account, and shared memory connector for Claude, ChatGPT, Gemini Spark & more
Connects AI agents to live, verified financial data from 18,000+ institutions — ready to reason from
- BankSyncOAuthio.banksync
Connect AI agents to bank accounts, transactions, balances, and investments.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables LLM agents to perform complete database operations on SQLite databases, including creating tables, executing queries, and managing data through CRUD operations with schema inspection capabilities.21 npmMIT
- FlicenseNot gradedqualityDmaintenanceEnables AI to query a business database for customers, orders, and revenue using natural language through safe, well-defined tools.-
- AlicenseNot gradedqualityCmaintenanceTurns a personal-finance SQLite database into typed, schema-validated tools that an AI assistant can call directly, letting you manage accounts, transactions, budgets, debts, investments, tax estimates, and goals through natural language.38 npmMIT
- FlicenseAqualityBmaintenanceEnables LLMs to answer small business finance questions about spending, sales trends, cash flow projections, and profitability using a local SQLite database.6-