Skip to main content
Glama

Security audit

pg_security_audit
Read-onlyIdempotent

Audit PostgreSQL security weaknesses, rank findings as critical, warning, or info with recommendations, and check roles, privileges, authentication, RLS, and risky extensions without changing data.

Instructions

Audit the database for security weaknesses and rank the findings as critical, warning or info, each with a recommendation.

It checks superusers and powerful role attributes (CREATEROLE, REPLICATION, BYPASSRLS), md5 password hashes, PUBLIC privileges and a PUBLIC-writable schema, SECURITY DEFINER functions without a fixed search_path, row level security gaps, pg_hba rules with trust or cleartext passwords, ssl, untrusted languages, risky extensions, file and program access roles, foreign servers and event triggers. Each check runs on its own: one that the server or the role cannot do becomes a note and the rest still run. Nothing is changed and no secret is read.

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": "pg_security_audit"
  }
}

Input Schema

NameRequiredDescriptionDefault
connectionNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.9/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, destructiveHint=false and a closed world, but the description adds genuine value beyond them: it states nothing is changed, no secret is read, and that each check is isolated so an unauthorized or unsupported check degrades to a note instead of failing the run. It does not mention expected runtime, required privilege level, or whether findings are persisted.

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?

Purpose is front-loaded, the check list is grouped into one dense sentence, and the behavioral guarantees close the description. The check enumeration is long but each item earns its place by telling the agent exactly what will be inspected; only minor tightening is possible.

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?

With no output schema, the description carries the return-value burden and does so adequately by describing severity-ranked findings each with a recommendation. Combined with the no-mutation/no-secret guarantees, an agent has enough to call it correctly; only the connection parameter and performance characteristics are left unexplained.

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?

There is a single optional 'connection' parameter with 0% schema description coverage, and the description gives it no mention at all. The name plus a null default makes the current-connection fallback inferable, keeping this at a minimum-viable 3 rather than lower, but the description fully defers on the only parameter it has.

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 first sentence states a specific verb and object ('Audit the database for security weaknesses') plus the output shape (findings ranked critical/warning/info with recommendations). The enumeration of concrete checks (superusers, md5 hashes, pg_hba trust rules, SECURITY DEFINER search_path, RLS gaps) makes it clearly distinguishable from siblings like pg_health_check or pg_privileges.

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

Usage Guidelines3/5

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

Usage is implied by the scope of the audit rather than stated: an agent can infer this is the broad security sweep, but nothing says when to prefer it over pg_privileges, pg_policy, or pg_health_check, and there are no exclusions or prerequisites. It also doesn't say how often or in what situation to run it.

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