Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

PG search run

pg_search_run
Read-only

Execute a full-text BM25 search on a pg_search-indexed table, returning results with relevance scores and configurable snippet highlighting.

Instructions

Run a BM25 keyword search against a pg_search-indexed table. Returns hits as {id, score, snippets} where id is the value of the caller-supplied key_field and score is pdb.score(t). columns=None searches the whole index; columns=["col"] restricts to a single text field. Multi-column search needs the pdb.parse per-field config JSON and is deferred to a follow-up phase. return_snippets=True requires snippet_field and projects pdb.snippets over that column. Requires the pg_search extension. SECURITY: snippet_start_tag / snippet_end_tag are not sanitized (they pass through to upstream as-is). The defaults match pg_search's HTML defaults; if callers forward untrusted values and a downstream consumer renders snippets as HTML, that's an XSS vector — output escaping is the renderer's responsibility.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitYes
queryYes
tableYes
schemaYes
columnsNo
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.
key_fieldYes
snippet_fieldNo
return_snippetsNo
snippet_end_tagNo</b>
snippet_start_tagNo<b>
snippet_max_num_charsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

The description extensively discloses behaviors beyond the readOnlyHint annotation: it explains the return format, the role of key_field and score, column search behavior, snippet parameters, and security implications of unsanitized tags. There is no contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured: it opens with the core action and return format, then parameter behaviors, then security notes. Every sentence adds value, though it is slightly long. 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 output format and key parameters, given the existence of an output schema. It does not address pagination or error handling, but for a search tool this is acceptable. Overall, it provides sufficient context for most use cases.

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?

With only 8% schema description coverage, the description adds significant meaning for parameters such as key_field, score, columns, return_snippets, snippet_field, and snippet tags (including XSS warning). It does not explain limit, schema, table, or database (though database has a schema description). Compensates well for low coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it runs a BM25 keyword search against a pg_search-indexed table and specifies the return format (id, score, snippets). It distinguishes itself by mentioning pg_search-specific features and limitations, but does not explicitly differentiate from sibling search tools like fuzzy_search or full_text_search.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions the requirement for the pg_search extension and defers multi-column search to a follow-up phase, implying usage constraints. However, it does not explicitly state when to use this tool versus alternatives (e.g., hybrid_search, vector_search) or provide exclusion criteria.

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