Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

MMR search

mmr_search
Read-only

Performs diversity-aware vector search: fetches nearest candidates via pgvector distance, then re-ranks with Maximal Marginal Relevance to return relevant yet diverse results.

Instructions

Diversity-aware vector search: fetch fetch_k nearest candidates by pgvector distance, then re-rank with Maximal Marginal Relevance to return k rows that are relevant but not near-duplicates — better LLM context than raw top-k. lambda_mult in [0,1] trades relevance (1.0) for diversity (0.0); default 0.5. Relevance + diversity are cosine similarities computed over candidate embeddings, so the result is independent of the recall-pass metric. Each hit carries its relevance, mmr_score, and selection rank. Reports available=false if the pgvector extension is not installed.

Example: mmr_search(schema='public', table='docs', column='embedding', query_vector=[0.1, ...], k=10, lambda_mult=0.5)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kNo
tableYes
columnYes
metricNol2
schemaYes
fetch_kNo
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.
lambda_multNo
query_vectorYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
matchesYes
availableYes
Behavior4/5

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

Annotations already declare readOnlyHint=true, which matches the tool's read-only nature. The description adds valuable behavior details: the available=false flag when pgvector is missing, and that relevance/diversity use cosine similarity independent of the retrieval metric. This goes beyond what annotations provide.

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 efficiently structured: a summary sentence, explanation of core parameters, output fields, error condition, and an explicit example. Every sentence adds value and the most critical information appears first.

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 existence of an output schema (which describes return fields), the description still adds algorithmic context, explains the output (relevance, mmr_score, selection rank), notes the pgvector dependency, and provides a concrete example. It is fully adequate for an agent to understand and invoke the tool correctly.

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 description coverage is only 11% (only 'database' has a raw description). The description compensates by explaining the key parameters lambda_mult and fetch_k (their roles, ranges, defaults) and includes an example call that illustrates many parameters. However, it does not detail schema, table, column, or query_vector beyond self-evident 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 identifies the tool as a diversity-aware vector search using Maximal Marginal Relevance, explicitly distinguishing it from raw top-k and implying its advantage for LLM context. Among many sibling search tools, it uniquely highlights MMR re-ranking.

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 states when to use this tool (when diverse results are preferred for LLM context) and implies that raw top-k is a simpler alternative. It does not explicitly list alternative tools or when not to use, but provides sufficient context for an AI agent to make a choice.

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