Skip to main content
Glama

get_session_analytics

Read-onlyIdempotent

Analyze AI agent session logs to break down token usage, prompt-cache hit rates, costs by tool/server, top files, and models used; returns read-only JSON metrics.

Instructions

Analyze AI agent session logs: token usage, prompt-cache hit rate (blended and split by provider/model), cost breakdown by tool/server, top files, models used. Parses Claude Code JSONL logs automatically. Read-only. For waste detection use get_optimization_report; for cost trends use get_usage_trends. Returns JSON: { sessionsCount, totals, cacheHitRate: { blended, byModel, byProvider }, byToolServer, topTools, topFiles, modelsUsed }.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "get_session_analytics"
  }
}

Input Schema

NameRequiredDescriptionDefault
periodNoTime period (default: week)
session_idNoSpecific session ID to analyze

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv3.22.0
    • removedInput schema / required
      Removed value: -[
      -  "session_id"
      -]
  2. Changed1 schema field changedv3.3.0
    • removedInput schema / $schema
      Removed value: -"http://json-schema.org/draft-07/schema#"
  3. Addedv1.41.0
  4. Removedv1.38.0
  5. Changed2 schema fields changedv1.35.1
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / required
      Added value: +[
      +  "session_id"
      +]
  6. First observedv0.1.0

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already declare readOnlyHint/idempotentHint/openWorldHint=false, so safety is covered. The description adds value beyond them by disclosing the data source (Claude Code JSONL logs, parsed automatically) and the exact return shape, which is the main behavioral unknown for this tool. 'Read-only' merely restates the annotation.

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 the purpose, then alternatives, then return shape — a sensible order with dense, information-bearing sentences. Minor waste in 'Read-only' (redundant with annotations) and the long inline return-field list, though the latter compensates for the missing output schema.

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?

No output schema exists, and the description compensates by enumerating the returned fields (sessionsCount, totals, cacheHitRate split by model/provider, byToolServer, topFiles, modelsUsed). With parameters fully covered by schema and safety covered by annotations, only edge cases (empty periods, invalid session_id behavior) are left unaddressed.

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 coverage is 100% with only two parameters (period enum with default, session_id), so the schema carries the semantics. The description adds nothing about period defaulting or the interaction between period and session_id, leaving baseline 3 appropriate.

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?

Specific verb+resource: 'Analyze AI agent session logs' followed by an explicit enumeration of what is measured (token usage, cache hit rate, cost by tool/server, top files, models). It also names the data source ('Parses Claude Code JSONL logs automatically'), so an agent knows this is a log-parsing analytics tool rather than a generic stats reader, distinguishing it from get_session_stats.

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?

Explicit routing: 'For waste detection use get_optimization_report; for cost trends use get_usage_trends' gives two when-to-use-an-alternative rules. It does not address the remaining overlaps with get_session_stats, get_coverage_report, or mine_sessions, so the disambiguation is clear but not exhaustive.

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