Skip to main content
Glama

log_cost

Record token usage and cost per task after each AI interaction to track spending and enable budget monitoring.

Instructions

Log token usage and cost for a task. Call this after each AI interaction.

Args: model: Model name (e.g., 'claude-sonnet-4-6', 'gpt-5.4') tokens_in: Number of input tokens tokens_out: Number of output tokens task: Description of what the task was

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelYes
tokens_inYes
tokens_outYes
taskNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

No annotations are provided, so the description carries the full burden. It conveys that the tool logs data without side effects like modifying state or triggering other actions. Could add that it is a record-only operation, but current description is sufficient.

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?

Description is extremely concise: two sentences for purpose and context, then a clean Args list. Every sentence adds value, no fluff, and front-loaded with the main action.

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?

For a simple logging tool with 4 parameters, the description covers the what, when, and how. Sibling tools provide context for when to use this vs others. An output schema exists but description doesn't need to detail return values.

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

Parameters5/5

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

Schema description coverage is 0%, but the description compensates fully by defining each parameter (model with examples, tokens_in/tokens_out as input/output tokens, task as description). This adds meaning beyond the schema's type definitions.

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?

Description clearly states it logs token usage and cost for a task, specifying to call after each AI interaction. It distinguishes from sibling tools like cost_report (for reports) and estimate_cost (for estimation) by focusing on per-interaction logging.

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?

Explicitly says 'Call this after each AI interaction.' This provides clear when-to-use context. While not listing exclusions, the sibling tools offer natural alternatives for other needs, making usage clear.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vanthienha199/agent-cost-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server