Skip to main content
Glama

Record LLM usage

record_usage

Record token usage for one LLM call against a session and get the call's cost in US dollars, so per-call spend can be priced and tracked in a persistent cost ledger.

Instructions

Record token usage of one LLM call against a session. Returns the cost of this call in US dollars.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "session_id": "<session_id>",
      "model": "<model>",
      "input_tokens": "<input_tokens>",
      "output_tokens": "<output_tokens>"
    },
    "name": "record_usage"
  }
}

Input Schema

NameRequiredDescriptionDefault
labelNoOptional tag, for example 'report' or 'chat-turn'
modelYesModel name as listed by list_models
session_idYesYour session or customer-run identifier
input_tokensYesUncached input tokens
output_tokensYesOutput tokens
cache_read_tokensNoTokens read from prompt cache
cache_write_tokensNoTokens written to prompt cache

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It usefully discloses the return value (cost in USD), which compensates for the missing output schema, but it does not state whether recording is idempotent, whether repeated calls double-count, what happens with an unknown model, or any auth/rate-limit behavior for what is clearly a mutation.

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

Conciseness5/5

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

Two sentences with zero filler: the action is front-loaded, followed immediately by the return value. Nothing is repeated and nothing needs trimming.

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

Completeness3/5

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

For a seven-parameter mutation with no annotations, the description covers the core action and its return value, and the schema fills in parameter detail. It falls short on side-effect semantics (idempotency, duplicate handling) and on how the tool relates to the reporting siblings, which an agent needs to use it correctly.

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

Parameters3/5

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

Schema description coverage is 100%, so all seven parameters (including cache_read_tokens and cache_write_tokens defaults) are documented in the schema. The description only restates that tokens and a session are involved and adds no syntax, format, or edge-case meaning beyond the schema; baseline 3 is appropriate.

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

Purpose4/5

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

The description names a specific verb and resource — 'Record token usage of one LLM call against a session' — and adds the result ('Returns the cost of this call in US dollars'). The write-oriented verb 'record' contrasts implicitly with the sibling read tools (cost_report, session_cost), though no sibling is named explicitly.

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

Usage Guidelines3/5

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

Usage is implied by 'one LLM call' (call this after each completion), but there is no explicit when-to-use statement, no guidance on how this differs from cost_report or session_cost, and no prerequisites (e.g., whether the session must already exist).

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

Deploy Server

Other Tools