Skip to main content
Glama
Omkar4141

Expense Tracker MCP Server

by Omkar4141

šŸ’° Expense Tracker using MCP (FastMCP + LangChain + Ollama)- Sample Project for understanding MCP

This project demonstrates a simple end-to-end MCP (Model Context Protocol) example where:

  • A FastMCP server exposes tools to manage expenses stored in SQLite

  • A LangChain client connects to the MCP server

  • An LLM (Llama 3.2 via Ollama) decides when to call tools

  • Natural language queries like

    "Add my expense 500 to groceries" automatically trigger backend database operations

šŸ“Œ Architecture Overview

User (CLI)
   │
   ā–¼
LangChain Client (client.py)
   │
   │  MCP (stdio)
   ā–¼
FastMCP Server (main.py)
   │
   ā–¼
SQLite Database (expenses.db)

Key Components

Component

Description

FastMCP

Exposes database operations as tools

LangChain MCP Adapter

Connects LLM to MCP tools

Ollama (Llama 3.2:3b)

Interprets user intent and calls tools

SQLite

Persistent expense storage


Related MCP server: Expense Tracker MCP

šŸ“‚ Project Structure

.
ā”œā”€ā”€ main.py        # FastMCP expense database server
ā”œā”€ā”€ client.py      # LangChain MCP client with LLM
ā”œā”€ā”€ expenses.db    # SQLite database (auto-created)
└── README.md

šŸš€ Features

  • āœ… Add expenses using natural language

  • āœ… View total expenses

  • āœ… List all expenses

  • āœ… Automatic tool selection by LLM

  • āœ… Persistent storage using SQLite

  • āœ… MCP-compliant architecture

šŸ› ļø Tools Exposed by MCP Server

The FastMCP server exposes the following tools:

add_expense

Adds a new expense entry.

{
  "amount": 500,
  "category": "groceries",
  "description": "weekly shopping"
}

get_total

Returns the total sum of all expenses.

get_all_expenses

Returns a list of all recorded expenses.

āš™ļø Prerequisites

Make sure you have the following installed:

  • Python 3.10+

  • Ollama

  • Llama 3.2 model

  • uv (Python package runner)

ollama pull llama3.2:3b

šŸ“¦ Install Dependencies

uv add fastmcp langchain langchain-mcp-adapters langchain-ollama

ā–¶ļø Running the Client

Update paths inside client.py:

"command": "/home/omkar/.local/bin/uv",
"args": [
    "run",
    "fastmcp",
    "run",
    "/full/path/to/main.py"
]

Then run:

uv run client.py

🧠 How It Works (Step-by-Step)

  1. User enters a natural language query

  2. LLM decides whether a tool is needed

  3. If required:

    • Tool name + arguments are generated

  4. LangChain invokes MCP tool

  5. Result is returned to LLM

  6. LLM generates final user-friendly respons

Just tell me šŸ‘

Available Tools

3 tools
add_expenseB

Add a new expense

Args: amount: Expense amount category: Expense category (e.g., 'food', 'transport', 'utilities') description: Optional description

Returns: ID of the added expense

ParametersJSON Schema
NameRequiredDescriptionDefault
amountYes
categoryYes
descriptionNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a creation operation ('Add a new expense'), implying mutation, but doesn't address permissions, error conditions, validation rules, or side effects. The return value is mentioned but without details on format or potential failures. More behavioral context is needed for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized. It front-loads the core purpose ('Add a new expense') followed by clear sections for Args and Returns. Every sentence earns its place by providing essential information without redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, mutation operation) and the presence of an output schema (implied by 'Returns: ID of the added expense'), the description is reasonably complete. It covers purpose, parameters, and return value. However, with no annotations and a mutation tool, it could benefit from more behavioral details like error handling or permissions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant semantic value beyond the input schema, which has 0% description coverage. It clarifies that 'amount' is the 'Expense amount', 'category' includes examples like 'food', 'transport', 'utilities', and 'description' is optional with a default. This compensates well for the schema's lack of descriptions, though it doesn't cover validation rules or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Add') and resource ('expense'), making it immediately understandable. It distinguishes from sibling tools like 'get_all_expenses' and 'get_total' by focusing on creation rather than retrieval or aggregation. However, it doesn't explicitly contrast with siblings in the description text itself.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_all_expenses' or 'get_total', nor does it specify prerequisites, constraints, or appropriate contexts for expense creation. The user must infer usage from the purpose alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_all_expensesC

