Back to Home
compilotbv icon

mcpg

Verified Safe

by compilotbv

Overview

A Model Context Protocol (MCP) server that provides a secure, API-driven interface for interacting with PostgreSQL databases, enabling AI agents and IDEs to manage and query data.

Installation

Run Command
docker run -i --rm -e MCP_API_KEY=your_api_key -e POSTGRES_HOST=your_postgres_host -e POSTGRES_PORT=5432 -e POSTGRES_DB=your_database_name -e POSTGRES_USER=your_database_user -e POSTGRES_PASSWORD=your_database_password postgresql-mcp-server

Environment Variables

  • MCP_API_KEY
  • POSTGRES_HOST
  • POSTGRES_DB
  • POSTGRES_USER
  • POSTGRES_PASSWORD

Security Notes

The server uses parameterized queries (`psycopg2`) to prevent SQL injection. All sensitive credentials are sourced from environment variables, preventing hardcoding. API key authentication is enforced. Subprocess calls for `pg_dump` and `pg_restore` are constructed with explicit arguments, minimizing command injection risks. The option for read-only mode further enhances security for exploratory use cases. Ensure necessary `pg_dump` and `pg_restore` binaries are present in the Docker image for backup/restore functionality.

Similar Servers

Stats

Interest Score0
Security Score9
Cost ClassMedium
Avg Tokens750
Stars0
Forks0
Last Update2025-11-23

Tags

PostgreSQLDatabase ManagementMCPAPIDocker