pg_manage_users
Streamline PostgreSQL user and permissions management with create, drop, alter, grant, and revoke operations, enabling precise control over database access and privileges.
Instructions
Manage PostgreSQL users and permissions - create, drop, alter users, grant/revoke permissions. Examples: operation="create" with username="testuser", operation="grant" with username, permissions, target, targetType
Input Schema
Name | Required | Description | Default |
---|---|---|---|
cascade | No | Include CASCADE to drop owned objects (for drop/revoke operations) | |
connectionLimit | No | Maximum number of connections (for create/alter operations) | |
connectionString | No | PostgreSQL connection string (optional) | |
createdb | No | Allow user to create databases (for create/alter operations) | |
createrole | No | Allow user to create roles (for create/alter operations) | |
ifExists | No | Include IF EXISTS clause (for drop operation) | |
includeSystemRoles | No | Include system roles (for list operation) | |
inherit | No | Inherit privileges from parent roles (for create/alter operations) | |
login | No | Allow user to login (for create/alter operations) | |
operation | Yes | Operation: create (new user), drop (remove user), alter (modify user), grant (permissions), revoke (permissions), get_permissions (view permissions), list (all users) | |
password | No | Password for the user (for create operation) | |
permissions | No | Permissions to grant/revoke: ["SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", "ALL"] | |
replication | No | Allow replication privileges (for create/alter operations) | |
schema | No | Filter by schema (for get_permissions operation) | |
superuser | No | Grant superuser privileges (for create/alter operations) | |
target | No | Target object name (for grant/revoke operations) | |
targetType | No | Type of target object (for grant/revoke operations) | |
username | No | Username (required for create/drop/alter/grant/revoke/get_permissions, optional filter for list) | |
validUntil | No | Password expiration date YYYY-MM-DD (for create/alter operations) | |
withGrantOption | No | Allow user to grant these permissions to others (for grant operation) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"cascade": {
"description": "Include CASCADE to drop owned objects (for drop/revoke operations)",
"type": "boolean"
},
"connectionLimit": {
"description": "Maximum number of connections (for create/alter operations)",
"type": "number"
},
"connectionString": {
"description": "PostgreSQL connection string (optional)",
"type": "string"
},
"createdb": {
"description": "Allow user to create databases (for create/alter operations)",
"type": "boolean"
},
"createrole": {
"description": "Allow user to create roles (for create/alter operations)",
"type": "boolean"
},
"ifExists": {
"description": "Include IF EXISTS clause (for drop operation)",
"type": "boolean"
},
"includeSystemRoles": {
"description": "Include system roles (for list operation)",
"type": "boolean"
},
"inherit": {
"description": "Inherit privileges from parent roles (for create/alter operations)",
"type": "boolean"
},
"login": {
"description": "Allow user to login (for create/alter operations)",
"type": "boolean"
},
"operation": {
"description": "Operation: create (new user), drop (remove user), alter (modify user), grant (permissions), revoke (permissions), get_permissions (view permissions), list (all users)",
"enum": [
"create",
"drop",
"alter",
"grant",
"revoke",
"get_permissions",
"list"
],
"type": "string"
},
"password": {
"description": "Password for the user (for create operation)",
"type": "string"
},
"permissions": {
"description": "Permissions to grant/revoke: [\"SELECT\", \"INSERT\", \"UPDATE\", \"DELETE\", \"TRUNCATE\", \"REFERENCES\", \"TRIGGER\", \"ALL\"]",
"items": {
"enum": [
"SELECT",
"INSERT",
"UPDATE",
"DELETE",
"TRUNCATE",
"REFERENCES",
"TRIGGER",
"ALL"
],
"type": "string"
},
"type": "array"
},
"replication": {
"description": "Allow replication privileges (for create/alter operations)",
"type": "boolean"
},
"schema": {
"description": "Filter by schema (for get_permissions operation)",
"type": "string"
},
"superuser": {
"description": "Grant superuser privileges (for create/alter operations)",
"type": "boolean"
},
"target": {
"description": "Target object name (for grant/revoke operations)",
"type": "string"
},
"targetType": {
"description": "Type of target object (for grant/revoke operations)",
"enum": [
"table",
"schema",
"database",
"sequence",
"function"
],
"type": "string"
},
"username": {
"description": "Username (required for create/drop/alter/grant/revoke/get_permissions, optional filter for list)",
"type": "string"
},
"validUntil": {
"description": "Password expiration date YYYY-MM-DD (for create/alter operations)",
"type": "string"
},
"withGrantOption": {
"description": "Allow user to grant these permissions to others (for grant operation)",
"type": "boolean"
}
},
"required": [
"operation"
],
"type": "object"
}