About postgres-mcp-server
postgres-mcp-server is an experimental MCP server that lets an LLM interact with a local PostgreSQL database. Its README warns against use on real databases, particularly when running write queries.
Key features
- 01Connect an LLM to a local PostgreSQL database
- 02Configure database name, user, password, and schema
- 03Run as an npm-based MCP server
Use cases
- 01Experiment with LLM access to a local database
- 02Test database interactions in a non-production environment
MCP support
It exposes PostgreSQL database interaction to an LLM through the Model Context Protocol. The project is experimental and warns against use with real databases.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEpostgres-mcp-server
This is a PostgresSQL Model Context Protocol server to let your LLM interact with your (local) database. Warning: This is still experimental, so DO NOT use this on real database and be careful with write queries!
Prerequisites
- have nodeJS installed
- run
npm installto install the project dependencies - have the following environment variables set:
DATABASE_NAME="your_database_name"
DATABASE_USER="your_database_user"
DATABASE_PASSWORD="your_database_password"
DATABASE_SCHEMA_name="your_database_schema_name" # i.e. standard this is usually `public`
Easy config for in your VSCODE settings.json:
{
"chat.mcp.discovery.enabled": true,
"mcp": {
"postgresql-database": {
"command": "npm",
"type": "stdio",
"args": ["start", "--prefix", "/path/to/code/postgres-mcp-server"],
"env": {
"CUSTOM_INSTRUCTIONS": "The databaseName is specific for the git branch we are on. It always has the same structure: jira_xxxxx, where the jira_xxxxx stands for the Jira ticket number. This Jira ticket number we always use at the start of a git branch. Hence, you should be able to take this from the current branch and create the databaseName from it",
"DATABASE_NAME": "my-database-name",
"DATABASE_USER": "my-user",
"DATABASE_PASSWORD": "my-password",
"DATABASE_SCHEMA_NAME": "public"
}
}
}
}
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.