Cross table similarity
cross_table_similarityFind the k most similar rows in a target table to a source row by matching pgvector embeddings across tables, enabling entity resolution and linking with dimension checks.
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.
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": {
"source_schema": "<source_schema>",
"source_table": "<source_table>",
"source_embedding_column": "<source_embedding_column>",
"source_id_column": "<source_id_column>",
"source_id_value": "<source_id_value>",
"target_schema": "<target_schema>",
"target_table": "<target_table>",
"target_embedding_column": "<target_embedding_column>"
},
"name": "cross_table_similarity"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| k | No | ||
| metric | No | l2 | |
| database | No | 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. | |
| source_table | Yes | ||
| target_table | Yes | ||
| source_schema | Yes | ||
| target_schema | Yes | ||
| source_id_value | Yes | ||
| source_id_column | Yes | ||
| source_embedding_column | Yes | ||
| target_embedding_column | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| matches | Yes | ||
| available | Yes | ||
| source_dimension | Yes | ||
| source_embedding_found | Yes |