Cost importer
The break-even card starts from what
Mushi Mushi can estimate alone. The cost importer replaces those estimates with
measured figures. It is a script, scripts/cost-import.mjs in the Mushi Mushi
repository. It runs where your credentials already are (your laptop or your
CI) and posts only the results.
Mushi Mushi never receives your AWS, GitHub, Sentry or Supabase credentials. The importer reads them from your environment and sends Mushi Mushi lines like “Supabase project, $12.40 a month, this formula, measured”.
What it reads
| Source | Needs | What it sends |
|---|---|---|
| Supabase | SUPABASE_ACCESS_TOKEN | Each organization’s plan and each project’s compute add-on: the plan once per organization, plus compute above the included credit. A project several apps share is split by the bytes each app’s tables and storage buckets take (from the prefixes and buckets in your config, or the table prefixes set on the break-even card). It is never divided by the number of apps: with nothing to split by, it posts no line and says so. |
| GitHub Actions | gh signed in as the billing account | Your net Actions cost per repository for 30 days, from /users/<user>/settings/billing/usage, as a bill per app (it shows on the Spend tab too). |
| Sentry | SENTRY_AUTH_TOKEN (org:read) | Accepted error events per Sentry project for 30 days. The plan price is split by each app’s share. |
| AWS | The AWS CLI with a read-only profile (ce:GetCostAndUsage, cloudwatch:GetMetricStatistics) | Cost Explorer by your cost-allocation tag (default project) as a bill per app. Until the tag has data: S3 split by bucket size, and the other services in one line not yet split by app. |
| App usage | SUPABASE_ACCESS_TOKEN, a read-only SQL query in your config | The AI cost per active user (median and p90 over 30 days), priced from each provider’s list price. This is the variable cost per payer. |
| Fixed | Your config | Plans with no usage API: a crawler plan, domains, a design tool. |
Every line carries its formula, its inputs, its source (measured or list price), its confidence, the date, and how a shared cost was split.
Run it
-
Open Portfolio → Break-even → Run the cost importer and choose Create an importer key. It is an account key with write access, shown once, and its owner must be a team owner or admin. Revoke it under MCP → Setup → Account keys. The panel also shows the commands below with your team id filled in.
-
Clone the repository (
git clone --depth 1 https://github.com/kensaurus/mushi-mushi; the script needs Node 20 or later and no install). Copyscripts/cost-import.example.jsonto a private place outside the repository and fill in your mapping: which app uses which tables, buckets, repositories, Sentry projects and AWS tag values. -
The GitHub source reads Actions billing with
gh api, so yourghlogin needs theuserscope (gh auth refresh -h github.com -s user). Without it the GitHub lines are skipped and the run says so. -
Dry-run it and read the result:
MUSHI_API_KEY=mushi_… node scripts/cost-import.mjs \ --org <your team id> --config ~/private/cost-import.json \ --dry-run --out ~/private/cost-lines.json -
Run it without
--dry-runto post. Re-running replaces the lines it posted before. A source that fails keeps its older lines and says why. Bills replace the days they cover.
--only supabase,github runs some sources. Under CI (CI=true) it prints
counts, never amounts.
Your config
{
"github": { "user": "your-billing-user", "repos": { "repo-name": "app-slug" } },
"sentry": { "org": "your-org", "planUsd": 26, "projects": { "sentry-project": "app-slug" } },
"supabase": {
"apps": {
"app-slug": { "ref": "abcdefghijklmnopqrst", "tablePrefixes": ["app_"], "buckets": ["app-media"] }
}
},
"aws": { "tagKey": "project", "region": "ap-northeast-1", "buckets": { "app-media-bucket": "app-slug" } },
"appUsage": [
{
"app": "app-slug",
"supabaseRef": "abcdefghijklmnopqrst",
"sql": "select user_id, model, sum(input_tokens) as input_tokens, sum(output_tokens) as output_tokens, count(*) as calls from app_ai_usage where created_at > now() - interval '30 days' group by user_id, model"
}
],
"fixed": [
{ "component": "crawler", "vendor": "crawler", "label": "Crawler plan", "monthlyUsd": 16, "formula": "Hobby plan, list price" }
]
}Apps are named by their slug in Mushi Mushi. Repositories, Supabase projects
and Sentry projects already set on an app (Settings → Integrations) are
used without a mapping; the config only adds what Mushi Mushi cannot know.
The usage query runs read-only and must return user_id, model,
input_tokens and output_tokens (and optionally calls). A model with no
list price in scripts/lib/model-prices.mjs is counted as $0 and the line says
how many calls that was.
Keep it private
The config, the dry-run output and your figures belong to you. Keep them out of any repository. Mushi Mushi stores the posted lines in your team’s data, which only your team’s members can read.