agent-cost-analyzer
v1.2.0Local, read-only analysis of agentic coding costs, caching and sessions from your own logs.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
list_log_providers List log providers
Lists the local agent-log sources (VS Code Copilot Chat, Claude Code CLI, pi, mitmproxy captures), whether each is available and why not, and which one is active. Use it to pick a `provider` argument or to explain why a source has no sessions.
list_sessions List sessions
Finds agent sessions of one provider, most recent first: start here to get the session ids every other per-session tool needs. Filter by a title/id substring, a start-date window, a repository and a project; each session names its repository key (null with unattributedReason when it has none) and project. `total` is the number of matches before `limit`, so you can tell whether to narrow the search.
| Parameter | Type | Description |
|---|---|---|
limit | integer | Maximum sessions to return (default 20). |
projectId | string | Only sessions in this project (an id from list_projects). |
provider | string | Log provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app. |
query | string | Case-insensitive substring of the session title or id. |
repository | string | Only sessions in this repository (a key from list_repositories). |
since | string | Earliest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp. |
until | string | Latest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp. |
get_turn Get one turn
Reads one turn of a session: the user prompt and assistant response (secrets redacted, truncated to maxTextChars), its token usage and AI Credits, any triggered event (compaction, model switch, cache expiry, ...) and its tool calls with outcomes. The text and tool calls are unknown, with a reason, for a VS Code Agent Host turn whose Copilot CLI event log is missing, unreadable or has no match. Use it to explain why a turn found by get_session_cost or list_tool_calls was expensive or failed. `cost` gives the turn's billed, reported and priced figures (the priced one names its price version) and…
| Parameter | Type | Description |
|---|---|---|
sessionId * | string | Session id from list_sessions. |
turnIndex * | integer | 0-based turn index, e.g. from get_session_cost's topTurns or list_tool_calls. |
maxTextChars | integer | Maximum characters per text field (default 2000). |
provider | string | Log provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app. |
get_session_audit Get session tool-call audit
Summarizes how one session's tool calls went: totals by outcome (success/error/interrupted/denied/unknown), failure rate, breakdowns by tool, shell program and failure category (command-not-found, wrong-directory, invalid-arguments, dependency-missing, git-state, ...), per-turn counts, retried commands, the tokens spent recovering from failures, and outcome coverage. Counts include tool calls made inside subagent runs; byOrigin splits main agent and subagents; a run whose calls couldn't be read is listed with its reason, never as 0. Start here for "why did the agent struggle?"; use list_tool_c…
| Parameter | Type | Description |
|---|---|---|
sessionId * | string | Session id from list_sessions. |
includeCalls | boolean | Also return every classified call (default false; can be large — prefer list_tool_calls with filters). |
provider | string | Log provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app. |
list_tool_calls List classified tool calls
Lists one session's tool calls with outcome, exit code, failure category, a redacted stderr excerpt, the command and program, and the turn index. Each call says whether the main agent or a subagent run made it. Filter by outcome, failure category, tool kind (shell, file-write, web, mcp, subagent, ...), tool name, shell program, turn, origin (main or subagent) or one subagent run; page with offset/limit (`total` counts every match). For a VS Code Agent Host session without a Copilot CLI event log the list is empty and toolCallsUnavailableReason says why: the calls are unknown, not zero.
| Parameter | Type | Description |
|---|---|---|
sessionId * | string | Session id from list_sessions. |
failureCategory | array | Keep only these failure categories. |
kind | array | Keep only these tool kinds, e.g. ["shell"] or ["web","mcp"]. |
limit | integer | Maximum calls to return (default 50). |
offset | integer | Skip this many matching calls (default 0). |
origin | array | Keep only calls by the main agent or by subagents, e.g. ["subagent"]. Default: both. |
program | string | Shell program, e.g. "npm" or "git". |
provider | string | Log provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app. |
runId | string | Only calls made by this subagent run (its origin.runId). |
status | array | Keep only these outcomes, e.g. ["error","interrupted","denied"]. |
tool | string | Exact tool name, e.g. "Bash" or "run_in_terminal". |
turnIndex | integer | Only this 0-based turn. |
get_audit_rollup Get cross-session tool-call rollup
Aggregates tool-call outcomes across one provider's most recent sessions in a date window: totals, failure rate, the top failing commands (and in how many sessions they failed), failures per day, a per-session summary, and breakdowns by tool, program and failure category. Sessions whose tool calls are unknown (a VS Code Agent Host session without a Copilot CLI event log) are not included in any count or rate; sessionsWithUnknownToolCalls says how many were left out and toolCallsUnavailableReason why. Counts include tool calls made inside subagent runs; byOrigin splits main agent and subagents;…
| Parameter | Type | Description |
|---|---|---|
limit | integer | How many of the most recent sessions to read per provider (default 50, max 500). |
provider | string | Log provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app. |
since | string | Earliest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp. |
until | string | Latest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp. |
get_session_cost Get session cost
Explains what one session cost and why: token totals (uncached input, cache write, cache read, reasoning, output) and AI Credits, each with turn coverage; cache hit ratio; spend per model; the most expensive turns; cost-relevant events (compaction, cache expiry, model switch, ...); and context overhead (system-prompt parts, tools defined but never used); the session's repository and project; `subagents` (the runs and their total) when the session's totals include subagent runs: AI Credits for Copilot Chat; tokens and priced cost for Claude Code, which has no AI Credits. A run that cannot be re…
| Parameter | Type | Description |
|---|---|---|
sessionId * | string | Session id from list_sessions. |
provider | string | Log provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app. |
topTurns | integer | How many of the most expensive turns to return (default 5). |
get_cost_rollup Get cross-session cost rollup
Answers "what is driving my spend?" across every available provider (or one, with `provider`) in a date window, optionally for one repository or project: token and AI Credits totals with coverage, per-basis cost totals, cache hit ratio, spend by provider, model, day, repository, project, vendor and channel, the most expensive sessions, and `reconciliation` (Copilot's billed AI Credits against the price book, per model and month: a steady gap means the price book is out of date). Follow up with get_session_cost on a top session. The same data the web Dashboard shows. `active`: true marks a sess…
| Parameter | Type | Description |
|---|---|---|
limit | integer | How many of the most recent sessions to read per provider (default 50, max 500). |
projectId | string | Only turns in this project (from list_projects). |
provider | string | Restrict to one log provider id (see list_log_providers). Default: every available provider. |
repository | string | Only turns attributed to this repository key (from list_repositories). |
since | string | Earliest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp. |
topSessions | integer | How many of the most expensive sessions to return (default 10). |
until | string | Latest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp. |
get_repository_cost Get a repository's cost over time
Answers "what did this repository cost, and how did it change?" for one repository key from list_repositories, across every available provider unless `provider` is given. Defaults: monthly buckets, the preferred basis, prices as of use, native currencies. Returns totals per basis with coverage (knownTurns of turns), one point per bucket in the range (UTC; a bucket with turns but nothing known has usd null and no amounts: a gap, never 0) with a running total, a breakdown by vendor then model, and the documented price changes in the range for the models priced (priceChanges). Turns are bucketed…
| Parameter | Type | Description |
|---|---|---|
repository * | string | Repository key from list_repositories, e.g. github.com/org/app or local:<folder name>. |
basis | string | Which cost basis the figures use: "preferred" (default: billed, else reported, else priced per turn), or only "billed", "reported" or "priced". |
bucket | string | Bucket size: "day", "week" (ISO weeks) or "month" (default), in UTC. |
currency | string | "native" (default): each figure in its own unit (AI Credits or USD), totals per currency. "usd": everything in USD at 1 AI Credit = $0.01, the only conversion used. |
limit | integer | How many of the most recent sessions to read per provider (default 50, max 500). |
pricing | string | How priced figures are priced: "as-of-use" (default: the price in force when each turn ran) or "today" (every turn at today's prices, for comparing and estimating). |
provider | string | Restrict to one log provider id (see list_log_providers). Default: every available provider. |
since | string | First day, inclusive: "YYYY-MM-DD" (UTC). Sessions started earlier are not read. |
until | string | Last day, inclusive: "YYYY-MM-DD" (UTC). |
get_project_cost Get a project's cost over time and breakdown
Answers "what did this project cost, where did the money go?" for one project id from list_projects: everything get_repository_cost returns for the project's turns, plus a breakdown by repository member, by vendor then model, tokens per model by type (uncached input, cache write, cache read, reasoning, output) and the most expensive sessions. Defaults: monthly buckets, the preferred basis, prices as of use, native currencies. Returns totals per basis with coverage (knownTurns of turns), one point per bucket in the range (UTC; a bucket with turns but nothing known has usd null and no amounts: a…
| Parameter | Type | Description |
|---|---|---|
projectId * | string | Project id from list_projects. |
basis | string | Which cost basis the figures use: "preferred" (default: billed, else reported, else priced per turn), or only "billed", "reported" or "priced". |
bucket | string | Bucket size: "day", "week" (ISO weeks) or "month" (default), in UTC. |
currency | string | "native" (default): each figure in its own unit (AI Credits or USD), totals per currency. "usd": everything in USD at 1 AI Credit = $0.01, the only conversion used. |
limit | integer | How many of the most recent sessions to read per provider (default 50, max 500). |
pricing | string | How priced figures are priced: "as-of-use" (default: the price in force when each turn ran) or "today" (every turn at today's prices, for comparing and estimating). |
provider | string | Restrict to one log provider id (see list_log_providers). Default: every available provider. |
since | string | First day, inclusive: "YYYY-MM-DD" (UTC). Sessions started earlier are not read. |
topSessions | integer | How many of the most expensive sessions to return (default 10, max 50). |
until | string | Last day, inclusive: "YYYY-MM-DD" (UTC). |
compare_costs Compare repositories or projects
Compares 2 to 20 repositories (keys from list_repositories) or projects (ids from list_projects) over one period: per id the total with coverage, the change against the previous period (or the same dates last year), cost per session, per active day and per turn, share of the compared total, cache-hit ratio and output share. Money measures are per currency unless currency is "usd"; a change against a period with nothing known is null, never "from 0". Defaults: the preferred basis, prices as of use, native currencies, the previous period. Cost figures carry their basis: billed (what GitHub Copil…
| Parameter | Type | Description |
|---|---|---|
groupBy * | string | Compare repositories or projects. |
ids * | array | The 2 to 20 repository keys (from list_repositories) or project ids (from list_projects) to compare. |
since * | string | First day of the period, inclusive: "YYYY-MM-DD" (UTC). |
until * | string | Last day of the period, inclusive: "YYYY-MM-DD" (UTC). |
basis | string | Which cost basis the figures use: "preferred" (default: billed, else reported, else priced per turn), or only "billed", "reported" or "priced". |
comparePeriod | string | What the change is measured against: "previous" (default: the same number of days just before) or "last-year" (the same dates a year earlier). |
currency | string | "native" (default): each figure in its own unit (AI Credits or USD), totals per currency. "usd": everything in USD at 1 AI Credit = $0.01, the only conversion used. |
limit | integer | How many of the most recent sessions to read per provider (default 50, max 500). |
pricing | string | How priced figures are priced: "as-of-use" (default: the price in force when each turn ran) or "today" (every turn at today's prices, for comparing and estimating). |
provider | string | Restrict to one log provider id (see list_log_providers). Default: every available provider. |
explain_cost_change Explain why a cost changed
Answers "costs went up 30%: was it a price change, more work, or a different model?" for one repository (key from list_repositories) or project (id from list_projects) between period A and period B. On the priced basis, as of use (tokens × the price version in force when each turn ran), per currency: the usage effect (more or fewer tokens at A's average price), the price effect (B's tokens × the change in unit price) and the mix effect (work moved between models), which add up exactly to the change; per model and token type (uncached input, cache read, cache write, output) with unit prices a…
| Parameter | Type | Description |
|---|---|---|
groupBy * | string | Explain a repository's or a project's change. |
id * | string | The repository key or project id. |
periodA * | A month "YYYY-MM", or {since, until} as "YYYY-MM-DD" (UTC, inclusive). | |
periodB * | A month "YYYY-MM", or {since, until} as "YYYY-MM-DD" (UTC, inclusive). | |
currency | string | "native" (default): each figure in its own unit (AI Credits or USD), totals per currency. "usd": everything in USD at 1 AI Credit = $0.01, the only conversion used. |
limit | integer | How many of the most recent sessions to read per provider (default 50, max 500). |
provider | string | Restrict to one log provider id (see list_log_providers). Default: every available provider. |
list_findings List security, anomaly and behavior-change findings
Lists what the analyzer flagged across every available provider (or one) in a date window, most severe first: security (credential access, pipe-to-shell, destructive or history-rewriting commands, privilege escalation, data upload, ...), anomalies (cost or failure outliers), behavior changes (first use of a program, tool or model) and price changes (kind "price-change": GitHub Copilot billing a model steadily above or below the price book, inferred; see get_price_changes). Each finding says what happened, when, in which session and turn, why it was flagged, with redacted evidence. Security fin…
| Parameter | Type | Description |
|---|---|---|
category | string | Exact category, case-insensitive, e.g. "credential-access" or "cost-outlier". |
kind | array | Keep only these kinds, e.g. ["security"]. |
limit | integer | How many of the most recent sessions to read per provider (default 50, max 500). |
maxResults | integer | Maximum findings to return (default 50); total and bySeverity count every match. |
minSeverity | string | Keep findings at or above this severity (info < low < medium < high < critical). |
origin | array | Keep only findings from the main agent or from subagents, e.g. ["subagent"]. Default: both. |
provider | string | Restrict to one log provider id (see list_log_providers). Default: every available provider. |
sessionId | string | Only findings in this session. |
since | string | Earliest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp. |
until | string | Latest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp. |
get_price_book Get the price book
Use to see which per-token prices the analyzer prices tokens with: each price version of a model on a channel ("github-copilot", "anthropic-api", ... or a user channel), its USD tiers per 1M tokens, the dates it is in force ([effectiveFrom, effectiveTo), UTC), its kind (list, promo, or the user's contract) and its cited sources with checkedAt. Default: every version on every channel. With `at`, only the versions in force then. A channel or model with no price is listed under `unknown` with the reason; it is unknown, never zero. Gaps between versions are listed under `gaps`, and user versions l…
| Parameter | Type | Description |
|---|---|---|
at | string | Only the versions in force at this time: "YYYY-MM-DD" (UTC midnight) or an ISO timestamp. |
channel | string | Only this channel, e.g. "github-copilot". |
model | string | Only this model, by its price-table id, e.g. "claude-sonnet-5.5". |
get_price_changes Get price changes
Use to see when a model's price changed. Two kinds, kept apart: documented (a boundary between two price-book versions: date, old and new USD per 1M tokens per token type, percentage, and the cited sources) and observed (GitHub Copilot only: billed AI Credits more than 5% above or below the price book for the same turns, the same way, 2 ISO weeks in a row with at least 20 such turns each; confidence "inferred", with the weeks as evidence: a prompt to check the price book, not a price). Oldest first. Observed changes read the sessions of every available provider (or one, with `provider`); docum…
| Parameter | Type | Description |
|---|---|---|
channel | string | Only this channel, e.g. "github-copilot". |
kind | string | "documented" or "observed"; default both. |
model | string | Only this model: a price-table id for documented changes, the logged model for observed ones. |
provider | string | Restrict observed changes to one log provider id (see list_log_providers). |
since | string | Changes from this day, inclusive: "YYYY-MM-DD" (UTC). |
until | string | Changes up to this day, inclusive: "YYYY-MM-DD" (UTC). |
list_repositories List repositories
Lists the code repositories the sessions worked in, across every available provider unless `provider` is given: start here to find a `repository` key for list_sessions or to see which project each repository is in. Each entry has its key (a normalised remote such as github.com/org/app; a repository without a remote, or a folder outside one, is local:<folder name> or path:<folder name>), session and turn counts, first and last use, AI Credits with coverage (null is unknown, never zero) and project ids. Sessions with no repository are grouped by reason under `unattributed`. Local folder paths ar…
| Parameter | Type | Description |
|---|---|---|
includeUnattributed | boolean | Include the Unattributed buckets with their reasons (default true). |
projectId | string | Only repositories with a member in this project (see list_projects). |
provider | string | Log provider id (see list_log_providers). Omit to read every available provider. |
since | string | Earliest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp. |
until | string | Latest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp. |
list_projects List projects
Lists the user's projects from their local projects file: each project's id, name and members (a repository key, optionally narrowed to a path inside it and branch patterns). A turn counts in at most one project, the most specific matching member. Use it to pick a `projectId` for list_repositories or list_sessions; `problems` lists what is wrong with the file, if anything. Client names and billing codes are not shared here; a statement (get_statement) has them.
replay_session Replay a session on another model
Use to see what one session (id from list_sessions) would have cost on another model: the session's own request trace (token counts only) is run through that model's vendor caching rules and priced, turn by turn beside what the session really cost. Every figure is Simulated, not measured: it assumes the same conversation (A1: the other model gets the same prompts and answers with as many tokens, which it wouldn't) and the same token counts (A2); the answer lists every assumption. Say "would have cost about", never "would have cost". The self-check (selfCheck) is the same replay on the session'…
| Parameter | Type | Description |
|---|---|---|
model * | string | A model id a vendor profile lists, e.g. "claude-haiku-5.5" or "gpt-6.1-sol" (log spellings such as "claude-opus-5-5-20261001" resolve too). |
sessionId * | string | Session id from list_sessions. |
pricing | string | Which prices the simulated requests are priced at: "session-channel" (default: a Copilot session at Copilot prices in AI Credits, any other at the target vendor's API price in USD, as of the session's… |
provider | string | Log provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app. |
compare_models_for_session Compare models for a session
Use to compare what one session (id from list_sessions) would have cost on several models: each model's simulated total and replayed turns beside the session's measured total, in one currency. Every figure is Simulated, not measured: it assumes the same conversation (A1: the other model gets the same prompts and answers with as many tokens, which it wouldn't) and the same token counts (A2); the answer lists every assumption. Say "would have cost about", never "would have cost". For the per-turn figures, the coverage reasons and the self-check, call replay_session with one model. A model no ven…
| Parameter | Type | Description |
|---|---|---|
models * | array | 1 to 10 model ids a vendor profile lists. The session's own model is added first when a profile lists it, and counts toward the 10. |
sessionId * | string | Session id from list_sessions. |
pricing | string | Which prices the simulated requests are priced at: "session-channel" (default: a Copilot session at Copilot prices in AI Credits, any other at the target vendor's API price in USD, as of the session's… |
provider | string | Log provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app. |
get_savings_report Get the savings report
Use first to answer "how can I spend less": the ranked list of changes that would have cost less over a window (default the last 30 days), the same list as the app's Savings tab. Each row has a kind (unused tools, idle cache expiry, unexplained cache break, model switch, failed tool calls), an amount per week and over the window as a range or an upper bound ("up to"), priced from the price book and not billed, its coverage (sessions analyzed of those in the window, and why the rest were not), the price version ids, up to 10 session ids, each with its start and its own saving over the window (n…
| Parameter | Type | Description |
|---|---|---|
includeSimulated | boolean | Also run the cheaper-model replays and list them as Simulated (default false: a replay per session is slow). |
limit | integer | How many opportunities to return, best first (default 10, max 20). |
pricing | string | How priced figures are priced: "as-of-use" (default: the price in force when each turn ran) or "today". |
provider | string | Log provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app. |
since | string | First day of the window, inclusive: "YYYY-MM-DD". Default: 30 days before until. |
until | string | Last day of the window, inclusive: "YYYY-MM-DD". Default: today. |
get_monthly_allowance Get the monthly AI Credits allowance
Use to answer "how much of my monthly allowance is left?": the AI Credits used so far in the current billing period against the allowance the user set in the app, the same answer as the app's header. The allowance is the user's own number, not a plan lookup. Figures are billed AI Credits of the VS Code Copilot sessions on this machine, whichever provider is active; Claude Code and pi sessions are not counted. Sessions without cost data are left out, so when some are missing the total is a lower bound (atLeast true, "at least") and remaining is an upper bound ("up to"); coverage says how many s…
estimate_cost Estimate the cost of planned work
Use to estimate what planned work on one project (id from list_projects) or repository (key from list_repositories) will cost: a p50–p90 range in USD at today's prices, never a single number, labelled "estimate". It is the median and 90th-percentile cost per active day (or per session) in the last 4 or 12 weeks × the planned active days (or sessions); days or sessions with any unpriced turn are left out and counted. With fewer than 5 known days or sessions there is no range: `refusal` says why. AI Credits are converted at 1 AI Credit = $0.01. With `model`, it estimates on that model instead…
| Parameter | Type | Description |
|---|---|---|
activeDays | integer | Planned active days (or give sessions). |
historyWeeks | History window in weeks: 4 or 12 (default). | |
model | string | Estimate on this model instead (a model id a vendor profile lists, e.g. "claude-haiku-5.5"): the target's sessions replayed on it, Simulated. |
projectId | string | The project id, from list_projects (or give repository). |
repository | string | A repository key, from list_repositories (or give projectId). |
sessions | integer | Planned sessions (or give activeDays). |
get_statement Get a project's billing statement
Use to see what one project (id from list_projects) costs for a period: the frozen statement if the period is issued, with the re-run beside it and the exact diff (late logs, a price-book change), else the draft and whether it can be issued (only an ended period can). Lines per basis, currency, channel, model and price version with tokens and unit prices; turns with unknown cost listed with their reason, never counted as 0; subscription (API-equivalent) use left off unless the project includes it; the project's markup, fixed lines and own currency at its fixed rate; totals per currency; covera…
| Parameter | Type | Description |
|---|---|---|
period * | string | A month "YYYY-MM", or a range "YYYY-MM-DD..YYYY-MM-DD". |
projectId * | string | The project id, from list_projects. |
includeLines | boolean | Include the lines (default true); totals, unknown lines and provenance are always there. |
get_turn_series Get a session's per-turn series
App-only: the per-turn figures (AI Credits, input, cache read, output, events) behind a session's cost chart. Called by the cost view, not by the model; use get_session_cost for the model-facing summary.
| Parameter | Type | Description |
|---|---|---|
sessionId * | string | Session id from list_sessions. |
maxTurns | integer | How many turns to return, from the first (default 500, max 2000). |
provider | string | Log provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app. |