# pg_cancel_backend

Cancel a running query (graceful, preferred over terminate).

Agent View of the PolicyLayer registry record for `pg_cancel_backend`. HTML page: https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-cancel-backend

## Facts

- Tool: `pg_cancel_backend`
- 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: Execute (High risk)
- Registry record: grade F, identity unverified
- Server rate-limited: no
- Parameters: 0
- Recommended policy verdict: Rate-limited

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

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

## Why pg_cancel_backend is rated High

This tool sends a cancellation signal to a running backend/query process. It triggers an external operation (interrupting a database process) that can affect running transactions and ongoing work. While it's described as 'graceful', it still forcibly stops another process's execution, which can cause partial work to be rolled back and disrupt other users or operations.

From the tool's own definition: "Cancel a running query (graceful, preferred over terminate)"

## Use case

AI agents invoke pg_cancel_backend to trigger actions in PostgreSQL MCP Server. What it does depends on the arguments the agent supplies, and its effects often reach beyond the immediate call: builds kicked off, notifications sent, workflows started.

## Recommended policy (PolicyLayer)

Verdict: **Rate-limited**. 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_cancel_backend": {
      "limits": [
        {
          "counter": "pg_cancel_backend_rate",
          "window": "minute",
          "max": 10,
          "scope": "grant"
        }
      ]
    }
  }
}
```

## 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_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
- `pg_jsonb_array` — Execute — https://policylayer.com/tools/io-github-neverinfamous-postgres-mcp/pg-jsonb-array.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
