Skip to main content
Glama
MCPg - Production-grade PostgreSQL MCP Server

MCPg - Production-grade PostgreSQL MCP Server

Vector search

vector_search
Read-only

Find the rows nearest to a query vector by pgvector distance (L2, cosine, or inner product), and report when the pgvector extension is unavailable.

Instructions

Find the rows nearest to a query vector by pgvector distance (metric: l2, cosine, or inner_product). Reports available=false if the pgvector extension is not installed.

Example: vector_search(schema='public', table='docs', column='embedding', query_vector=[0.1, 0.2, ...], metric='cosine', limit=10)

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "schema": "<schema>",
      "table": "<table>",
      "column": "<column>",
      "query_vector": "<query_vector>"
    },
    "name": "vector_search"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNo
tableYes
columnYes
metricNol2
schemaYes
databaseNoOptional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected.
query_vectorYes

Output Schema

NameRequiredDescriptionDefault
matchesYes
availableYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.8.4
    • changedInput schema / properties / database / description
      Previous value: -"Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids."New value: +"Optional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected."
  2. First observedv0.6.8

TDQS

A3.6/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, so the safety profile is covered. The description still adds real behavioral value by enumerating the three supported metrics and, importantly, disclosing the failure mode that the tool reports available=false when the pgvector extension is absent. It does not say anything about ordering guarantees, pagination, or how large result sets behave.

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?

Two sentences plus one worked example, with the core capability front-loaded and no filler. The example earns its place by showing the full argument set, though it is slightly verbose for what it demonstrates.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return values need no explanation. Still, for a 7-parameter tool with 14% schema coverage, the description leaves dimensions-matching, limit behavior, and metric-index alignment unaddressed, which an agent would need to call this correctly on an unfamiliar table.

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 only 14% — only the 'database' parameter is documented in the schema. The description partially compensates by listing the legal metric values (l2, cosine, inner_product), which the schema leaves as a bare string with no enum. It says nothing about limit semantics, default ordering, or the requirement that query_vector dimensionality match the target column.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb and resource ('find the rows nearest to a query vector') and scopes it to pgvector distance metrics. It is clear what the tool does, but it does not differentiate itself from the many sibling search tools (vector_range_search, mmr_search, hybrid_search, fuzzy_search), so an agent must infer the boundary itself.

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

Usage Guidelines3/5

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

Usage is implied by the purpose and demonstrated by a concrete example call, which shows the typical argument shape. However, there is no explicit when-to-use vs. when-not guidance and no mention of the alternative vector search tools that could do a similar job.

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

Deploy Server

Other Tools