Get all expenses

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Get all expenses' implies a read operation but doesn't specify whether this is paginated, filtered, sorted, or includes metadata. It lacks details on permissions, rate limits, response format, or any side effects. For a tool with zero annotation coverage, this is insufficient behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise ('Get all expenses') but borders on under-specification rather than efficient brevity. While it uses minimal words, it fails to provide necessary context that would help an agent. The structure is simple but lacks front-loading of critical information beyond the basic action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 0 parameters, 100% schema coverage, and an output schema exists, the description's job is reduced. However, for a 'get all' operation with sibling tools present, the description should ideally clarify scope and differentiation. While the output schema will handle return values, the description remains incomplete regarding when and how to use this tool versus alternatives.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage (empty schema), so no parameter documentation is needed. The description doesn't add parameter semantics because there are none to describe, which is appropriate. Baseline score of 4 applies since the schema fully covers the parameter requirements (none).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get all expenses' is a tautology that essentially restates the tool name 'get_all_expenses'. While it does specify the verb 'Get' and resource 'expenses', it lacks any differentiation from sibling tools like 'get_total' or specificity about what 'all' entails. This is minimal information that doesn't add meaningful clarity beyond the name itself.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention sibling tools like 'get_total' (which presumably provides aggregated expense data) or 'add_expense' (for creating expenses), nor does it specify any contextual prerequisites or exclusions. The agent receives no direction on appropriate usage scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_totalB

Get total of all expenses

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but reveals nothing about how it works: no indication of data freshness, calculation method, error conditions, or response format. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that communicates the core purpose without any fluff. It's appropriately sized for a simple tool with no parameters. Every word earns its place, and the structure is front-loaded with essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, has output schema), the description is minimally adequate. The output schema will handle return value documentation, reducing the description's burden. However, for a tool with no annotations, it should ideally provide more behavioral context about calculation method or data scope to reach completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters with 100% schema description coverage, so the schema already fully documents the parameter situation. The description appropriately doesn't waste space discussing non-existent parameters. Baseline for zero parameters is 4, as there's nothing to compensate for and no misleading information.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('total of all expenses'), making the purpose immediately understandable. It distinguishes from sibling 'get_all_expenses' by focusing on the aggregated total rather than individual items. However, it doesn't specify the exact scope (e.g., time period, categories) which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_all_expenses'. It doesn't mention scenarios where a summary total is preferred over detailed listings, nor does it indicate any prerequisites or constraints for usage. The agent must infer usage context from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 3 tool updates
    • First observedadd_expense
    • First observedget_all_expenses
    • First observedget_total

TDQS

B3/5.0
Disambiguation5/5

Each tool has a distinct purpose: add_expense creates new records, get_all_expenses retrieves all records, and get_total calculates a sum. There is no overlap or ambiguity between these operations.

Naming Consistency5/5

All tools follow a consistent verb_noun pattern (add_expense, get_all_expenses, get_total) with clear, descriptive names. The naming style is uniform throughout the set.

Tool Count2/5

With only 3 tools, the set feels thin for an expense tracker domain. It lacks essential operations like updating or deleting expenses, viewing expenses by category or date, or filtering, which limits functionality.

Completeness2/5

The tool set is severely incomplete for expense tracking. It supports adding and viewing all expenses but misses critical operations such as update_expense, delete_expense, get_expense_by_id, and filtering by category or date, leaving significant gaps in the CRUD lifecycle.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    C
    quality
    D
    maintenance
    Enables personal expense management with SQLite storage, allowing users to add, update, delete, list, and summarize expenses by category through natural language interactions.
    5
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables management of expenses via SQLite database, including adding, listing, updating, deleting, filtering, and summing expenses through natural language.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables natural language management of personal expenses, including adding, listing, and summarizing expenses with local SQLite storage.
    -

Latest Blog Posts

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/Omkar4141/dbserver_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server