Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default (server instance)
✓ import server from 'mcp-postgres'
✗ const server = require('mcp-postgres')
ESM-only package; no CommonJS support. The server starts automatically on import when run as a CLI.
PostgresServer
✓ import { PostgresServer } from 'mcp-postgres'
✗ import { PostgresServer } from 'mcp-postgres'
Class-based export for programmatic usage
Config
✓ import type { Config } from 'mcp-postgres'
TypeScript type for configuration object
Programmatic setup of MCP PostgreSQL server with environment variables, connecting via stdio transport.
import { PostgresServer } from 'mcp-postgres';
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
// The package is typically run as a CLI tool.
// To run programmatically:
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
const server = new PostgresServer({
host: process.env.DB_HOST ?? 'localhost',
port: parseInt(process.env.DB_PORT ?? '5432'),
user: process.env.DB_USER ?? 'postgres',
password: process.env.DB_PASSWORD ?? '',
database: process.env.DB_NAME ?? 'postgres',
sslmode: process.env.DB_SSL_MODE ?? 'disable'
});
const transport = new StdioServerTransport();
await server.connect(transport);
console.error('MCP PostgreSQL Server running on stdio');
mcp-postgres --version
Errors
Common errors & fixes
(node:xxx) [PG] Deprecation Warning: pg@9.0 will drop support for concurrent queries on a single client. Use a pool instead.
Using Promise.all() to run multiple queries on a single pg.Client concurrently.
fixUpdate to mcp-postgres@1.2.1 or later, which sequences queries.
Error: Invalid input syntax for type ...
... at column '...'
SQL injection attempt or malformed column name (unquoted special characters).
fixUpgrade to >=1.2.0 which properly quotes identifiers.
Error: getaddrinfo ENOTFOUND ...
PostgreSQL hostname not resolvable or incorrect.
fixCheck DB_HOST or DATABASE_URL value. Ensure the host is reachable and resolveable.
Audit
Dependencies
pgrequiredPostgreSQL client driver for Node.js
@modelcontextprotocol/sdkrequiredMCP SDK for server implementation