← cost-optimizer

Install cost-optimizer

Three steps: get an API key, add the MCP server to Claude Code, and (if you want cost figures from your own sessions) turn on the usage sync. Nothing is synced until you run it.

1. Create your account and an API key

Sign in with Google, Apple or GitHub, or ask for a sign-in link by e-mail. A new address starts the 30-day trial; no card is needed. If a teammate invited you, open the link they sent or enter the invite code on that page.

On your account page, choose Create an API key. The key is shown once and starts with co_live_; only a hash of it is stored, so a lost key is replaced by a new one. The page fills the commands below with your key and ticks each step off as the service sees it happen.

2. Add the MCP server to Claude Code

In a terminal, with your key in place of YOUR_KEY:

claude mcp add --transport http cost-optimizer https://cost-optimizer.force-field.ai/mcp --header "Authorization: Bearer YOUR_KEY"

Then, inside Claude Code, ask: “call the cost-optimizer account_status tool”. You should see your plan, your limits and the trial end date. An unauthorized answer means the key was mistyped.

Any MCP client that speaks streamable HTTP can use the same address with the same Authorization: Bearer header.

3. Sync usage from your sessions (optional)

The cost figures come from usage metadata in your Claude Code transcripts. One short Python script reads them on your machine (Python 3, standard library only). Read it first if you like; it is one file.

curl -fsSO https://cost-optimizer.force-field.ai/usage_sync.py
python3 usage_sync.py --dry-run --all --since-days 7

The dry run prints the exact payload and sends nothing: per session, hour and model, a 16-character key hashed on your machine, the hour, the model id and token counts. No message content, no paths, no project names.

When you are satisfied, send it:

COST_OPTIMIZER_API_KEY=YOUR_KEY python3 usage_sync.py --all --since-days 30

Run the same command again whenever you want newer sessions included; sending the same sessions twice changes nothing.

4. Use it

Every figure carries the date and status of the rate card it was priced on. A figure that cannot be computed exactly reads “not computable”. These are API-equivalent costs, not an invoice.

Remove it

claude mcp remove cost-optimizer

A packaged Claude Code plugin (skills, an agent and automatic sync at session end) is being published separately; these steps do not need it.