Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

Run SELECT tuned

run_select_tuned
Read-only

Run heavy analytical SELECT queries with elevated work_mem to prevent disk spills, using SET LOCAL for safe per-statement memory tuning.

Instructions

Run a read-only SELECT with an elevated, bounded work_mem (and optionally maintenance_work_mem) for THIS statement only. Useful for heavy analytical SELECTs (large sorts / hash joins / GROUP BY) that spill to disk under the default work_mem. The knob is set via SET LOCAL inside the same read-only transaction, so it never leaks back into the pool. Both knobs must match ^\d+(kB|MB|GB)$ and are hard-capped at 2GB (unbounded values are an OOM risk). SQL is validated read-only by the same allowlist as run_select. SET LOCAL only affects transactional statements — non-transactional maintenance (CREATE INDEX CONCURRENTLY, VACUUM) is out of scope.

Example: run_select_tuned(sql='SELECT a, count(*) FROM big GROUP BY a', work_mem='256MB')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.
max_rowsNo
work_memYes
maintenance_work_memNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
rowsYes
columnsYes
row_countYes
truncatedYes
Behavior5/5

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

Annotations already set readOnlyHint=true, but description adds significant behavioral details: SET LOCAL scoping so memory setting doesn't leak, hard cap at 2GB to prevent OOM, regex validation for memory units, and read-only validation via same allowlist as run_select. These go well beyond annotations.

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?

Description is concise yet comprehensive. First sentence states purpose, then usage context, then constraints, and ends with an example. Every sentence adds value; no fluff. Suitable length for the tool's complexity.

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?

Given the tool's complexity (5 parameters, memory tuning, read-only validation) and presence of an output schema, the description covers the key aspects: purpose, parameter semantics, scoping, and constraints. It does not detail return values (handled by output schema) or error cases, but remains complete enough for correct invocation.

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 20% schema description coverage, the description compensates well by explaining work_mem and maintenance_work_mem: bounded, local scope, regex pattern, cap. It does not detail sql, max_rows, or database (database has its own schema description). Adds significant meaning beyond bare schema.

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?

Description clearly states it runs a read-only SELECT with tuned work_mem for heavy analytical queries. It distinguishes itself from run_select by explicitly mentioning the memory tuning and scoping via SET LOCAL. Verb 'run' + resource 'read-only SELECT with tuned work_mem' is specific and unambiguous.

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?

Explicitly says it's 'useful for heavy analytical SELECTs... that spill to disk under default work_mem.' It also mentions what is out of scope (non-transactional maintenance). However, it does not explicitly state when not to use it (e.g., simple queries where default work_mem suffices should use run_select instead).

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