agent-cost-analyzer

v1.2.0
io.github.raulkivi/agent-cost-analyzer Checked 10 hours ago Published 11 days ago

Local, 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.

ParameterTypeDescription
limitintegerMaximum sessions to return (default 20).
projectIdstringOnly sessions in this project (an id from list_projects).
providerstringLog provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app.
querystringCase-insensitive substring of the session title or id.
repositorystringOnly sessions in this repository (a key from list_repositories).
sincestringEarliest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp.
untilstringLatest 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…

ParameterTypeDescription
sessionId *stringSession id from list_sessions.
turnIndex *integer0-based turn index, e.g. from get_session_cost's topTurns or list_tool_calls.
maxTextCharsintegerMaximum characters per text field (default 2000).
providerstringLog 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…

ParameterTypeDescription
sessionId *stringSession id from list_sessions.
includeCallsbooleanAlso return every classified call (default false; can be large — prefer list_tool_calls with filters).
providerstringLog 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.

ParameterTypeDescription
sessionId *stringSession id from list_sessions.
failureCategoryarrayKeep only these failure categories.
kindarrayKeep only these tool kinds, e.g. ["shell"] or ["web","mcp"].
limitintegerMaximum calls to return (default 50).
offsetintegerSkip this many matching calls (default 0).
originarrayKeep only calls by the main agent or by subagents, e.g. ["subagent"]. Default: both.
programstringShell program, e.g. "npm" or "git".
providerstringLog provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app.
runIdstringOnly calls made by this subagent run (its origin.runId).
statusarrayKeep only these outcomes, e.g. ["error","interrupted","denied"].
toolstringExact tool name, e.g. "Bash" or "run_in_terminal".
turnIndexintegerOnly 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;…

ParameterTypeDescription
limitintegerHow many of the most recent sessions to read per provider (default 50, max 500).
providerstringLog provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app.
sincestringEarliest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp.
untilstringLatest 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…

ParameterTypeDescription
sessionId *stringSession id from list_sessions.
providerstringLog provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app.
topTurnsintegerHow 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…

ParameterTypeDescription
limitintegerHow many of the most recent sessions to read per provider (default 50, max 500).
projectIdstringOnly turns in this project (from list_projects).
providerstringRestrict to one log provider id (see list_log_providers). Default: every available provider.
repositorystringOnly turns attributed to this repository key (from list_repositories).
sincestringEarliest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp.
topSessionsintegerHow many of the most expensive sessions to return (default 10).
untilstringLatest 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…

ParameterTypeDescription
repository *stringRepository key from list_repositories, e.g. github.com/org/app or local:<folder name>.
basisstringWhich cost basis the figures use: "preferred" (default: billed, else reported, else priced per turn), or only "billed", "reported" or "priced".
bucketstringBucket size: "day", "week" (ISO weeks) or "month" (default), in UTC.
currencystring"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.
limitintegerHow many of the most recent sessions to read per provider (default 50, max 500).
pricingstringHow 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).
providerstringRestrict to one log provider id (see list_log_providers). Default: every available provider.
sincestringFirst day, inclusive: "YYYY-MM-DD" (UTC). Sessions started earlier are not read.
untilstringLast 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…

ParameterTypeDescription
projectId *stringProject id from list_projects.
basisstringWhich cost basis the figures use: "preferred" (default: billed, else reported, else priced per turn), or only "billed", "reported" or "priced".
bucketstringBucket size: "day", "week" (ISO weeks) or "month" (default), in UTC.
currencystring"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.
limitintegerHow many of the most recent sessions to read per provider (default 50, max 500).
pricingstringHow 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).
providerstringRestrict to one log provider id (see list_log_providers). Default: every available provider.
sincestringFirst day, inclusive: "YYYY-MM-DD" (UTC). Sessions started earlier are not read.
topSessionsintegerHow many of the most expensive sessions to return (default 10, max 50).
untilstringLast 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…

