Skip to main content

A Model Context Protocol server providing tools to execute Ledger, a powerful command-line accounting system, commands.

Project description

MseeP.ai Security Assessment Badge

mcp-server-ledger: A Ledger CLI MCP Server

smithery badge

Overview

A Model Context Protocol server for interacting with Ledger CLI, a powerful, double-entry accounting system accessible from the command line. This server allows Large Language Models to query and analyze your financial data through the Ledger CLI tool.

This MCP server exposes Ledger CLI's functionality through a standardized interface, making it easy for AI assistants to help you with financial reporting, budget analysis, and accounting tasks.

Features

The server provides the following tools that map to Ledger CLI commands:

  1. ledger_balance

    • Shows account balances with powerful filtering options
    • Inputs: query pattern, date ranges, display options
    • Returns: Formatted balance report
  2. ledger_register

    • Shows transaction register with detailed history
    • Inputs: query pattern, date ranges, sorting options
    • Returns: Formatted register report
  3. ledger_accounts

    • Lists all accounts in the ledger file
    • Input: optional query pattern
    • Returns: List of matching accounts
  4. ledger_payees

    • Lists all payees from transactions
    • Input: optional query pattern
    • Returns: List of matching payees
  5. ledger_commodities

    • Lists all commodities (currencies) used
    • Input: optional query pattern
    • Returns: List of matching commodities
  6. ledger_print

    • Prints transactions in ledger format
    • Inputs: query pattern, date ranges
    • Returns: Formatted ledger entries
  7. ledger_stats

    • Shows statistics about the ledger file
    • Input: optional query pattern
    • Returns: Statistical summary of the ledger
  8. ledger_budget

    • Shows budget analysis
    • Inputs: query pattern, date ranges, reporting period
    • Returns: Budget report
  9. ledger_raw_command

    • Runs a raw Ledger CLI command
    • Input: command arguments as a list of strings
    • Returns: Command output as text

Prerequisites

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

Installation

Using Docker (recommended)

You can also use the Docker image from the minhyeoky/mcp-ledger repository:

docker pull minhyeoky/mcp-ledger

Add this to your claude_desktop_config.json:

"mcp-ledger": {
  "command": "docker",
  "args": [
    "run",
    "-v",
    "/path/to/your/ledger/file.ledger:/main.ledger",
    "-e",
    "LEDGER_FILE=/main.ledger",
    "-i",
    "--rm",
    "minhyeoky/mcp-ledger"
  ]
}

Replace /path/to/your/ledger/file.ledger with the actual path to your ledger file.

Installing via Smithery

To install Ledger CLI MCP Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @minhyeoky/mcp-ledger --client claude

Using uv

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
    ]
  }

}

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"

The AI will use the appropriate Ledger CLI commands through the server to get the information.

Debugging

For more detailed local testing:

mcp dev main.py

Development

This server is built using the Model Context Protocol Python SDK. For more information about MCP and how to develop MCP servers, see the official documentation.

To contribute to this project:

  1. Clone the repository
  2. Install development dependencies
  3. Make your changes
  4. Test using the MCP inspector or by integrating with Claude Desktop

Security Considerations

This server runs Ledger CLI commands on your financial data. While it includes basic validation to prevent command injection, you should:

  • Only use with trusted clients
  • Be careful about which file paths you expose
  • Review all commands before execution

License

This MCP server is licensed under the MIT License. Feel free to use, modify, and distribute it according to the license terms.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_mcp_server_ledger-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_mcp_server_ledger-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_mcp_server_ledger-0.1.0.tar.gz.

File metadata

File hashes

Hashes for iflow_mcp_mcp_server_ledger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ea77ccfa78309ca166059dc8642623d5e3db29b8191efc84403602fc530b5fde
MD5 76c784b8b61e9cd1e147203e3c9607d9
BLAKE2b-256 dae1ef414f2a26bb4f1b2b35ee416f4c7a4d5980c9db480b3768b470b0594810

See more details on using hashes here.

File details

Details for the file iflow_mcp_mcp_server_ledger-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for iflow_mcp_mcp_server_ledger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c7965fecaa35952c9d86afc9b5e369123f41770fcc5cf37ce91ad7641dd5fde
MD5 5c30e227eb8c266acde36f9ee160d330
BLAKE2b-256 9bf7de4ea600e412dd1d2245d6af1e154c73f21a256e9aa63388918e2435eeeb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page