Skip to main content
Glama

cancel_query

Cancel a running PostgreSQL query by its backend PID to halt resource-intensive operations. Preview with dry-run before applying.

Instructions

[WRITE][risk=high] Cancel a backend's running query (pg_cancel_backend). No inverse.

Captures the backend's pid + query for audit; a cancel has no undo. Pass
dry_run=True to preview.

Refuses this tool's own backend pid — the query it would cancel is this very
call. Enforced under dry_run too.

Args:
    pid: Backend process id (from list_activity).
    dry_run: If True, preview without cancelling.
    target: Target name from config; omit for the default.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYes
targetNo
dry_runNo
Behavior5/5

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

With no annotations, the description fully discloses high risk, audit logging, no undo, and self-prevention. It transparently states the operation is destructive and irreversible.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with risk tags, and each sentence provides critical information. No redundancy; compact yet thorough.

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?

For a high-risk mutation tool with no output schema, it covers purpose, parameters, and side effects. It lacks return value details but that is acceptable for a cancellation action.

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 schema has 0% description coverage, but the description details each parameter: pid from list_activity, dry_run for preview, target from config. It adds necessary context beyond the schema's titles.

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 the tool cancels a running query via pg_cancel_backend. It distinguishes itself from siblings like terminate_backend and reset_query_stats by focusing on the query itself and noting the no-inverse property.

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?

It explains when to use (cancel a query) and when not (refuses its own backend pid). It advises using dry_run for preview. However, it does not explicitly contrast with alternatives like terminate_backend.

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/AIops-tools/Postgres-AIops'

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