Skip to main content
Glama
minhyeoky

Ledger CLI MCP Server

by minhyeoky

ledger_register

Filter, sort, and group financial transactions by date, payee, or period using regex patterns and customizable parameters for precise financial analysis.

Instructions

Show transaction register

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • main.py:35-55 (schema)
    Pydantic model defining the input schema for the ledger_register tool parameters.
    class LedgerRegister(BaseModel):
        query: Optional[str] = Field(
            None, description="Filter transactions by regex pattern"
        )
        begin_date: Optional[str] = Field(
            None, description="Start date for transactions (YYYY/MM/DD)"
        )
        end_date: Optional[str] = Field(
            None, description="End date (exclusive) for transactions (YYYY/MM/DD)"
        )
        monthly: bool = Field(False, description="Group by month")
        weekly: bool = Field(False, description="Group by week")
        daily: bool = Field(False, description="Group by day")
        yearly: bool = Field(False, description="Group by year")
        sort: Optional[str] = Field(
            None, description="Sort transactions (date, amount, payee)"
        )
        by_payee: bool = Field(False, description="Group by payee")
        current: bool = Field(
            False, description="Show only transactions on or before today"
        )
  • main.py:160-185 (handler)
    The handler function for the ledger_register tool. It constructs the ledger CLI command based on parameters and executes it using run_ledger helper.
    @mcp.tool(description="Show transaction register")
    def ledger_register(params: LedgerRegister) -> str:
        cmd = ["register"]
    
        if params.query:
            cmd.append(params.query)
        if params.begin_date:
            cmd.extend(["-b", params.begin_date])
        if params.end_date:
            cmd.extend(["-e", params.end_date])
        if params.monthly:
            cmd.append("--monthly")
        if params.weekly:
            cmd.append("--weekly")
        if params.daily:
            cmd.append("--daily")
        if params.yearly:
            cmd.append("--yearly")
        if params.sort:
            cmd.extend(["-S", params.sort])
        if params.by_payee:
            cmd.append("-P")
        if params.current:
            cmd.append("-c")
    
        return run_ledger(cmd)
  • Shared helper function that executes ledger CLI commands safely, used by ledger_register and other tools.
    def run_ledger(args: List[str]) -> str:
        try:
            if not LEDGER_FILE:
                return "Ledger file path not set. Please provide it via --ledger-file argument or LEDGER_FILE environment variable."
    
            # Validate inputs to prevent command injection
            for arg in args:
                if ";" in arg or "&" in arg or "|" in arg:
                    return "Error: Invalid characters in command arguments."
    
            result = subprocess.run(
                ["ledger", "-f", LEDGER_FILE] + args,
                check=True,
                text=True,
                capture_output=True,
            )
            return result.stdout
        except subprocess.CalledProcessError as e:
            error_message = f"Ledger command failed: {e.stderr}"
            if "couldn't find file" in e.stderr:
                error_message = f"Ledger file not found at {LEDGER_FILE}. Please provide a valid path via --ledger-file argument or LEDGER_FILE environment variable."
            return error_message
Behavior1/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. 'Show transaction register' implies a read-only operation but provides no information about permissions needed, data format returned, pagination, rate limits, or whether this is a live view versus cached data. For a tool with 10 parameters and no annotation coverage, this is completely inadequate.

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 at just three words, but this brevity comes at the cost of being under-specified rather than efficient. While front-loaded with the core action, it lacks the necessary detail for a tool with this complexity. The structure is simple but incomplete.

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

Completeness1/5

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

Given the tool's complexity (10 parameters, no output schema, no annotations), the description is completely inadequate. It doesn't explain what a 'transaction register' contains, how it differs from other ledger tools, what parameters control, or what format the output takes. This leaves too many gaps for effective tool selection and invocation.

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

Parameters1/5

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

The description mentions no parameters whatsoever, while the schema has 10 parameters with 0% description coverage. The description doesn't even hint at the existence of date filtering, grouping options, or search capabilities that the parameters enable. This leaves the agent with no semantic understanding of what the parameters control.

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 'Show transaction register' is a tautology that essentially restates the tool name 'ledger_register'. It doesn't specify what a 'transaction register' contains or how it differs from sibling tools like ledger_print or ledger_balance. While it indicates a display/read operation, it lacks specificity about scope or content.

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

Usage Guidelines1/5

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

There is absolutely no guidance about when to use this tool versus alternatives. With multiple sibling tools available (ledger_print, ledger_balance, ledger_stats, etc.), the description provides no context about when this specific register view is appropriate versus other ledger reporting tools.

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

Install Server

Other Tools

Related Tools

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/minhyeoky/mcp-server-ledger'

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