# execute_query

Execute a custom SELECT SQL query on the PostgreSQL database.

Agent View of the PolicyLayer registry record for `execute_query`. HTML page: https://policylayer.com/tools/aadarshjain-postgres-mcp-server/execute-query

## Facts

- Tool: `execute_query`
- Server: PostgreSQL MCP Server (`aadarshjain/postgres-mcp-server`) — https://policylayer.com/tools/aadarshjain-postgres-mcp-server.md
- Homepage: https://github.com/aadarshjain/postgres-mcp-server
- Risk category: Execute (High risk)
- Registry record: grade C, identity unverified
- Server rate-limited: no
- Parameters: 0
- Recommended policy verdict: Rate-limited

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

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

## Why execute_query is rated High

The tool executes arbitrary SQL queries constructed at runtime. Even though the stated purpose is SELECT queries (read operations), the 'execute' verb and 'custom' qualifier classify this as Execute rather than Read. An AI agent with access to this tool could be tricked into executing unintended queries that access sensitive data across the entire database.

From the tool's own definition: "Tool name 'execute_query' combined with description 'Execute a custom SELECT SQL query on the PostgreSQL database' indicates the ability to run arbitrary SQL queries."

## Use case

AI agents invoke execute_query to trigger actions in PostgreSQL MCP Server. What it does depends on the arguments the agent supplies, and its effects often reach beyond the immediate call: builds kicked off, notifications sent, workflows started.

## Recommended policy (PolicyLayer)

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

```json
{
  "version": "1",
  "default": "deny",
  "tools": {
    "execute_query": {
      "limits": [
        {
          "counter": "execute_query_rate",
          "window": "minute",
          "max": 10,
          "scope": "grant"
        }
      ]
    }
  }
}
```

## Other tools on PostgreSQL MCP Server (4)

- `filter_instances` — Read — https://policylayer.com/tools/aadarshjain-postgres-mcp-server/filter-instances.md
- `get_database_stats` — Read — https://policylayer.com/tools/aadarshjain-postgres-mcp-server/get-database-stats.md
- `get_table_schema` — Read — https://policylayer.com/tools/aadarshjain-postgres-mcp-server/get-table-schema.md
- `list_tables` — Read — https://policylayer.com/tools/aadarshjain-postgres-mcp-server/list-tables.md

## 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=aadarshjain-postgres-mcp-server · API: https://policylayer.com/registry/api · Policy library: https://policylayer.com/policies/aadarshjain-postgres-mcp-server
