Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

Detect vector outliers

detect_vector_outliers
Read-only

Flag pgvector rows with embeddings far from their cluster centroid using per-cluster z-scores, identifying outliers within vector groups.

Instructions

Flag pgvector rows whose embedding sits far from any cluster centroid. Samples up to sample_size (default 5000) non-NULL rows of schema.table.embedding_column, clusters them with k-means (same engine as cluster_vectors), then per cluster computes a z-score on the distance from each row to its centroid and flags rows whose z-score exceeds zscore_threshold (default 3.0). Per-cluster scoring catches rows that are weird-for-their-group rather than weird-overall, which is usually what 'find outliers' should mean. Returns outliers sorted by z-score descending (capped at max_results), total_outliers (the unclipped count), and cluster_stats (per-cluster mean / std of within-cluster distances). When id_column is set each outlier carries that column's value; otherwise the row's positional sample index. k >= 2 and there must be at least 2k parseable rows. Reports available=false if pgvector is not installed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kNo
seedNo
tableYes
metricNol2
schemaYes
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.
id_columnNo
max_resultsNo
sample_sizeNo
max_iterationsNo
embedding_columnYes
zscore_thresholdNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
kYes
metricYes
outliersYes
availableYes
dimensionYes
sampled_rowsYes
cluster_statsYes
total_outliersYes
zscore_thresholdYes
Behavior5/5

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

The description discloses sampling behavior, clustering method (same as cluster_vectors), per-cluster scoring, sorting, and capping. It also notes the 'available=false' condition if pgvector is missing, which adds context beyond the readOnlyHint annotation. No contradictions.

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 a single, dense paragraph that efficiently covers functionality, algorithm, return values, and constraints. Every sentence adds value without 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?

Given the tool's complexity (12 parameters, algorithm details) and presence of an output schema, the description thoroughly explains how it works, what it returns, and prerequisites. It addresses both parameter semantics and behavioral nuances.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With only 8% schema coverage, the description provides extensive context for many parameters: sample_size, zscore_threshold, k, max_results, id_column, etc., explaining their roles and defaults. This significantly compensates for the sparse schema 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 description clearly states it flags rows with embeddings far from cluster centroids, explains the per-cluster z-score method, and distinguishes it from global outlier detection. It also mentions the return structure and includes the tool name's purpose.

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?

The description explains when to use (find outliers within clusters) and provides prerequisites (k >= 2, at least 2k rows, pgvector installed). It implicitly contrasts with a global approach but does not explicitly list alternatives or when not to use.

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/devopam/MCPg'

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