Skip to main content
Glama
MCPg - Production-grade PostgreSQL MCP Server

MCPg - Production-grade PostgreSQL MCP Server

Test RLS for role

test_rls_for_role
Read-only

Verify what a PostgreSQL role can read from a table under row-level security: check RLS and policies, count visible rows, and inspect sample rows in a read-only transaction.

Instructions

Test what an RLS-bound role can read from a table. Reports whether RLS is enabled on the table, lists the policies that apply to the given role, counts the rows the role can read, and returns up to sample_size rows so the agent can inspect them. Runs as the target role inside a READ ONLY transaction — no writes can leak. Pure read.

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": {
      "schema": "<schema>",
      "table": "<table>",
      "role": "<role>"
    },
    "name": "test_rls_for_role"
  }
}

Input Schema

NameRequiredDescriptionDefault
roleYes
tableYes
schemaYes
databaseNoOptional: 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.
sample_sizeNo

Output Schema

NameRequiredDescriptionDefault
roleYes
tableYes
sampleYes
schemaYes
columnsYes
rls_enabledYes
rows_visibleYes
active_policiesYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.8.4
    • changedInput schema / properties / database / description
      Previous value: -"Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids."New value: +"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."
  2. First observedv0.6.8

TDQS

A4/5.0
Behavior4/5

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

Beyond readOnlyHint=true and openWorldHint=false, it discloses meaningful execution semantics: the query runs as the target role and inside a READ ONLY transaction, so no writes can leak. That is exactly the kind of context annotations cannot convey. It still omits cost/limit characteristics for a full count over large tables, which is a real behavioral concern for row-counting tools.

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?

Front-loaded with the core action, then outputs, then safety. The closing "Pure read." is partly redundant with "no writes can leak" and the readOnlyHint annotation, but it is a cheap emphasis rather than bloat.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present, the return-value explanation is a bonus rather than a necessity. The gap is on the input side and on operational cost: for a tool that counts all readable rows, the description gives no sense of expense or scale limits, which matters when choosing it over a cheap metadata listing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is only 20%, so the description must carry the load: it explains sample_size in effect ("returns up to sample_size rows") and ties role and table to the operation. However, schema is never mentioned, no format or qualification guidance is given (e.g., schema.table naming), and database is left entirely to the schema field.

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?

States a specific verb and resource ("Test what an RLS-bound role can read from a table") and then enumerates the concrete outputs: RLS-enabled status, applicable policies, readable row count, and a row sample. That is clearly distinct from siblings like list_policies or list_grants, which only enumerate metadata without exercising the role.

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 makes the usage context clear: use this when you need to know what a specific role actually sees through RLS, not just which policies exist. It does not explicitly name alternatives (e.g., list_policies for a purely declarative view) or state when not to use it, so it stops short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools