PostgreSQL MCP Server for Cloudflare Workers
21 tools available in the PostgreSQL MCP server. Each tool can be called by AI assistants to perform specific actions.
postgresql_database_infoGet information about the connected database.
Returns comprehensive database information including:
{
"type": "object",
"properties": {
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
}
}
}postgresql_list_extensionsList installed PostgreSQL extensions.
Returns all extensions currently installed in the database.
Returns: List of extensions with:
{
"type": "object",
"properties": {
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
}
}
}postgresql_table_statsGet statistics for a table.
Returns detailed statistics about table usage and maintenance.
Args:
Returns: Table statistics including:
{
"type": "object",
"required": [
"table"
],
"properties": {
"table": {
"type": "string",
"description": "Table name"
},
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"schema": {
"type": "string",
"default": "public",
"description": "Schema name"
}
}
}postgresql_list_functionsList functions and procedures in a schema.
Args:
Returns: List of functions with:
{
"type": "object",
"properties": {
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"schema": {
"type": "string",
"default": "public",
"description": "Schema name"
}
}
}postgresql_get_functionGet the full definition of a function or procedure.
Args:
Returns: Complete function definition including:
{
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"description": "Function name"
},
"schema": {
"type": "string",
"default": "public",
"description": "Schema name"
}
}
}postgresql_list_triggersList triggers on a table or all triggers in a schema.
Args:
Returns: List of triggers with:
{
"type": "object",
"properties": {
"table": {
"type": "string",
"description": "Table name (optional)"
},
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"schema": {
"type": "string",
"default": "public",
"description": "Schema name"
}
}
}postgresql_list_sequencesList all sequences in a schema.
Args:
Returns: List of sequences with:
{
"type": "object",
"properties": {
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"schema": {
"type": "string",
"default": "public",
"description": "Schema name"
}
}
}postgresql_list_rolesList database roles.
Returns all user-created roles (excluding system roles starting with pg_).
Returns: List of roles with:
{
"type": "object",
"properties": {
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
}
}
}postgresql_list_privilegesList privileges granted on a table.
Args:
Returns: List of privileges with:
{
"type": "object",
"required": [
"table"
],
"properties": {
"table": {
"type": "string",
"description": "Table name"
},
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"schema": {
"type": "string",
"default": "public",
"description": "Schema name"
}
}
}postgresql_list_connectionsList active database connections.
Returns all active connections to the current database.
Returns: List of connections with:
{
"type": "object",
"properties": {
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
}
}
}postgresql_get_settingsGet PostgreSQL configuration settings.
Args:
Returns: List of settings with:
{
"type": "object",
"properties": {
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"pattern": {
"type": "string",
"description": "Filter pattern for setting names"
}
}
}postgresql_queryExecute a read-only SQL query (SELECT, WITH, EXPLAIN, SHOW).
This tool is for querying data from the database. It only allows read operations for safety. Use postgresql_execute for write operations.
Args:
Examples:
Returns: Query results with rows, row count, column info, and execution time.
{
"type": "object",
"required": [
"sql"
],
"properties": {
"sql": {
"type": "string",
"description": "SQL query to execute (SELECT, WITH, EXPLAIN, SHOW only)"
},
"format": {
"enum": [
"json",
"markdown",
"table"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"params": {
"type": "array",
"items": {
"type": "string"
},
"description": "Query parameters (for $1, $2, etc.)"
}
}
}postgresql_executeExecute a write SQL command (INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, etc.).
This tool executes commands that modify the database. Use with caution. For safety, always use parameterized queries to prevent SQL injection.
Args:
Examples:
Returns: Command result with affected row count and execution time.
{
"type": "object",
"required": [
"sql"
],
"properties": {
"sql": {
"type": "string",
"description": "SQL command to execute"
},
"params": {
"type": "array",
"items": {
"type": "string"
},
"description": "Query parameters (for $1, $2, etc.)"
}
}
}postgresql_explainGet the execution plan for a SQL query.
Analyzes how PostgreSQL will execute the query without actually running it. Use ANALYZE option to execute the query and see actual timings.
Args:
Returns: Query execution plan showing:
{
"type": "object",
"required": [
"sql"
],
"properties": {
"sql": {
"type": "string",
"description": "SQL query to explain"
},
"format": {
"enum": [
"json",
"text"
],
"type": "string",
"default": "json",
"description": "Output format"
},
"params": {
"type": "array",
"items": {
"type": "string"
},
"description": "Query parameters"
},
"analyze": {
"type": "boolean",
"default": false,
"description": "Execute query and show actual timings"
},
"buffers": {
"type": "boolean",
"default": false,
"description": "Show buffer usage (requires analyze)"
}
}
}postgresql_list_schemasList all database schemas.
Returns all user-created schemas in the database, excluding system schemas (pg_catalog, information_schema, pg_toast).
Returns: List of schemas with name and owner.
{
"type": "object",
"properties": {
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
}
}
}postgresql_list_tablesList all tables in a schema.
Returns tables, views, and foreign tables with size information.
Args:
Returns: List of tables with:
{
"type": "object",
"properties": {
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"schema": {
"type": "string",
"default": "public",
"description": "Schema name"
}
}
}postgresql_describe_tableGet complete information about a table.
Returns detailed information including columns, indexes, constraints, and foreign keys for the specified table.
Args:
Returns: Complete table structure:
{
"type": "object",
"required": [
"table"
],
"properties": {
"table": {
"type": "string",
"description": "Table name"
},
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"schema": {
"type": "string",
"default": "public",
"description": "Schema name"
}
}
}postgresql_list_columnsList all columns in a table.
Args:
Returns: List of columns with:
{
"type": "object",
"required": [
"table"
],
"properties": {
"table": {
"type": "string",
"description": "Table name"
},
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"schema": {
"type": "string",
"default": "public",
"description": "Schema name"
}
}
}postgresql_list_indexesList all indexes on a table.
Args:
Returns: List of indexes with:
{
"type": "object",
"required": [
"table"
],
"properties": {
"table": {
"type": "string",
"description": "Table name"
},
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"schema": {
"type": "string",
"default": "public",
"description": "Schema name"
}
}
}postgresql_list_constraintsList all constraints on a table.
Args:
Returns: List of constraints:
{
"type": "object",
"required": [
"table"
],
"properties": {
"table": {
"type": "string",
"description": "Table name"
},
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"schema": {
"type": "string",
"default": "public",
"description": "Schema name"
}
}
}postgresql_list_foreign_keysList all foreign keys for a table.
Args:
Returns: List of foreign keys with:
{
"type": "object",
"required": [
"table"
],
"properties": {
"table": {
"type": "string",
"description": "Table name"
},
"format": {
"enum": [
"json",
"markdown"
],
"type": "string",
"default": "json",
"description": "Response format"
},
"schema": {
"type": "string",
"default": "public",
"description": "Schema name"
}
}
}