Skip to main content
Glama

Get agent model usage

get_agent_usage
Read-onlyIdempotent

Fetch per-model token and cost usage for an agent or project across 24h, 7d or 30d windows, including cache reads, cache writes and cost source.

Instructions

Requires the read scope or higher. Model usage, one row per model per UTC day: tokens_in (cache reads included, so tokens_cache_read is not added to it), tokens_out, tokens_cache_read, tokens_cache_write, cost_usd (decimal text) and cost_source: client (the tool reported its cost), estimated (LastPing priced tokens at API list prices), mixed (a traced day holds both) or empty (unknown). origin is traces or metrics; a day and model can have one of each, never summed. With id, one agent's usage; without, the project's, traces only, plus by_agent (costliest first). Both carry by_project: per project (a Claude Code session's folder) its runs, tokens and cost from traced runs only (project_scope traces_only). by_project sums each run's traced totals, while one agent's days prefer a Claude Code metrics export's reported cost, so the two need not match. With project, days become one row per UTC day with model and provider empty; project narrows days and by_project, not by_agent. untrusted_fields names the data fields LastPing did not write (job output, exporter data or user-supplied names).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNoAgent UUID or slug (from list_agents). Omitted: every agent in the project.
rangeNoTime window: 24h, 7d (the default) or 30d. It covers every UTC day that overlaps it, so 24h spans two days.
projectNoOnly usage from traced runs of this project; metrics-only usage has no project and is left out. days then hold one row per UTC day with model and provider empty (a run's totals are not split by model); by_agent is not narrowed.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.1.17
    • changedInput schema / properties / id / description
      Previous value: -"Agent UUID or slug (from list_agents). Omit for every agent in the project."New value: +"Agent UUID or slug (from list_agents). Omitted: every agent in the project."
  2. Changed1 schema field changedv0.1.9
    • addedInput schema / properties / project
      Added value: +{
      +  "description": "Only usage from traced runs of this project; metrics-only usage has no project and is left out. days then hold one row per UTC day with model and provider empty (a run's totals are not split by model); by_agent is not narrowed.",
      +  "type": "string"
      +}
  3. Addedv0.1.6

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only cover the read-only/idempotent safety profile, yet the description adds substantial non-obvious behavior: cost_source enumeration, origin traces/metrics being never summed, the by_project vs. per-agent cost mismatch, project_scope traces_only, and the meaning of untrusted_fields.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The permission requirement is front-loaded, but the remainder is a single semicolon-chained wall of text that is hard to parse. Every clause carries information, yet the lack of segmentation hurts scanability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description fully carries the burden of explaining the return shape: the field list, cost_source values, origin semantics, by_agent/by_project structure, and untrusted_fields. Nothing essential for correct interpretation is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description goes further by explaining interactions the schema omits: project narrows days and by_project but not by_agent, and id scopes to one agent's usage (traces only) versus the project's.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource with its granularity: 'Model usage, one row per model per UTC day', then enumerates the exact returned columns. An agent can tell this apart from get_agent or list_agents immediately.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives the precondition ('Requires the read scope or higher') and the branching behavior of id vs. no id, plus the project scoping rule. It does not explicitly name a sibling alternative, but the conditional scoping guidance is unusually clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.