Analyze session cost
analyze_session_costDetect costly session patterns from audit logs: flag hot repeated tool calls, redundant listings, and idle sessions, providing caching or schema consolidation suggestions.
Instructions
Surface hot-path inefficiencies from the audit log. Reads mcpg_audit.events over the last lookback_minutes (default 60, capped at 1440) and flags tools called more than hot_threshold times (default 10). Catalogue-listing tools (list_tables / list_schemas / list_indexes / etc.) get a redundant_listing finding pointing at get_compact_schema; other tools get a hot_repeated_call finding suggesting caching. Idle sessions get an idle_session finding. When mcpg_audit.events doesn't exist (audit subsystem off) returns audit_table_present=False with a diagnostic. Returns an object with audit_table_present (bool), events_examined (int), lookback_minutes, findings (list of objects with reason, tool, call_count, suggestion), and detail.
Example: analyze_session_cost(lookback_minutes=30, hot_threshold=15)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. | |
| hot_threshold | No | ||
| lookback_minutes | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| detail | No | ||
| findings | Yes | ||
| events_examined | Yes | ||
| lookback_minutes | Yes | ||
| audit_table_present | Yes |