Skip to main content
Glama

PostgreSQL MCP Server

AGPL 3.0
498
94
  • Linux
  • Apple

pg_execute_sql

Execute any valid PostgreSQL SQL statements with parameterized inputs, transaction control, and customizable timeouts for efficient database operations.

Instructions

Execute arbitrary SQL statements - sql="ANY_VALID_SQL" with optional parameters and transaction support. Examples: sql="CREATE INDEX ...", sql="WITH complex_cte AS (...) SELECT ...", transactional=true

Input Schema

NameRequiredDescriptionDefault
connectionStringNoPostgreSQL connection string (optional)
expectRowsNoWhether to expect rows back (false for statements like CREATE, DROP, etc.)
parametersNoParameter values for prepared statement placeholders ($1, $2, etc.)
sqlYesSQL statement to execute (can be any valid PostgreSQL SQL)
timeoutNoQuery timeout in milliseconds
transactionalNoWhether to wrap in a transaction

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "connectionString": { "description": "PostgreSQL connection string (optional)", "type": "string" }, "expectRows": { "default": true, "description": "Whether to expect rows back (false for statements like CREATE, DROP, etc.)", "type": "boolean" }, "parameters": { "default": [], "description": "Parameter values for prepared statement placeholders ($1, $2, etc.)", "items": {}, "type": "array" }, "sql": { "description": "SQL statement to execute (can be any valid PostgreSQL SQL)", "type": "string" }, "timeout": { "description": "Query timeout in milliseconds", "type": "number" }, "transactional": { "default": false, "description": "Whether to wrap in a transaction", "type": "boolean" } }, "required": [ "sql" ], "type": "object" }
Install Server

Other Tools from PostgreSQL MCP Server

Related Tools

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/HenkDz/postgresql-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server