Skip to main content
Glama
lastro

lastro

by shiborgi

Lastro

Self-hosted, agent-first ledger for personal, family, property, project and business finances. Each independent financial scope is a Book.

An AI agent operates Lastro over MCP: it sends the files your bank, card and point of sale export, and Lastro turns them into a reviewable ledger. A compact web app is where a person reviews and corrects. PostgreSQL is the source of truth.

The model in one picture

file ──▶ movements ──▶ descriptor ──▶ financial records
         (evidence)     (decides)      expense ≠ payment
                                       revenue ≠ receipt
  • Four records. What is owed (an expense) is not what moved (a payment), and what was earned (a revenue) is not what arrived (a receipt). Settlements link them; status is derived from settlements, never stored.

  • Evidence first. Every imported line is staged as a movement. Nothing is inferred from its wording: a descriptor per name (or product code) says what its lines are, and once it is classified every past and future line of that name posts on its own.

  • Revenue from sales, cash from evidence. A point of sale's payments report and an acquirer's sales are the revenue; deposits, Pix credits and the till are the receipts that settle it, so a sale is counted once.

Related MCP server: Payments Agent Gateway (MCP)

Quick start

Requires Bun 1.4+ and Docker.

cp .env.example .env
# set BETTER_AUTH_SECRET — openssl rand -base64 32

docker compose -f docker-compose.release.yml up -d --build
bun install
bun run bootstrap --email you@example.com --password 'a-long-passphrase' \
  --book "My business" --delegate agent@lastro.local --role EDITOR \
  --agent agent:example

That prints an MCP credential once. Then:

macOS on Apple Silicon can use Apple Container instead of Docker; see docs/operating/install.md.

Connecting an agent

Each module is its own MCP server at /mcp/<module>; connect to the ones the agent uses, with one credential:

{
  "mcpServers": {
    "lastro-finance": {
      "url": "http://127.0.0.1:3002/mcp/finance",
      "headers": { "Authorization": "Bearer <credentialId>.<secret>" }
    },
    "lastro-finance-imports": {
      "url": "http://127.0.0.1:3002/mcp/finance-imports",
      "headers": { "Authorization": "Bearer <credentialId>.<secret>" }
    }
  }
}

The others are /mcp/core, /mcp/sales, /mcp/sales-imports and /mcp/close; GET /mcp lists them. A credential acts as one member of one Book, with that member's role. Every operation of a module is a tool on its server. Writes take an idempotencyKey, destructive tools require confirmation: "confirm", and every write is audited with the agent and the operator it acts for. docs/operating/agent.md is the agent's guide: for each import flow, the tool sequence and what to do when a line waits.

Import flows

Flow

Source file

Type

Becomes

nubank-account

Nubank checking account CSV

account-movements

expenses and payments, revenues and receipts, transfers

c6-account

C6 checking account CSV

account-movements

the same

stone-account

Stone account statement

account-movements

Pix sent; the day's Pix sales as one receipt

stone-payouts

Stone payout report

receipt-movements

expected receipts, paid by the bank line

c6-card

C6 card invoice

card-movements

purchases with their instalments

yooga-payments

Point of sale payments by method

revenue-movements

the day's revenue: gross, discount, tip

stone-sales

Stone sales export

revenue-movements

the acquirer's fee

yooga-sales

Point of sale sales by product

sale-movements

the day's sale lines

The providers are examples: each flow is one parser over a documented format. Adding an import flow is a parser, its fixtures and a flow document.

Architecture

packages/kernel   value types, defineOperation, defineModule, the importer registry
packages/host     the module list, composition, the single generated init
packages/config   validated environment configuration
packages/testing  fitness tests, the integration suite, the smoke test

modules/core              identity, Books, membership, agent credentials, audit, idempotency
modules/finance           catalogs, the four records, transfers, imported evidence
modules/sales             products, sale evidence and lines, sales days
modules/finance-imports parsers of bank, card, point-of-sale and acquirer files
modules/sales-imports     parsers of point-of-sale sales by product
modules/close             the daily close, read from sales and finance

apps/api          HTTP adapter, hosts Better Auth
apps/mcp          MCP adapter, stdio and Streamable HTTP
apps/web          Next.js shell and each module's screens

Each business module owns its rules, contracts, use cases, persistence port, tables, triggers, operations and screens. finance and sales depend only on core; the import modules and close build on them, and every module but core can be left out. A parser can be its own package, contributed to an import module through its manifest. An operation is declared once; the HTTP routes, MCP tools, web client and proxy allowlist derive from it. core's write envelope runs every write: authorization from Book membership, one transaction, idempotent replay and the audit event. Adding a module edits no other: docs/extending/adding-a-module.md.

More: architecture · data model · domain dictionary · data dictionary · diagrams · decisions · roadmap.

Invariants

  • Money is a bigint in the currency's minor unit; JSON carries decimal strings. No floats, anywhere.

  • Every operation is scoped to an authenticated Book, and every reference carries the Book in its key.

  • Settlements carry their item's sign and never exceed it; payments and receipts are the signed sum of their settlements and never negative. These are database triggers.

  • Status is derived from active settlements; settlements are voided, never edited.

  • Every write is idempotent by key and appends an audit event.

Development

docker compose up -d          # PostgreSQL 16 on :5432
bun install
DATABASE_URL=postgres://lastro:lastro@localhost:5432/lastro bun run db:init
bun run check                 # typecheck, lint, unit and fitness tests, builds, scans
bun run test:integration      # Docker: real PostgreSQL, both adapters
bun run smoke                 # Docker: the install path end to end

Changing the schema: edit the owning module's src/db/schema.ts or src/db/triggers.sql, then bun run db:regenerate. There is one init by design; Lastro ships a database it creates, not one it upgrades.

Contributing

See CONTRIBUTING.md and the code of conduct. Security reports: SECURITY.md.

License

MIT — see LICENSE. UI primitives are copied from shadcn/ui, also MIT; see THIRD_PARTY_NOTICES.md.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Double-entry accounting ledger MCP server for autonomous agents that enables creating accounts, posting journal entries, and generating financial reports.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      MCP server for double-entry bookkeeping with idempotent writes, immutable entries, and audit trail. Enables trustworthy financial recording and verification through natural language.
      8 npm
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      Enables AI agents to create accounts, record balanced double-entry transactions, query balances, and reconcile accounts against a SQLite-backed ledger through four MCP tools.
      4
      -