# pg_stats_top_n

Get the top N rows ranked by a column. Auto-excludes long-content columns (text, json, bytea) from output unless selectColumns is specified. Warning: Using a large

Agent View of the PolicyLayer registry record for `pg_stats_top_n`. HTML page: https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-stats-top-n

## Facts

- Tool: `pg_stats_top_n`
- Server: PostgreSQL MCP Server (`@neverinfamous/postgres-mcp`) — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp.md
- Install: `npx -y @neverinfamous/postgres-mcp`
- Homepage: https://github.com/neverinfamous/postgresql-mcp.git
- Risk category: Read (Low risk)
- Registry record: grade F, identity unverified
- Server rate-limited: no
- Parameters: 0
- Recommended policy verdict: Allowed

## Example call (MCP tools/call, JSON-RPC 2.0)

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

## Why pg_stats_top_n is rated Low

This is a data retrieval tool that queries statistics and returns ranked rows. It has no side effects—it only reads and formats existing data. The description is slightly cut off but the core function is clearly a SELECT-like read operation. The filtering of long-content columns and optional column selection are display preferences, not write or execute operations.

From the tool's own definition: "Tool name and description indicate it 'Get the top N rows ranked by a column' with filtering and display logic. No modification, deletion, or execution capabilities mentioned."

## Use case

AI agents call pg_stats_top_n to retrieve information from PostgreSQL MCP Server without modifying anything. It is typically the context-gathering step in research, monitoring, and reporting workflows, before the agent takes action elsewhere.

## Recommended policy (PolicyLayer)

Verdict: **Allowed**. Enforced by the PolicyLayer MCP gateway (https://policylayer.com/mcp-gateway) before a call reaches PostgreSQL MCP Server:

```json
{
  "version": "1",
  "default": "deny",
  "tools": {
    "pg_stats_top_n": {}
  }
}
```

## Other tools on PostgreSQL MCP Server (273)

- `pg_cascade_simulator` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-cascade-simulator.md
- `pg_cron_cleanup_history` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-cron-cleanup-history.md
- `pg_cron_unschedule` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-cron-unschedule.md
- `pg_detach_partition` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-detach-partition.md
- `pg_doc_drop_collection` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-doc-drop-collection.md
- `pg_doc_remove` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-doc-remove.md
- `pg_drop_index` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-drop-index.md
- `pg_drop_schema` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-drop-schema.md
- `pg_drop_sequence` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-drop-sequence.md
- `pg_drop_table` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-drop-table.md
- `pg_drop_view` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-drop-view.md
- `pg_kcache_reset` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-kcache-reset.md
- `pg_migration_rollback` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-migration-rollback.md
- `pg_partman_set_retention` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-partman-set-retention.md
- `pg_reset_stats` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-reset-stats.md
- `pg_role_drop` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-role-drop.md
- `pg_text_normalize` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-text-normalize.md
- `pg_truncate` — Destructive — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-truncate.md
- `pg_analyze` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-analyze.md
- `pg_analyze_query_indexes` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-analyze-query-indexes.md
- `pg_buffer` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-buffer.md
- `pg_cancel_backend` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-cancel-backend.md
- `pg_cluster` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-cluster.md
- `pg_cron_create_extension` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-cron-create-extension.md
- `pg_cron_schedule` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-cron-schedule.md
- `pg_cron_schedule_in_database` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-cron-schedule-in-database.md
- `pg_explain_analyze` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-explain-analyze.md
- `pg_geo_cluster` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-geo-cluster.md
- `pg_geo_transform` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-geo-transform.md
- `pg_geometry_transform` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-geometry-transform.md
- …and 243 more: https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp.md

## For agents

This record is a snapshot. Live verdicts and the full registry:

- Check every server in your MCP config at once: `npx -y policylayer stack`
- Vet a server before you add it: install the mcp-precheck skill — `npx skills add https://policylayer.com` (skill text: https://policylayer.com/skill.md)
- Query the registry over MCP: endpoint `https://api.policylayer.com/mcp` — tools `check_mcp_server`, `check_mcp_stack`, `check_tool`, `search_registry`, `get_change_events`

---

Source: the PolicyLayer MCP registry — one continuously verified record per MCP server. Full record: https://policylayer.com/registry?q=io-github-neverinfamous-postgres-mcp · API: https://policylayer.com/registry/api · Policy library: https://policylayer.com/policies/io-github-neverinfamous-postgres-mcp