ParameterTypeDescription
groupBy *stringCompare repositories or projects.
ids *arrayThe 2 to 20 repository keys (from list_repositories) or project ids (from list_projects) to compare.
since *stringFirst day of the period, inclusive: "YYYY-MM-DD" (UTC).
until *stringLast day of the period, inclusive: "YYYY-MM-DD" (UTC).
basisstringWhich cost basis the figures use: "preferred" (default: billed, else reported, else priced per turn), or only "billed", "reported" or "priced".
comparePeriodstringWhat the change is measured against: "previous" (default: the same number of days just before) or "last-year" (the same dates a year earlier).
currencystring"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.
limitintegerHow many of the most recent sessions to read per provider (default 50, max 500).
pricingstringHow 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).
providerstringRestrict 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…

ParameterTypeDescription
groupBy *stringExplain a repository's or a project's change.
id *stringThe 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).
currencystring"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.
limitintegerHow many of the most recent sessions to read per provider (default 50, max 500).
providerstringRestrict 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…

ParameterTypeDescription
categorystringExact category, case-insensitive, e.g. "credential-access" or "cost-outlier".
kindarrayKeep only these kinds, e.g. ["security"].
limitintegerHow many of the most recent sessions to read per provider (default 50, max 500).
maxResultsintegerMaximum findings to return (default 50); total and bySeverity count every match.
minSeveritystringKeep findings at or above this severity (info < low < medium < high < critical).
originarrayKeep only findings from the main agent or from subagents, e.g. ["subagent"]. Default: both.
providerstringRestrict to one log provider id (see list_log_providers). Default: every available provider.
sessionIdstringOnly findings in this session.
sincestringEarliest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp.
untilstringLatest 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…

ParameterTypeDescription
atstringOnly the versions in force at this time: "YYYY-MM-DD" (UTC midnight) or an ISO timestamp.
channelstringOnly this channel, e.g. "github-copilot".
modelstringOnly 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…

ParameterTypeDescription
channelstringOnly this channel, e.g. "github-copilot".
kindstring"documented" or "observed"; default both.
modelstringOnly this model: a price-table id for documented changes, the logged model for observed ones.
providerstringRestrict observed changes to one log provider id (see list_log_providers).
sincestringChanges from this day, inclusive: "YYYY-MM-DD" (UTC).
untilstringChanges 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…

ParameterTypeDescription
includeUnattributedbooleanInclude the Unattributed buckets with their reasons (default true).
projectIdstringOnly repositories with a member in this project (see list_projects).
providerstringLog provider id (see list_log_providers). Omit to read every available provider.
sincestringEarliest session start, inclusive: "YYYY-MM-DD" or an ISO timestamp.
untilstringLatest 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'…

ParameterTypeDescription
model *stringA 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 *stringSession id from list_sessions.
pricingstringWhich 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…
providerstringLog 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…

ParameterTypeDescription
models *array1 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 *stringSession id from list_sessions.
pricingstringWhich 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…
providerstringLog 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…

ParameterTypeDescription
includeSimulatedbooleanAlso run the cheaper-model replays and list them as Simulated (default false: a replay per session is slow).
limitintegerHow many opportunities to return, best first (default 10, max 20).
pricingstringHow priced figures are priced: "as-of-use" (default: the price in force when each turn ran) or "today".
providerstringLog provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app.
sincestringFirst day of the window, inclusive: "YYYY-MM-DD". Default: 30 days before until.
untilstringLast 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…

ParameterTypeDescription
activeDaysintegerPlanned active days (or give sessions).
historyWeeksHistory window in weeks: 4 or 12 (default).
modelstringEstimate 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.
projectIdstringThe project id, from list_projects (or give repository).
repositorystringA repository key, from list_repositories (or give projectId).
sessionsintegerPlanned 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…

ParameterTypeDescription
period *stringA month "YYYY-MM", or a range "YYYY-MM-DD..YYYY-MM-DD".
projectId *stringThe project id, from list_projects.
includeLinesbooleanInclude 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.

ParameterTypeDescription
sessionId *stringSession id from list_sessions.
maxTurnsintegerHow many turns to return, from the first (default 500, max 2000).
providerstringLog provider id, e.g. "claude-code", "vscode", "pi-agent", "mitmproxy" (see list_log_providers). Defaults to the provider active in the web app.