MCP PostgreSQL Server
@antonorlov
About MCP PostgreSQL Server
MCP PostgreSQL Server
Config
Add this server to your MCP-compatible client using the configuration below.
{
"mcpServers": {
"postgres": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-postgres-server"
],
"env": {
"PG_HOST": "your_host",
"PG_PORT": "5432",
"PG_USER": "your_user",
"PG_PASSWORD": "your_password",
"PG_DATABASE": "your_database"
}
}
}
}Tools
6Connect to PostgreSQL database. NOTE: Default connection exists - only use when requested or if other commands fail
Execute a SELECT query
Execute an INSERT, UPDATE, or DELETE query
List all schemas in the database
List tables in the database
Get table structure
Overview
What is MCP PostgreSQL Server?
A Model Context Protocol server that enables AI models to interact with PostgreSQL databases through a standardized interface. It provides database operations such as connecting, querying, executing statements, and listing schemas and tables.
How to use MCP PostgreSQL Server?
Install via npm (npm install mcp-postgres-server) or run directly with npx mcp-postgres-server. Configure environment variables for database credentials (host, port, user, password, database). Then use the available MCP tools: connect_db, query, execute, list_schemas, list_tables, describe_table.
Key features of MCP PostgreSQL Server
- Secure connection handling with automatic cleanup
- Prepared statement support to prevent SQL injection
- Supports PostgreSQL-style ($1, $2) and MySQL-style (?) parameter placeholders
- Comprehensive error handling with detailed messages
- TypeScript support
- Automatic connection management
- Multi-schema support for database operations
Use cases of MCP PostgreSQL Server
- Querying data from PostgreSQL tables using SELECT statements
- Executing INSERT, UPDATE, and DELETE operations securely
- Exploring database structure by listing schemas, tables, and describing columns
- Integrating AI models with existing PostgreSQL databases for data retrieval
FAQ from MCP PostgreSQL Server
How does the server prevent SQL injection?
It uses prepared statements for all queries, securely handling parameterized inputs to avoid injection.
What parameter placeholder styles are supported?
Both PostgreSQL-style ($1, $2) and MySQL
Frequently asked questions
How does the server prevent SQL injection?
It uses prepared statements for all queries, securely handling parameterized inputs to avoid injection.
What parameter placeholder styles are supported?
Both PostgreSQL-style ($1, $2) and MySQL
Basic information
More Databases MCP servers
MCP Alchemy
runekaagaardA MCP (model context protocol) server that gives the LLM access to and knowledge about relational databases like SQLite, Postgresql, MySQL & MariaDB, Oracle, and MS-SQL.
Neon MCP Server
neondatabase-labsMCP server for interacting with Neon Management API and databases
Postgres Mcp
crystaldbaPostgres MCP Pro provides configurable read/write access and performance analysis for you and your AI agents.

Redis
modelcontextprotocolModel Context Protocol Servers

nuzur
nuzur is a model-first database platform for MySQL and PostgreSQL. The MCP server lets any AI assistant or agent (Claude, Cursor, Gemini, or anything else that speaks MCP) design your schema, query your data, generate mi
Comments