Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

Cross table similarity

cross_table_similarity
Read-only

Find rows in one table most similar to a specific row in another table using vector embeddings, for entity resolution and cross-table linking.

Instructions

Find the k rows in target_schema.target_table most similar to a specific row in source_schema.source_table. Locates the source row via source_id_column = source_id_value, reads its embedding from source_embedding_column, then issues a pgvector k-NN query against target_embedding_column. Both columns must be vector(N) of the same N — verified from the catalog up front so a mismatch fails with a clear error rather than a cast error. Useful for entity-resolution / linking across tables whose embeddings come from different models but share a dimension. Returns source_embedding_found=false when no row matches the id value. Reports available=false if pgvector is not installed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kNo
metricNol2
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.
source_tableYes
target_tableYes
source_schemaYes
target_schemaYes
source_id_valueYes
source_id_columnYes
source_embedding_columnYes
target_embedding_columnYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
matchesYes
availableYes
source_dimensionYes
source_embedding_foundYes
Behavior5/5

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

The description goes well beyond the readOnlyHint annotation. It details the exact steps (locate source row, read embedding, pgvector k-NN query), dimensional verification upfront, clear error handling for missing id and missing pgvector. This provides comprehensive behavioral transparency.

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?

Concise at ~100 words, with front-loaded main action and separate error handling. Every sentence adds value with no redundancy. The structure is logical and easy to scan.

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 complexity (cross-table embedding similarity) and minimal annotations, the description covers the main functionality, error conditions, prerequisites (pgvector, dimension match), and the use case. The output schema exists separately, so return value details are not required. The description is complete enough for an agent to correctly select and invoke the tool.

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

Parameters4/5

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

Despite only 9% schema coverage, the description explains the roles of many parameters through the narrative of the operation (source/target schema/table/embedding columns, id column/value, k, metric). It adds meaning beyond the schema titles, though it could explicitly list and describe each parameter for full clarity.

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?

Clearly states the specific action: 'Find the k rows in target_schema.target_table most similar to a specific row in source_schema.source_table.' This verb-resource combination with cross-table scope is distinct from sibling tools like vector_search (same-table) and analyze_* tools. The entity-resolution use case further clarifies 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?

Provides a clear use case: 'entity-resolution / linking across tables whose embeddings come from different models but share a dimension.' This implies when to use it. However, it does not explicitly mention when not to use or list alternatives, which would improve guidance. Still, the context of siblings like vector_search suggests differentiation.

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