- Home
- MCP servers
- PostgreSQL
PostgreSQL
- javascript
27
GitHub Stars
javascript
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"vignesh-codes-ai-agents-mcp-pg": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"mcp/postgres",
"postgresql://username:password@host.docker.internal:5432/mydatabase"
]
}
}
}You can use this MCP server to access and manipulate PostgreSQL databases through a model-driven interface. It enables you to inspect schemas, run read-only queries, and perform CRUD operations like creating tables, inserting, updating, and deleting rows, as well as dropping tables. This makes it easier for language models to interact with your database in a structured, safe way.
How to use
Connect to the PostgreSQL MCP Server from your MCP client and issue high-level actions that map to SQL operations. You can query the database to inspect schemas and run read-only SELECT statements. You can also create tables, insert new rows, update existing rows based on conditions, delete specific rows, and drop tables when needed. The server returns results in a structured format that your client can display or further process.
How to install
Prerequisites you need before installing the MCP server:
- Docker installed on your machine
- Claude Desktop installed on your machine
Then follow these concrete steps to set up the server and connect your MCP client.
1. Install Docker and Claude Desktop
2. Clone the repository
3. Run PG Docker container
4. Build the mcp server
5. Open Claude Desktop and connect to the MCP server by updating the mcpServers field in claude_desktop_config.json
MCP server configuration for Claude Desktop
To connect via Claude Desktop, use the following MCP server configuration. This config runs the MCP server in a Docker container and provides the PostgreSQL connection URL.
{
"mcpServers": {
"postgres": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"mcp/postgres",
"postgresql://username:password@host.docker.internal:5432/mydatabase"
]
}
}
}
Features and capabilities
The server provides a core read-only query capability for safe data inspection and a set of write operations to manage your schema and data. The following functionalities are supported:
- Query: execute read-only SQL queries in a read-only transaction
- Create Tables: dynamically create new tables with a specified name and columns
- Insert Entries: add new rows to a specified table
- Update Entries: update existing rows based on given conditions
- Delete Entries: remove rows that match given conditions
- Drop Tables: remove tables from the database
Schema information and sample data
The server can expose table schemas and sample data to help you understand the structure of your database. You can inspect the schema for each table and run queries to verify data integrity.
Available tools
query
Execute read-only SQL queries against the connected database.
Create Tables
Create new tables by specifying a table name and a set of column definitions.
Insert Entries
Insert new rows into a specified table.
Update Entries
Update existing rows in a table based on given conditions.
Delete Entries
Delete rows that match specified conditions in a table.
Drop Tables
Drop existing tables from the database.
Table Schemas
Provide JSON schema information for each table discovered from database metadata.