Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

Analyze session cost

analyze_session_cost
Read-only

Detect 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

TableJSON Schema
NameRequiredDescriptionDefault
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.
hot_thresholdNo
lookback_minutesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
detailNo
findingsYes
events_examinedYes
lookback_minutesYes
audit_table_presentYes
Behavior5/5

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

Beyond the annotations (readOnlyHint=true), the description adds rich behavioral details: it reads `mcpg_audit.events`, flags tools exceeding a threshold, handles idle sessions, handles the case where the audit table doesn't exist, and explains different findings for catalogue-listing vs. other tools. No contradictions with annotations.

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?

The description is front-loaded with the main purpose in the first sentence. It is detailed but efficient, covering key behaviors without unnecessary wordiness. The example at the end helps clarity. Could be slightly more structured but overall concise for the complexity.

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?

Given that there is an output schema (not shown but indicated), the description already covers all necessary context: the input parameters, the source table, behavioral edge cases (missing table, idle sessions, category-specific findings), and the structure of the return object. It is very complete for an agent to use effectively.

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?

The description adds meaning beyond the input schema: it explains the default and cap for `lookback_minutes`, the default for `hot_threshold`, and that `database` is optional for targeting a secondary read-only database (referencing `list_databases`). Given 33% schema coverage, this compensates well.

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 'Surface hot-path inefficiencies from the audit log' and specifies reading from `mcpg_audit.events`. It distinguishes from sibling analyze tools by focusing on session cost based on audit log data, which is unique among the many analyze_* tools listed.

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?

The description provides clear context for when to use the tool (to find hot-path inefficiencies), includes default values and constraints (capped at 1440 minutes), and gives an example. However, it does not explicitly state when not to use this tool or mention alternatives among sibling tools, leaving some room for ambiguity.

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/devopam/MCPg'

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