> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thinkplatform.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Choose User guide for browser tasks, Developers for CLI, SDK and external agents, and Administration for organization management.
> Confirm identity and organization/project context before operations. Documentation access does not grant ThinkPlatform permissions.
> Review side effects, verify changes with a read, and do not blindly retry an operation with an uncertain outcome.
> Use documented UI steps for the web app and documented public CLI or SDK interfaces for automation. Follow each page’s prerequisites and authentication requirements.

# Lakehouse cost commands

> Inspect spending and investigate SQL warehouses, jobs, and dashboard refresh costs.

These examples assume an authenticated active saved profile with the intended organization and project. Confirm it with `tp context show` before running commands. Add root `--json` before the command when machine parsing needs JSON output; use root `--profile <name>` only to override the active profile.

Use one route consistently. Both routes call the same ThinkPlatform backend and use the same org/project authorization.

## CLI route

Run commands using the active saved profile:

```bash theme={"system"}
tp profile show PROFILE
tp lakehouse costs overview \
  --from YYYY-MM-DD --to YYYY-MM-DD --scope project
tp lakehouse warehouses list
tp lakehouse query-history list \
  --from FROM_ISO --to TO_ISO --limit 200
tp lakehouse jobs list
tp lakehouse runs list --job-id JOB_ID --from ISO_START --to ISO_END --limit 20
```

Use `--scope organization` only as an org owner. Use `--force-refresh` only when stale provider data would materially affect the conclusion; it is not a routine refresh option. Do not enable query text during broad collection.

Run the bounded collector:

```bash theme={"system"}
tp-lakehouse-cost-snapshot --help
```

## MCP route

Use these ThinkPlatform system tools in a managed Agent:

| Intent | MCP system tool | CLI equivalent |
| - | - | - |
| Financial and usage overview | `databricks_get_cost_overview` | `tp lakehouse costs overview` |
| Warehouse state/config | `databricks_list_warehouses` | `tp lakehouse warehouses list` |
| Recent execution causes | `databricks_list_query_history` | `tp lakehouse query-history list` |
| Job definitions | `databricks_list_jobs` | `tp lakehouse jobs list` |
| Period-bounded Job runs | `databricks_list_job_runs` with `start_time_from`/`start_time_to` | `tp lakehouse runs list --from ... --to ...` |
| SQL preview | Databricks SQL preview system tool with `fresh=false` | `tp lakehouse sql preview` |
| Notebook run | Databricks notebook run system tool with `compute_mode` | `tp lakehouse notebooks run --compute ...` |
| Job upsert | Databricks Job upsert system tool with `compute_mode` | `tp lakehouse jobs upsert-* --compute ...` |

Pass explicit cost/query dates and scope, and bound Job runs with `start_time_from`/`start_time_to`. Keep `include_query_text=false`. If a tool is missing, report that capability gap; do not bypass project boundaries with ad-hoc credentials.

## Cost-aware operation examples

```bash theme={"system"}
tp lakehouse sql preview \
  --query "SELECT key, metric FROM ${TP_DATABRICKS_CATALOG}.gold.metrics LIMIT 100"
tp lakehouse sql preview --file check.sql --fresh
tp lakehouse notebooks run notebooks/daily \
  --compute serverless --wait
tp lakehouse jobs upsert-notebook \
  --name daily --notebook-path notebooks/daily --compute serverless --dry-run
```

Preview uses the shared cache by default. Use `--fresh` only for an explicit new read. Prefer `serverless`; use `job-cluster` for unsupported workloads and `existing-cluster` only with an explicit cluster ID and authorization.

## Targeted follow-up

* Filter Query History by `warehouse_id` and status before increasing the limit.
* Inspect runs only for ranked project Jobs; do not enumerate unrelated workspace Jobs.
* Use SQL hash, duration, cache status, bytes/rows read, and status in reports. Retrieve raw SQL only when an org owner explicitly authorizes it and the diagnosis cannot proceed otherwise.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.