# query

Run a read-only SQL query

Agent View of the PolicyLayer registry record for `query`. HTML page: https://policylayer.com/tools/postgres/query

## Facts

- Tool: `query`
- Server: PostgreSQL (`@modelcontextprotocol/server-postgres`) — https://policylayer.com/tools/postgres.md
- Install: `npx -y @modelcontextprotocol/server-postgres`
- Homepage: https://github.com/modelcontextprotocol/server-postgres
- Risk category: Read (Low risk)
- Registry record: grade F, identity verified
- Server rate-limited: no
- Parameters: 0
- Recommended policy verdict: Allowed

## Example call (MCP tools/call, JSON-RPC 2.0)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "query",
    "arguments": {}
  }
}
```

## Why query is rated Low

A read-only SQL query tool can only retrieve or inspect data without side effects. Even though SQL queries can be complex, the read-only restriction prevents Write, Destructive, Execute, and Financial risks. Severity is low because the blast radius is limited to information disclosure; an agent cannot cause operational damage through this tool alone.

From the tool's own definition: "Tool name is 'query' and description explicitly states 'Run a read-only SQL query'. The read-only constraint means no data modification, deletion, or execution of arbitrary code is possible."

## Use case

AI agents call query to retrieve information from PostgreSQL without modifying anything. It is typically the context-gathering step in research, monitoring, and reporting workflows, before the agent takes action elsewhere.

## Recommended policy (PolicyLayer)

Verdict: **Allowed**. Enforced by the PolicyLayer MCP gateway (https://policylayer.com/mcp-gateway) before a call reaches PostgreSQL:

```json
{
  "version": "1",
  "default": "deny",
  "tools": {
    "query": {}
  }
}
```

## For agents

This record is a snapshot. Live verdicts and the full registry:

- Check every server in your MCP config at once: `npx -y policylayer stack`
- Vet a server before you add it: install the mcp-precheck skill — `npx skills add https://policylayer.com` (skill text: https://policylayer.com/skill.md)
- Query the registry over MCP: endpoint `https://api.policylayer.com/mcp` — tools `check_mcp_server`, `check_mcp_stack`, `check_tool`, `search_registry`, `get_change_events`

---

Source: the PolicyLayer MCP registry — one continuously verified record per MCP server. Full record: https://policylayer.com/registry?q=postgres · API: https://policylayer.com/registry/api · Policy library: https://policylayer.com/policies/postgres
