Registry / database / postgres-activity-mcp

postgres-activity-mcp

JSON →
library0.1.0jsnpmunverified

Version 0.1.0. An MCP (Model Context Protocol) server that automatically logs all INSERT, UPDATE, and DELETE operations in a PostgreSQL database and exposes the log to AI coding agents via MCP tools. Unlike manual database introspection, it sets up audit triggers on all tracked tables once, then lets agents query recent row changes without writing SQL. Currently requires Node >=20 and Postgres >=13. Ships four tools: setup_activity_logging, refresh_activity_triggers, get_recent_db_changes, and summarize_recent_db_changes. Not yet stable; API and trigger behavior may change between minor versions.

npm install postgres-activity-mcp
INSTALL
IMPORT
SIG · POSTGRES-ACTIVITY-
P
postgres-activity-mcp
databasejavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

server (MCP server)
✓ npx -y postgres-activity-mcp
This package is a CLI MCP server, not a library. Run via npx or from source. No JS import entry point is published.

Add the MCP server to your client configuration (e.g., Claude Desktop or custom MCP client), pointing to your local Postgres.

{ "mcpServers": { "postgres-activity": { "command": "npx", "args": ["-y", "postgres-activity-mcp"], "env": { "DATABASE_URL": "postgres://postgres:postgres@localhost:5432/my_database" } } } }
Debug
Known issues
gotchaThe DATABASE_URL user must have superuser or sufficient privileges to CREATE TABLE, CREATE FUNCTION, and CREATE TRIGGER on all tracked tables.
fix
Use a superuser for local development, or grant the necessary permissions manually.
affects: >=0.1.0
gotchaThe setup tool creates triggers on ALL tables in the connected database's public schema (and any tracked schemas). This may cause unexpected audit log growth on noisy tables.
fix
Manually drop triggers on tables you don't want to track, or configure tracked schemas in the tool call.
affects: >=0.1.0
breakingThis package requires PostgreSQL >=13 because it uses built-in immutable function `ABS` (since v13) in trigger function timestamp logic.
fix
Upgrade Postgres to 13+ or stay on 0.1.0 with an older trigger function and manual adjustment.
affects: >=0.1.0
deprecatedThe initial release (0.1.0) may have instability in trigger creation on partitioned tables or tables with foreign key cascades.
fix
Test on your schema; file issues on GitHub if triggers fail silently.
affects: ==0.1.0
gotchaRunning setup_activity_logging multiple times is safe (idempotent), but may re-create triggers with slightly different behavior after an upgrade — check the CHANGELOG before re-running.
fix
After upgrading the MCP server, always re-run setup_activity_logging to get the latest trigger function.
affects: >=0.1.0
Errors
Common errors & fixes
Error: permission denied to create "db_activity_log"
DATABASE_URL user lacks CREATE TABLE permission.
fix
Grant CREATE on schema: GRANT CREATE ON SCHEMA public TO your_user;
Cannot read properties of undefined (reading 'schemas')
The server could not connect to the database or the database does not exist.
fix
Check DATABASE_URL connection string and that the database is running.
ERROR: function public.record_change() does not exist
The trigger function was not created or was dropped.
fix
Run setup_activity_logging tool again to (re)create the function.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
pgrequiredPostgreSQL client for connecting to the database and executing queries from MCP tools.
Agent activity
4 hits · last 30 days
node
4
Resources
postgres-activity-mcp — npm install postgres-activity-mcp · libregistry