query
Execute read-only SQL queries against the database
How to use it
query is exposed by the Postgres MCP MCP server. Add the server to your MCP client (Claude Desktop, Cursor, Windsurf and others), and the query tool becomes available to the model automatically. See the full listing for setup details and every tool this server provides.
Install Postgres MCP
npx @javiagui/postgresql-mcpOther tools in Postgres MCP (14)
Get table structure (columns, types, constraints)
Get view definition and columns
Execute write operations (INSERT/UPDATE/DELETE) when enabled
Get EXPLAIN plan for query optimization
Get database version and connection info
List constraints (PK, FK, UNIQUE, CHECK)
List the configured connections by alias, with host, database, write permission and which is the default. Never returns credentials.
List functions and procedures
List indexes for a table
List all schemas in the database
List tables in a specific schema
List views in a schema
Search for columns by name across all tables
Get table statistics (row count, size, bloat)