Skip to main content
Glama
call518

MCP PostgreSQL Operations

by call518

get_lock_monitoring

Monitor PostgreSQL locks and deadlocks to diagnose lock contention, identify blocked and blocking sessions, and filter results by status, mode, type, state, or user.

Instructions

[Tool Purpose]: Monitor current locks and potential deadlocks in PostgreSQL

[Exact Functionality]:

  • List all current locks held and waited for by sessions

  • Show blocked and blocking sessions, lock types, and wait status

  • Help diagnose lock contention and deadlock risk

  • Filter results by granted status, state, mode, lock type, or username

[Required Use Cases]:

  • When user requests "lock monitoring", "deadlock check", "blocked sessions", etc.

  • When diagnosing performance issues due to locking

  • When checking for blocked or waiting queries

  • When filtering specific types of locks or users

[Strictly Prohibited Use Cases]:

  • Requests for killing sessions or force-unlocking

  • Requests for lock configuration changes

  • Requests for historical lock data (only current state is shown)

Input Schema

NameRequiredDescriptionDefault
modeNoFilter by lock mode ("AccessShareLock", "ExclusiveLock", etc.)
stateNoFilter by session state ("active", "idle", "idle in transaction", etc.)
grantedNoFilter by granted status ("true" or "false")
locktypeNoFilter by lock type ("relation", "transactionid", "virtualxid", etc.)
usernameNoFilter by specific username
database_nameNoDatabase name to analyze (uses default database if omitted)

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changedv3.4.3
    • addedInput schema / properties / database_name / description
      Added value: +"Database name to analyze (uses default database if omitted)"
    • addedInput schema / properties / granted / description
      Added value: +"Filter by granted status (\"true\" or \"false\")"
    • addedInput schema / properties / locktype / description
      Added value: +"Filter by lock type (\"relation\", \"transactionid\", \"virtualxid\", etc.)"
    • addedInput schema / properties / mode / description
      Added value: +"Filter by lock mode (\"AccessShareLock\", \"ExclusiveLock\", etc.)"
    • addedInput schema / properties / state / description
      Added value: +"Filter by session state (\"active\", \"idle\", \"idle in transaction\", etc.)"
    • addedInput schema / properties / username / description
      Added value: +"Filter by specific username"
  2. Changed21 schema fields changedv3.4.2
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / database_name / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedInput schema / properties / database_name / title
      Removed value: -"Database Name"
    • removedInput schema / properties / database_name / type
      Removed value: -"string"
    • addedInput schema / properties / granted / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedInput schema / properties / granted / title
      Removed value: -"Granted"
    • removedInput schema / properties / granted / type
      Removed value: -"string"
    • addedInput schema / properties / locktype / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedInput schema / properties / locktype / title
      Removed value: -"Locktype"
    • removedInput schema / properties / locktype / type
      Removed value: -"string"
    • addedInput schema / properties / mode / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedInput schema / properties / mode / title
      Removed value: -"Mode"
    • removedInput schema / properties / mode / type
      Removed value: -"string"
    • addedInput schema / properties / state / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedInput schema / properties / state / title
      Removed value: -"State"
    • removedInput schema / properties / state / type
      Removed value: -"string"
    • addedInput schema / properties / username / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedInput schema / properties / username / title
      Removed value: -"Username"
    • removedInput schema / properties / username / type
      Removed value: -"string"
    • removedOutput schema / properties / result / title
      Removed value: -"Result"
    • removedOutput schema / title
      Removed value: -"_WrappedResult"
  3. Addedv1.0.0

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it makes clear this is a read-only listing of current state (explicitly not historical), and that it cannot kill sessions or alter configuration. It does not mention required privileges or the cost of scanning pg_locks on a busy server, which would matter for a diagnostic query.

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?

The bracketed sections front-load purpose, functionality, and use cases, which is easy to scan. It is somewhat verbose and the 'Required Use Cases' bullets partially repeat the 'Exact Functionality' bullets, but no section is pure filler.

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 six-parameter, read-only diagnostic tool with full schema coverage and an output schema, the description covers purpose, exclusions, and result scope (current state only). The only meaningful omissions are permission requirements and any caveat about how the filters combine.

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?

Schema description coverage is 100%, so each filter is already documented with examples in the schema; baseline 3 applies. The description's filter list ('granted status, state, mode, lock type, or username') largely restates the schema and even omits the database_name parameter, adding no syntax or interaction guidance.

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 states a specific verb and resource ('Monitor current locks and potential deadlocks in PostgreSQL') and then enumerates exactly what is returned: held/waited locks, blocked and blocking sessions, lock types, wait status. This clearly separates it from siblings like get_wait_events or get_active_connections, which do not report lock-level contention.

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?

It gives explicit required use cases (lock monitoring, deadlock check, blocked sessions, lock-contention performance diagnosis) and an explicit 'Strictly Prohibited' list (killing sessions, changing config, historical data). An agent knows both when to pick this tool and when to look elsewhere.

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