Skip to main content

CostCrunch for Python, the terminal and AI assistants

One package, three ways in to your CostCrunch data:

CLI cost documents list --status needs_attention
Python CostCrunch().materials.history(material_id)
MCP Ask Claude, Cursor or any MCP client "what did we pay for 5/8 sheetrock last month, and is that a good price?"

All three are generated from the same list of operations, so they always match. Everything is read-only and scoped to your company: you see exactly what you see in the CostCrunch app.

Install

uv tool install costcrunch          # or: pipx install costcrunch
cost auth login

This opens your browser to sign in with Google. For an email + password account, use cost auth login --email you@company.com. Your session is stored in ~/.config/costcrunch/credentials.json, readable only by you. cost auth logout removes it.

Or use an API key: create one in CostCrunch under Settings › Connections › API, then cost auth login --api-key (it asks for the key), or set COSTCRUNCH_API_KEY. A key belongs to one company, can only read, and works until you revoke it on that page.

If you belong to more than one company: cost account orgs, then cost account use-org <id> (or pass --org <id> to any command).

CLI

cost search all "tri-state"                        # anything: documents, suppliers, materials...
cost documents list --type invoice --since 2026-10-01
cost documents get <document-id>                   # header + line items + price checks
cost suppliers list
cost suppliers materials <supplier-id> --search sheetrock
cost projects get <project-id>                     # spend by supplier, month, cost type
cost materials find "5/8 sheetrock"                # by meaning, not just words
cost materials history <material-id> --since 2026-01-01
cost materials prices <material-id>                # your history vs other suppliers vs online
cost spend monthly

Add --json to any command for machine-readable output, or --csv on list commands for a spreadsheet: cost --csv suppliers list > suppliers.csv. cost <group> --help lists every command and option.

Python

from costcrunch import CostCrunch

cc = CostCrunch()                                   # your `cost auth login`, or COSTCRUNCH_API_KEY
# cc = CostCrunch(api_key="cc_live_...")            # or pass a key from Settings › API
for d in cc.documents.list(status="needs_attention")["items"]:
    print(d["date"], d["supplier"], d["total"], d["url"])

sheetrock = cc.materials.find("5/8 sheetrock")["items"][0]
history = cc.materials.history(sheetrock["id"], since="2026-01-01")
print(history["summary"]["avg_price_per_unit"], history["summary"]["unit"])

For scripts and CI, use an API key (COSTCRUNCH_API_KEY) instead of signing in. Errors raise costcrunch.ApiError (with .status, .code, .message), NotFound, PermissionDenied or AuthError.

AI assistants (MCP)

The quickest setup is in CostCrunch under Settings › Connections › API: create a key and copy the ready-made command for Claude Code, Claude Desktop or Cursor. They run the server with uv, so there's nothing to install first:

claude mcp add costcrunch --env COSTCRUNCH_API_KEY=cc_live_... -- uvx --from costcrunch cost mcp

If you've installed the CLI and signed in, it can print the setup for your own sign-in instead:

cost mcp setup claude-code                         # prints: claude mcp add costcrunch -- /path/to/cost mcp
cost mcp setup claude-desktop                      # prints the JSON for claude_desktop_config.json
cost mcp setup cursor

The server runs on your computer (cost mcp, over stdio), as you or as your API key. It exposes 20 read-only tools such as search_all, documents_list, materials_find, materials_history, materials_prices, projects_get and spend_monthly, and every result carries a link back into the CostCrunch app.

Security

  • You sign in as yourself. The API decides which company's data you can see from your membership; the --org option only chooses between companies you already belong to.
  • This package can't change anything: there are no write operations in this version, and the API refuses anything but reads from an API key.
  • Only a hash of each API key is stored by CostCrunch; the key is shown once. Revoking it in Settings › Connections › API stops it within a minute.
  • Tokens are stored with 0600 permissions and refreshed automatically. The public Supabase key embedded in the package is the same one the web app ships with.

Developing

uv venv && uv pip install -e '.[dev]'
pytest && ruff check src tests

Each operation lives in src/costcrunch/ops/<group>.py:

@op("suppliers", "get")
def get_supplier(api, supplier_id: Annotated[str, Arg("Supplier id", positional=True)]):
    """Get one supplier: spend, branches and sales rep."""
    return pick(api.get(f"/suppliers/{supplier_id}")["supplier"], {...})

That one function becomes cc.suppliers.get(...), cost suppliers get <id> and the MCP tool suppliers_get. The docstring is the help text and tool description. Its first sentence is the short summary, so write it for a customer. Results are reshaped with pick so internal fields (storage paths, bounding boxes, flags) never leak out and the output doesn't change when the web app's payloads do. tests/test_registry.py enforces the conventions.

Writes are supported by the registry (@op(..., write=True)). The CLI asks for confirmation (or --yes), Python needs confirm=True, and the MCP tool requires a verbatim user_confirmation. None are exposed yet.

Metadata

Release files for costcrunch 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for costcrunch 0.1.0
File Size Uploaded Provenance Actions
costcrunch-0.1.0.tar.gz 32.8 kB With provenance Details for costcrunch-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for costcrunch 0.1.0
File Interpreter ABI Platform Actions
costcrunch-0.1.0-py3-none-any.whl Python 3 none any Details for costcrunch-0.1.0-py3-none-any.whl

Total release size: 70.7 kB

Release files / costcrunch-0.1.0.tar.gz

Download URL costcrunch-0.1.0.tar.gz
Size 32.8 kB
Tags Source
SHA-256 checksum
How to use checksums
dc69bdacdb0592d3acc984f3f3d405a963a5430ad94d2d5abac4188b0f332dab
BLAKE2b-256 checksum
How to use checksums
3e24b03771c5117c6cc780576bb6afd2deefdbd1efa48103ed8e4b5524b1421d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / costcrunch-0.1.0-py3-none-any.whl

Download URL costcrunch-0.1.0-py3-none-any.whl
Size 37.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c66c52fbc46256d85f5dccc898f445e19017304a7f56bdd580e7ba9baf77c1d7
BLAKE2b-256 checksum
How to use checksums
425bb2f7f2cc0b82fc0cb45640e86df3a190fa4f65c4386a3bcff214e7075088
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for costcrunch 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for costcrunch-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page