checkKey

Check if a row exists by primary key; validates value types against the PK column types before querying.

read-onlyany connectionsweeps instancesweeps group

Synopsis

checkKey(schema, table, values)

Description

Check if a row exists by primary key; validates value types against the PK column types before querying.

Parameters

schema requiredstring
table requiredstring
values requiredarray

Also accepts connection, instance, group, described once under arguments every tool takes.

Output

Whether a row with the given key exists. An absent extension or a missing grant is reported as {error, hint} instead.

FieldType
existsboolean | null

Scope

A physical replica is byte-identical here, so asking each member of a replication group adds nothing.

Example mocked data

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "checkKey",
    "arguments": {
      "schema": "shop",
      "table": "orders",
      "values": [
        482211
      ]
    }
  }
}

Result

{
  "exists": true
}

Invented values on a fictional shop database, shaped by and checked against this tool's output schema. Real output is returned as structuredContent to clients that negotiate MCP 2025-06-18 or later.

See also

evaluateIndex, duplicateIndexes, tableBloat, indexBloat, explainQuery