Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

Hybrid BM25 vector search

hybrid_bm25_vector_search
Read-only

Combine BM25 text search with pgvector vector search using Reciprocal Rank Fusion to produce hybrid search results with transparent per-leg rankings.

Instructions

Combine a BM25 search and a pgvector search via Reciprocal Rank Fusion — the canonical v2 pattern ParadeDB documents in the 2025-10-22 'Hybrid Search Missing Manual' blog post. Returns hits as {id, score, bm25_rank, vector_rank}. score is the summed sum(weight * 1.0 / (k + rank)) across both legs; per-leg ranks are surfaced for transparency (either can be NULL if a row only appeared in one leg's top-K). distance_op is the pgvector operator ('<=>'/'<->'/'<#>' — RRF is operator-agnostic). bm25_columns=None searches the whole BM25 index; bm25_columns=["col"] restricts the BM25 leg to a single field. Defaults mirror upstream's demonstrated form (cosine, k=60, equal weights, per_leg_limit=20). Requires the pg_search and pgvector extensions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kNo
tableYes
schemaYes
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.
key_fieldYes
query_textYes
bm25_weightNo
distance_opNo<=>
final_limitYes
bm25_columnsNo
query_vectorYes
per_leg_limitNo
vector_columnYes
vector_weightNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

The description discloses detailed behavioral traits beyond annotations: the RRF formula, score calculation, handling of per-leg ranks (including NULL cases), and defaults. This adds significant value beyond the readOnlyHint annotation, confirming safe read operations and explaining output structure.

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 dense but well-organized, starting with the core purpose, then output details, parameter explanations, defaults, and requirements. Each sentence adds value without redundancy, making it appropriately sized for the complexity.

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 (14 parameters, 7 required) and the presence of an output schema, the description covers the algorithm, output format, parameter semantics for key fields, and constraints (extensions, defaults). It is sufficiently complete for an agent to understand invocation and expected results.

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?

Schema coverage is only 7%, but the description explains the function of many parameters (e.g., distance_op, bm25_columns, k, weights, per_leg_limit) and their defaults. It does not describe every parameter exhaustively (e.g., vector_weight is mentioned but not explained), but compensates well for the low schema coverage.

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 that it combines BM25 and pgvector search via Reciprocal Rank Fusion, citing a specific blog post. It uses specific verbs and resources, distinguishing itself from other search tools in the sibling list like full_text_search and fuzzy_search by detailing its methodology.

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 implies usage context (combining BM25 and vector search) and lists required extensions, but does not explicitly state when to use this tool over alternatives like hybrid_search or pg_search_run. It provides clear context without exclusionary guidance.

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