Skip to main content
Glama
minhyeoky

Ledger CLI MCP Server

by minhyeoky

ledger_accounts

Retrieve and filter a list of accounts in Ledger CLI using regex patterns to streamline financial data analysis and reporting tasks.

Instructions

List all accounts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • main.py:188-195 (handler)
    The handler function for the 'ledger_accounts' tool. It constructs the 'ledger accounts' command with an optional query filter and executes it via the run_ledger helper. Registered using the @mcp.tool decorator.
    @mcp.tool(description="List all accounts")
    def ledger_accounts(params: LedgerAccounts) -> str:
        cmd = ["accounts"]
    
        if params.query:
            cmd.append(params.query)
    
        return run_ledger(cmd)
  • main.py:58-60 (schema)
    Pydantic BaseModel schema for input parameters to the ledger_accounts tool, defining an optional query string for filtering accounts.
    class LedgerAccounts(BaseModel):
        query: Optional[str] = Field(None, description="Filter accounts by regex pattern")
  • main.py:188-188 (registration)
    The @mcp.tool decorator registers the ledger_accounts function as an MCP tool with the description 'List all accounts'.
    @mcp.tool(description="List all accounts")
  • Shared helper function that runs ledger CLI commands securely, used by ledger_accounts 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
Behavior2/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. 'List all accounts' implies a read-only operation, but it doesn't specify whether this is a safe query, if it requires authentication, what the output format might be, or if there are any rate limits. For a tool with no annotation coverage, this leaves significant behavioral gaps that could affect agent decision-making.

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 extremely concise at just three words, with no wasted language. It's front-loaded with the core action and resource, making it easy to parse quickly. For a simple listing tool, this brevity is appropriate and efficient.

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

Completeness2/5

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

Given the complexity of a ledger system with multiple sibling tools, no annotations, no output schema, and incomplete parameter documentation, the description is inadequate. It doesn't explain what an 'account' means in this context, how the listing is formatted, or how it relates to other ledger operations. For a tool in a potentially complex domain, more context is needed to ensure proper usage.

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

Parameters3/5

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

The description mentions no parameters, but the input schema has one parameter ('query') with 0% description coverage in the schema itself. The description doesn't compensate by explaining what 'query' does or how it filters accounts, leaving the parameter undocumented. However, with only one parameter and a baseline expectation, this is minimally adequate but lacks detail.

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 'List all accounts' clearly states the action (list) and resource (accounts), making the basic purpose understandable. However, it doesn't differentiate this tool from its siblings like 'ledger_balance' or 'ledger_register', which might also involve account-related operations. The purpose is stated but lacks specificity about what makes this tool unique in the ledger context.

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 provides no guidance on when to use this tool versus alternatives. With multiple sibling tools like 'ledger_balance', 'ledger_register', and 'ledger_stats', it's unclear if this is the primary account listing tool or if others serve overlapping purposes. There's no mention of prerequisites, context, or exclusions that would help an agent choose appropriately.

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