home / mcp / mcp-server-ledger: a ledger cli mcp server
A Model Context Protocol server for interacting with Ledger CLI, a powerful double-entry accounting system. This server enables Large Language Models to query and analyze financial data through a standardized interface, making it easy for AI assistants to help with financial reporting, budget analysis, and accounting tasks.
Configuration
View docs{
"mcpServers": {
"minhyeoky-mcp-server-ledger": {
"command": "docker",
"args": [
"run",
"-v",
"/path/to/your/ledger/file.ledger:/main.ledger",
"-e",
"LEDGER_FILE=/main.ledger",
"-i",
"--rm",
"minhyeoky/mcp-ledger"
],
"env": {
"LEDGER_FILE": "<path-to-ledger-file-inside-container>"
}
}
}
}You can interact with your Ledger data through an MCP server that exposes Ledger CLI functionality in a standardized way. This lets you ask questions about your finances, run reports, and explore transactions using natural language support from your AI assistant while Ledger CLI handles the accounting logic.
To use this MCP server, connect it to your MCP client and issue natural language questions about your Ledger data. The server translates your prompts into Ledger CLI commands under the hood and returns formatted results such as balances, registers, or budget reports. Typical tasks include asking for current balances, reviewing transactions from a date range, listing accounts or payees, and analyzing budget performance. You can combine filters like date ranges and query patterns to narrow results to exactly what you need.
Prerequisites you need on your machine before installing the MCP server are a running Python environment and a Ledger-compatible ledger file. You also need either Docker or UV to host and run the MCP server.
# Prerequisites
python3 --version
python3 -m venv venv
source venv/bin/activate
pip install -U pip
pip install mipcp # assuming the MCP Python SDK name if applicable
# Optional: install UV for easy runtime
# uv is a separate tool you can install via your package managerThe recommended way is to run the MCP server inside a Docker container. Pull the image and mount your Ledger file so the server can access your data.
docker pull minhyeoky/mcp-ledger
```
```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.If you use Claude Desktop, configure the MCP server connection to run the Docker command shown here. This lets Claude Desktop route questions to Ledger CLI through the MCP server.
"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"
]
}
```
Make sure your ledger file path is correct and accessible by the Docker engine.You can also run the MCP server using UV for a streamlined workflow. Start the synchronization to bring the MCP server online.
uv sync
```
If you need a specific start command, adapt to your environment following the runtime guidance in your setup.The server requires a path to your Ledger file. Provide this via the LEDGER_FILE environment variable or by passing it as a command-line argument when starting the server. When using Docker, you typically mount the ledger file and set LEDGER_FILE to point to the mounted file.
This MCP server executes Ledger CLI commands that operate on your financial data. Validate inputs carefully and restrict access to trusted clients. Keep ledger file paths private and review all commands before execution.
If you encounter issues, verify that the Ledger file is accessible inside the container or runtime, check that LEDGER_FILE points to the correct path, and ensure the MCP server process has sufficient permissions to read the ledger. Restart the container or runtime after changes.
The MCP server exposes a suite of Ledger CLI-based tools to query balances, registers, accounts, payees, commodities, and more, enabling rich financial insights via natural language prompts.
Shows account balances with filtering options such as query patterns and date ranges and returns a formatted balance report.
Displays the transaction register with detailed history, supporting query patterns and date ranges and returns a formatted register report.
Lists all accounts in the ledger file, with an optional query pattern to filter results.
Lists all payees from transactions, with optional query filtering.
Lists all commodities (currencies) used in the ledger.
Prints transactions in Ledger format for a given query and date range.
Shows statistics about the ledger file, including counts and totals.
Provides budget analysis over a specified period.
Executes a raw Ledger CLI command and returns the textual output.