Skip to main content
Glama
LuciferForge

agent-safety-mcp

by LuciferForge

cost_guard_record

Track and record token usage and costs for completed LLM calls to monitor API expenses and maintain budget control.

Instructions

Record a completed LLM call's token usage and cost.

Args: model: Model identifier used for the call. input_tokens: Actual input tokens consumed. output_tokens: Actual output tokens consumed. purpose: Optional label for this call (e.g. "summarizer", "classifier").

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelYes
input_tokensYes
output_tokensYes
purposeNo

Implementation Reference

  • The cost_guard_record tool implementation, which utilizes the CostGuard instance to record token usage and return the calculated cost and total spent.
    def cost_guard_record(
        model: str,
        input_tokens: int,
        output_tokens: int,
        purpose: str = "",
    ) -> dict:
        """Record a completed LLM call's token usage and cost.
    
        Args:
            model: Model identifier used for the call.
            input_tokens: Actual input tokens consumed.
            output_tokens: Actual output tokens consumed.
            purpose: Optional label for this call (e.g. "summarizer", "classifier").
        """
        guard = _get_guard()
        cost = guard.record(model, input_tokens, output_tokens, purpose=purpose)
        return {
            "recorded": True,
            "model": model,
            "cost_usd": round(cost, 6),
            "total_spent_usd": round(guard.status().get("spent_usd", 0), 6),
        }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It establishes this is a post-call write operation ('record'), but omits details about persistence guarantees, idempotency, error behavior, or return values (no output schema exists to supplement this).

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?

The description is well-structured with the core purpose front-loaded in the first sentence, followed by a clean Args section. Every sentence provides value with no redundancy or waste.

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

Completeness4/5

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

For a simple 4-parameter recording tool with basic types, the description adequately covers inputs and operation context. A minor gap exists regarding return behavior or success confirmation, though the absence of an output schema suggests a simple acknowledgement return.

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?

Given 0% schema description coverage, the Args section fully compensates by documenting all 4 parameters: 'model' (identifier), 'input_tokens'/'output_tokens' (actual consumed counts), and 'purpose' (optional label with examples), adding necessary semantics missing from the schema.

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?

The description clearly states the specific action ('Record') and target ('completed LLM call's token usage and cost'), distinguishing it from siblings like cost_guard_check, cost_guard_configure, and cost_guard_status through the distinct 'record' verb.

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?

The description implies timing by specifying 'completed LLM call,' suggesting post-call usage, but lacks explicit guidance on when to use this versus alternatives like cost_guard_check (likely for pre-call estimation) or cost_guard_status.

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/LuciferForge/agent-safety-mcp'

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