Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

Monitor embedding drift

monitor_embedding_drift
Read-only

Compare two time windows of pgvector embeddings and flag distributional drift by measuring cosine distance between centroids and L2-norm changes.

Instructions

Compare two time windows of a pgvector column and flag distributional drift. Samples up to sample_size (default 5000) non-NULL embeddings from each window (filtered by timestamp_column), computes the centroid (per-dimension mean vector) and L2-norm distribution of each, then reports the cosine distance between the two centroids (the main drift signal), the relative change in mean / std of the L2-norm distribution, and a boolean drift_detected that flips when cosine distance exceeds drift_threshold (default 0.05). Each window is treated as a half-open [start, end) interval. Useful for ops monitoring of embedding pipelines — an upstream model swap typically shows up as a large centroid cosine distance even if the norm distribution looks stable. insufficient_data is returned distinctly from drift_detected=false when either window is empty. Reports available=false if pgvector is not installed.

Example: monitor_embedding_drift(schema='public', table='docs', embedding_column='embedding', timestamp_column='created_at', baseline_start='2026-01-01', baseline_end='2026-02-01', current_start='2026-02-01', current_end='2026-03-01')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYes
schemaYes
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.
current_endYes
sample_sizeNo
baseline_endYes
current_startYes
baseline_startYes
drift_thresholdNo
embedding_columnYes
timestamp_columnYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
notesYes
currentYes
baselineYes
availableYes
dimensionYes
drift_detectedYes
drift_thresholdYes
insufficient_dataYes
centroid_cosine_distanceYes
norm_std_relative_changeYes
norm_mean_relative_changeYes
Behavior4/5

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

The description details the algorithm (sampling, centroid, L2-norm, cosine distance), edge cases (insufficient_data, available if pgvector not installed), and the half-open interval behavior. Annotations already declare readOnlyHint=true, so the read-only nature is covered. The description adds significant behavioral context beyond 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?

The description is a single paragraph of ~150 words, efficient and front-loaded with the main action. Every sentence adds value: algorithm, default values, edge cases, example. No redundancy.

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?

The description covers the main return values (cosine distance, drift_detected, insufficient_data, available) and edge cases. Given the tool's complexity and 11 parameters, it is reasonably complete, though more detail on output schema would be beneficial.

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

Parameters2/5

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

With an input schema of 11 parameters and only 9% schema description coverage, the description should compensate. It mentions only sample_size and drift_threshold defaults, and timestamps implicitly. It does not explain schema, table, embedding_column, baseline/current start/end, or the database parameter. The example provides usage but no parameter semantics.

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 the tool's purpose: 'Compare two time windows of a pgvector column and flag distributional drift.' It identifies the specific resource (pgvector column) and action (compare and flag drift), and distinguishes it from sibling tools like detect_vector_outliers or analyze_vector_search_efficiency.

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 provides a concrete use case: 'Useful for ops monitoring of embedding pipelines — an upstream model swap typically shows up as a large centroid cosine distance.' It implies when to use it but does not explicitly exclude alternatives or state when not to use it.

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