
mcp-server-ledger
MCPLets AI read Ledger CLI plain-text double-entry ledgers and query balances, registers, accounts, payees and budget performance. Easiest with Docker and the author's image (Ledger CLI included), or install Ledger CLI yourself; needs your ledger file.
mcp-server-ledger: A Ledger CLI MCP Server
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:
-
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
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_FILEenvironment 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:
- Clone the repository
- Install development dependencies
- Make your changes
- 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.
関連リソース

Beancount
CLILanguage and toolset for double-entry bookkeeping in text files: bean-check validates the ledger, bean-format normalizes it, and Fava or beanquery handle reports and queries. Plain-text ledgers are easy for agents to generate and keep in version control.
beancount/beancount6.1k
Ledger
CLIClassic plain-text double-entry accounting CLI: entries live in a text file and it produces balance, register, budget and other reports directly, with no database or hidden state, so agents can easily read and write ledgers, reconcile and report.
ledger/ledger6.1k
hledger
CLIPlain-text double-entry accounting: track income, expenses, investments and time, generate balance sheets, income statements and budget reports in one command, with CSV import and JSON output for agent reconciliation and reporting. Converts to and from Beancount.
hledgerorg/hledger4.8k
rustledger
CLIBeancount plain-text accounting in Rust (rledger): validate ledgers, run BQL queries, build balance sheets and income statements, import bank CSV/OFX, track budgets, returns and capital gains. Has an MCP server and ag-rledger (JSON output) for agents. Tax figures need an accountant's review.
rustledger/rustledger418
hledger-flow
CLIhledger workflow that files bank and card CSV exports in a set folder layout and applies rules to build journals in one step, rebuilding when rules change. Needs hledger; download from Releases (macOS and Linux only). Have an accountant check the books.
apauley/hledger-flow220
beanquery
CLIBeancount's official query tool, bean-query: run SQL-like queries on plain-text double-entry ledgers to get balances, income and expense summaries and account details, for agent-assisted bookkeeping. Needs uv or Python 3.8+ and a Beancount ledger; have an accountant review reports.
beancount/beanquery66
