Skip to main content
Glama
minhyeoky

Ledger CLI MCP Server

by minhyeoky

ledger_stats

Generate and display detailed statistics from a ledger file, enabling financial analysis through customizable query filters with the Ledger CLI MCP Server.

Instructions

Show statistics about the ledger file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • main.py:232-239 (handler)
    The handler function for the 'ledger_stats' tool. It constructs a 'ledger stats' command (optionally filtered by query) and executes it using the shared run_ledger helper.
    @mcp.tool(description="Show statistics about the ledger file")
    def ledger_stats(params: LedgerStats) -> str:
        cmd = ["stats"]
    
        if params.query:
            cmd.append(params.query)
    
        return run_ledger(cmd)
  • main.py:84-86 (schema)
    Pydantic schema/model defining the input parameters for the ledger_stats tool, including an optional query filter.
    class LedgerStats(BaseModel):
        query: Optional[str] = Field(None, description="Filter for statistics")
  • Shared helper function that runs ledger CLI commands with input validation, error handling, and uses the LEDGER_FILE environment variable.
    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 the full burden of behavioral disclosure. It only states what the tool does ('Show statistics') without any details on output format, performance, error handling, or other behavioral traits. This is inadequate for a tool with parameters and no output schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's appropriately sized for a simple tool, though its brevity contributes to gaps in other dimensions. It's front-loaded and clear in its minimal form.

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 complexity (1 parameter, no annotations, no output schema, and multiple sibling tools), the description is incomplete. It fails to explain what statistics are shown, how to use the parameter, or how it differs from other tools. This leaves significant gaps for an AI agent to operate effectively.

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 input schema has 1 parameter with 0% description coverage, and the tool description provides no information about parameters. It doesn't explain what the 'query' parameter does, how to use it, or what 'Filter for statistics' means in practice. This leaves the parameter undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Show statistics about the ledger file' states a clear verb ('Show') and resource ('ledger file'), but it's vague about what specific statistics are shown and doesn't differentiate from sibling tools like 'ledger_balance' or 'ledger_register' that might also show statistical information. It provides a basic purpose but lacks specificity.

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

Usage Guidelines2/5

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

The description offers no guidance on when to use this tool versus alternatives like 'ledger_balance' or 'ledger_register', nor does it mention any prerequisites or exclusions. It's a generic statement with no contextual usage information, leaving the agent to guess based on tool names alone.

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