@@ -7,6 +7,11 @@ A Model Context Protocol (MCP) server that provides comprehensive PostgreSQL dat
77
88## Quick Start
99
10+ ## Prerequisites
11+ - Node.js ≥18.0.0
12+ - Access to a PostgreSQL server
13+ - (Optional) An MCP client like Cursor or Claude for AI integration
14+
1015[ ![ Install MCP Server] ( https://cursor.com/deeplink/mcp-install-dark.svg )] ( https://cursor.com/install-mcp?name=postgresql-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBoZW5rZXkvcG9zdGdyZXMtbWNwLXNlcnZlciIsIi0tY29ubmVjdGlvbi1zdHJpbmciLCJwb3N0Z3Jlc3FsOi8vdXNlcjpwYXNzd29yZEBob3N0OnBvcnQvZGF0YWJhc2UiXX0= )
1116
1217### Option 1: npm (Recommended)
@@ -15,9 +20,16 @@ A Model Context Protocol (MCP) server that provides comprehensive PostgreSQL dat
1520npm install -g @henkey/postgres-mcp-server
1621
1722# Or run directly with npx (no installation)
23+ # Use env var for connection string (optional)
24+ export POSTGRES_CONNECTION_STRING=" postgresql://user:pass@localhost:5432/db"
25+ npx @henkey/postgres-mcp-server
26+ # Or pass directly:
1827npx @henkey/postgres-mcp-server --connection-string " postgresql://user:pass@localhost:5432/db"
1928```
2029
30+ # Verify installation
31+ npx @henkey/postgres-mcp-server --help
32+
2133Add to your MCP client configuration:
2234``` json
2335{
@@ -38,7 +50,40 @@ Add to your MCP client configuration:
3850npx -y @smithery/cli install @HenkDz/postgresql-mcp-server --client claude
3951```
4052
41- ### Option 3: Manual Installation (Development)
53+ ### Option 3: Docker (Recommended for Production)
54+ ``` bash
55+ # Build the Docker image
56+ docker build -t postgres-mcp-server .
57+
58+ # Run with environment variable
59+ docker run -i --rm \
60+ -e POSTGRES_CONNECTION_STRING=" postgresql://user:password@host:port/database" \
61+ postgres-mcp-server
62+ ```
63+
64+ Add to your MCP client configuration:
65+ ``` json
66+ {
67+ "mcpServers" : {
68+ "postgresql-mcp" : {
69+ "command" : " docker" ,
70+ "args" : [
71+ " run" ,
72+ " -i" ,
73+ " --rm" ,
74+ " henkey/postgres-mcp:latest" ,
75+ " -e" ,
76+ " POSTGRES_CONNECTION_STRING"
77+ ],
78+ "env" : {
79+ "POSTGRES_CONNECTION_STRING" : " postgresql://user:password@host:port/database"
80+ }
81+ }
82+ }
83+ }
84+ ```
85+
86+ ### Option 4: Manual Installation (Development)
4287``` bash
4388git clone < repository-url>
4489cd postgresql-mcp-server
@@ -131,6 +176,21 @@ Add to your MCP client configuration:
131176 " minDuration" : 100
132177}
133178
179+ // Execute a parameterized SELECT query
180+ {
181+ " operation" : " select" ,
182+ " query" : " SELECT * FROM users WHERE id = $1" ,
183+ " parameters" : [1 ]
184+ }
185+
186+ // Perform an INSERT mutation
187+ {
188+ " operation" : " insert" ,
189+ " table" : " products" ,
190+ " data" : {" name" : " New Product" , " price" : 99.99 },
191+ " returning" : " id"
192+ }
193+
134194// Manage database object comments
135195{
136196 " operation" : " set" ,
@@ -169,9 +229,90 @@ For additional information, see the [`docs/`](./docs/) folder:
169229✅ ** Security focused** - SQL injection prevention, parameterized queries
170230✅ ** Robust architecture** - Connection pooling, comprehensive error handling
171231
232+ ## Docker Usage
233+
234+ The PostgreSQL MCP Server is fully Docker-compatible and can be used in production environments.
235+
236+ ### Building the Image
237+ ``` bash
238+ # Build locally
239+ docker build -t postgres-mcp-server .
240+
241+ # Or pull from Docker Hub
242+ docker pull henkey/postgres-mcp:latest
243+ ```
244+
245+ ### Running with Environment Variables
246+ ``` bash
247+ # Basic usage (using Docker Hub image)
248+ docker run -i --rm \
249+ -e POSTGRES_CONNECTION_STRING=" postgresql://user:password@host:port/database" \
250+ henkey/postgres-mcp:latest
251+
252+ # Or with locally built image
253+ docker run -i --rm \
254+ -e POSTGRES_CONNECTION_STRING=" postgresql://user:password@host:port/database" \
255+ postgres-mcp-server
256+
257+ # With tools configuration
258+ docker run -i --rm \
259+ -e POSTGRES_CONNECTION_STRING=" postgresql://user:password@host:port/database" \
260+ -e POSTGRES_TOOLS_CONFIG=" /app/config/tools.json" \
261+ -v /path/to/config:/app/config \
262+ postgres-mcp-server
263+ ```
264+
265+ ### Docker Compose Example
266+ ``` yaml
267+ version : ' 3.8'
268+ services :
269+ postgres-mcp :
270+ build : .
271+ environment :
272+ - POSTGRES_CONNECTION_STRING=postgresql://user:password@postgres:5432/database
273+ depends_on :
274+ - postgres
275+ stdin_open : true
276+ tty : true
277+
278+ postgres :
279+ image : postgres:15
280+ environment :
281+ - POSTGRES_DB=database
282+ - POSTGRES_USER=user
283+ - POSTGRES_PASSWORD=password
284+ ports :
285+ - " 5432:5432"
286+ ` ` `
287+
288+ ### MCP Client Configuration
289+ For use with MCP clients like Cursor or Claude Desktop:
290+
291+ ` ` ` json
292+ {
293+ " mcpServers " : {
294+ " postgresql-mcp " : {
295+ " command " : " docker" ,
296+ " args " : [
297+ " run" ,
298+ " -i" ,
299+ " --rm" ,
300+ " henkey/postgres-mcp:latest" ,
301+ " -e" ,
302+ " POSTGRES_CONNECTION_STRING"
303+ ],
304+ " env " : {
305+ " POSTGRES_CONNECTION_STRING " : " postgresql://user:password@host:port/database"
306+ }
307+ }
308+ }
309+ }
310+ ```
311+
172312## Prerequisites
173313
174- - Node.js ≥ 18.0.0
314+ - Node.js ≥ 18.0.0 (for local development)
315+ - Docker (for containerized deployment)
175316- PostgreSQL server access
176317- Valid connection credentials
177318
0 commit comments