Skip to main content
Glama

import_session_usage

Bulk-import a completed session's usage in a single call — the retroactive counterpart to record_usage, for when a session wasn't instrumented live. Use when a calling agent (e.g. VS Code Copilot Chat) already has a session's turn-by-turn history in its own local store and wants this server to report on it exactly as if it had been tracked live. Accepts a list of entries under one shared session_id; each entry resolves its input and output tokens independently, either from exact counts when known or by estimating from raw turn text using this server's existing token counter. Cost is always computed server-side from current pricing, never trusted from the caller. A malformed entry (no usable tokens/text on one side, or an unresolvable model_name) is reported as its own per-entry failure and does not fail the rest of the batch. Idempotent like record_usage — resubmitting the same entries (same request_id, or the same session_id/model/occurred_at/token-or-text when request_id is omitted) is a no-op. Recorded usage is then readable via analyze_session_usage and GET /usage/session/{session_id}. Requires your service API key on the MCP connection (x-api-key or Authorization: Bearer); org_id defaults to, and must match, that key's org. POST /mcp request bodies are capped at 1,000,000 bytes (413 above that). 500 exact-count entries fit comfortably (~150 KB); text-mode imports of long sessions can exceed it, so split the entries across several calls under the same session_id — imports are idempotent, so overlapping or retried batches are safe.

Input Schema

NameRequiredDescriptionDefault
org_idNoOptional organisation ID to attribute this usage to. Defaults to, and must match, the org of the service key on the MCP connection
entriesYesUsage entries to import, one per turn/call in the session
session_idYesShared session ID to tag every entry in this batch with

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / org_id / description
      Previous value: -"Optional organisation ID to attribute this usage to"New value: +"Optional organisation ID to attribute this usage to. Defaults to, and must match, the org of the service key on the MCP connection"
  2. First observed

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so: server-side cost computation never trusted from the caller, per-entry failure isolation that does not fail the batch, and precise idempotency semantics including the derived key when request_id is omitted. It also discloses auth requirements (x-api-key or Bearer, org_id must match key's org) and the 1,000,000-byte body cap with 413 behavior plus a splitting workaround — behavioral facts an agent cannot infer from the schema.

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

Conciseness4/5

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

Front-loaded with purpose and counterpart relationship, and every sentence carries a distinct fact. It is, however, one dense wall of prose running to dozens of clauses, and the size-cap guidance at the end reads as a second paragraph crammed into the first.

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 mutation tool with no annotations and no output schema, everything an agent needs is present: auth, org scoping, per-entry error behavior, idempotency, payload limits with a batching strategy, and where the imported data becomes visible afterward. Nothing material is left to inference.

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 the baseline is 3; the description earns a bump by explaining the interaction between fields — one shared session_id across entries, and each entry resolving input/output tokens independently from exact counts or by estimation from raw text. It also clarifies that the idempotency key is derived from session_id/model/occurred_at/token-or-text, though this partially restates 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?

States a specific verb and resource ("Bulk-import a completed session's usage") and immediately positions itself relative to a sibling ("the retroactive counterpart to record_usage"). An agent can distinguish it from record_usage and analyze_session_usage without opening any schema.

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

Usage Guidelines5/5

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

Gives an explicit when: a session wasn't instrumented live, and the caller already holds turn-by-turn history locally (e.g. VS Code Copilot Chat). It also names the alternative (record_usage) and the downstream read path (analyze_session_usage, GET /usage/session/{id}), so both the trigger and the follow-on are unambiguous.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.