Skip to main content
Glama

analyze_session_usage

Analyze one specific session's actual recorded LLM usage (tagged via record_usage's session_id) on demand: total input/output tokens, total actual cost, and a per-model breakdown if more than one model was used. Also runs the session's own observed token pattern through the same routing engine behind recommend_model / POST /router/recommend to produce a grounded recommendation — or confirm the current choice is already optimal — with the estimated dollar savings or increase versus this session's actual cost. Returns has_data: false with no recommendation if the session_id has no recorded usage. Advisory only — never switches or reroutes anything. 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.

Input Schema

NameRequiredDescriptionDefault
org_idNoOptional organisation ID filter — scopes the lookup to usage events recorded under that org_id. Defaults to, and must match, the org of the service key on the MCP connection
session_idYesThe session_id previously used when calling record_usage

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / org_id / description
      Previous value: -"Optional organisation ID filter — scopes the lookup to usage events recorded under that org_id, same as get_usage_summary's org_id"New value: +"Optional organisation ID filter — scopes the lookup to usage events recorded under that org_id. Defaults to, and must match, the org of the service key on the MCP connection"
  2. First observed

TDQS

A4.4/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: it declares the tool advisory-only and that it 'never switches or reroutes anything', spells out authentication requirements (x-api-key or Bearer on the MCP connection) and the org_id matching constraint. It also discloses the empty-result behavior and how the recommendation is derived (same engine as POST /router/recommend).

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?

A single dense paragraph that is front-loaded with the core purpose and output shape, followed by the recommendation mechanics and then the safety/auth caveats. Every clause adds information, though the length pushes the auth and advisory notes far from the opening.

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?

There is no output schema, so the description must describe returns — and it does precisely: token totals, actual cost, per-model breakdown conditional on multiple models, recommendation with dollar delta, and has_data: false. Auth prerequisites and the advisory-only guarantee round out what an agent needs to call 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 both parameters are already documented in the schema, and the description largely restates those same semantics (session_id from record_usage, org_id defaulting to and matching the key's org). Baseline 3 applies since the schema does the heavy lifting.

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 — analyze one session's recorded LLM usage — and enumerates the concrete outputs (input/output tokens, actual cost, per-model breakdown, routing recommendation with estimated savings). It distinguishes itself from siblings by tying session_id to record_usage and naming the shared routing engine behind recommend_model.

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?

Usage context is clear: use it 'on demand' for a single session that was tagged via record_usage's session_id, and it produces either a recommendation or a confirmation the current choice is optimal. It also states the negative case (has_data: false when no usage recorded), but never explicitly says when to prefer recommend_model or get_usage_summary instead.

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.