Skip to main content
Glama
foxter-io

PostgreSQL MCP Server

by foxter-io

Cancel or Terminate a PostgreSQL Backend

pg_kill_query
Destructive

Cancel or terminate PostgreSQL backend processes by PID. Use cancel mode to stop a query without disconnecting, or terminate to forcefully kill the connection.

Instructions

Cancel or terminate a PostgreSQL backend process by PID.

Two modes:

  • cancel (safe): Sends SIGINT — cancels the current query but leaves the connection alive. The client can reconnect and retry.

  • terminate (forceful): Sends SIGTERM — kills the connection entirely. Use when cancel doesn't work.

Args:

  • pid: Process ID of the backend to cancel/terminate (from pg_active_queries or pg_list_locks)

  • mode: 'cancel' to cancel current query, 'terminate' to kill connection (default: cancel)

Returns: Whether the signal was successfully sent.

Note: You cannot cancel/terminate your own backend or superuser backends without superuser privileges.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYesBackend PID to cancel or terminate
modeNo'cancel' = cancel query, 'terminate' = kill connectioncancel
Behavior5/5

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

Annotations already mark destructiveHint=true, but the description elaborates: cancel sends SIGINT (safe, connection stays), terminate sends SIGTERM (forceful, connection killed). Also states it cannot kill own backend or superuser without privileges. No contradiction 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.

Conciseness5/5

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

Highly concise: one sentence for purpose, then clear sections for modes, args, returns, and note. Every sentence adds essential information with no redundancy.

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?

Despite no output schema, the description covers return value ('Whether the signal was successfully sent'), edge cases (own backend, superuser), and sources for the PID. This is comprehensive for a straightforward kill tool.

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?

Schema coverage is 100%, but the description adds value by specifying that pid comes from pgs_active_queries or pg_list_locks, and explaining the two mode values with their default. This goes beyond the schema's basic descriptions.

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 title and first sentence clearly state that the tool cancels or terminates a PostgreSQL backend by PID. It distinguishes two modes (cancel vs terminate) and explains their effects. No sibling tool does this, so purpose is unambiguous.

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

Usage Guidelines5/5

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

Explicitly describes when to use cancel (safe, leaves connection alive) vs terminate (when cancel doesn't work). Notes that PID comes from sibling tools (pg_active_queries, pg_list_locks) and warns about privilege limitations. This gives agents clear decision criteria.

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/foxter-io/mcp-postgresql'

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