Ledger CLI MCP server

Integrates with Ledger CLI to enable natural language queries for financial data analysis, report generation, and budget tracking through nine structured tools that map directly to Ledger commands.
Back to servers
Provider
Minhyeok Lee
Release date
Mar 16, 2025
Language
Python
Stats
18 stars

This MCP server integrates with Ledger CLI to allow AI assistants to analyze your financial data through a standardized interface. It provides tools for balance reports, transaction history, budget analysis, and more, making it easier to manage your personal or business finances.

Prerequisites

  • Ledger CLI must be installed and available in your PATH
  • A valid Ledger file with your financial data

Installation

Using uv (recommended)

The easiest way to install and run this server is with uv:

uv sync

Configuration

The server requires a path to your Ledger file. This can be provided through:

  • The LEDGER_FILE environment variable
  • Command-line arguments when starting the server

Using with Claude Desktop

Add this to your claude_desktop_config.json:

"mcpServers": {
  "ledger": {
    "command": "uv",
    "args": [
      "run",
      "--env-file",
      "/path/to/your/.env",  // Optional: to set LEDGER_FILE
      "--with",
      "mcp[cli]",
      "mcp",
      "run",
      "<repo_path>/main.py"  // Path to the main.py file in this repository
    ]
  }
}

Available Tools

The server provides several tools that map directly to Ledger CLI commands:

ledger_balance

Shows account balances with powerful filtering options

  • Inputs: query pattern, date ranges, display options
  • Returns: Formatted balance report

ledger_register

Shows transaction register with detailed history

  • Inputs: query pattern, date ranges, sorting options
  • Returns: Formatted register report

ledger_accounts

Lists all accounts in the ledger file

  • Input: optional query pattern
  • Returns: List of matching accounts

ledger_payees

Lists all payees from transactions

  • Input: optional query pattern
  • Returns: List of matching payees

ledger_commodities

Lists all commodities (currencies) used

  • Input: optional query pattern
  • Returns: List of matching commodities

ledger_print

Prints transactions in ledger format

  • Inputs: query pattern, date ranges
  • Returns: Formatted ledger entries

ledger_stats

Shows statistics about the ledger file

  • Input: optional query pattern
  • Returns: Statistical summary of the ledger

ledger_budget

Shows budget analysis

  • Inputs: query pattern, date ranges, reporting period
  • Returns: Budget report

ledger_raw_command

Runs a raw Ledger CLI command

  • Input: command arguments as a list of strings
  • Returns: Command output as text

Usage Examples

Once configured, you can ask your AI assistant questions about your financial data:

  • "Show me my expenses for the last month"
  • "What's my current balance in all accounts?"
  • "List all transactions with Amazon"
  • "How much did I spend on groceries in 2023?"
  • "Show me my budget performance for Q1"

Debugging

For more detailed local testing:

mcp dev main.py

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later