- Home
- MCP servers
- PostgreSQL
PostgreSQL
- javascript
0
GitHub Stars
javascript
Language
7 months ago
First Indexed
3 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": {
"sbfulfil-pg-mcp": {
"command": "node",
"args": [
"/absolute/path/to/pg_mcp/src/index.js"
],
"env": {
"DB_HOST": "localhost",
"DB_NAME": "your_database_name",
"DB_PORT": "5432",
"DB_USER": "your_username",
"DB_PASSWORD": "your_password"
}
}
}
}You can explore your PostgreSQL database structure through a dedicated MCP server that exposes schemas, tables, columns, keys, and relationships. This server lets Cursor and other MCP-compatible tools inspect and navigate your database metadata in a structured, queryable way, without exposing actual data.
How to use
Connect your MCP client to the PostgreSQL MCP Server to start exploring your database. You will be able to list schemas and tables, describe individual tables to see columns and data types, inspect foreign key relationships, and view indexes. Use the client’s provided tools to request metadata, and use the results to understand how your database is organized and how tables relate to one another.
How to install
Prerequisites you need before installation are Node.js 18 or newer, a PostgreSQL database (local or remote), and npm or yarn as a package manager.
# Install dependencies
npm install
# Copy example environment and edit with your database connection details
cp config.env.example .env
Configure your database connection by editing the .env file with your PostgreSQL credentials. Typical variables include the host, port, database name, user, and password.
DB_HOST=localhost
DB_PORT=5432
DB_NAME=your_database_name
DB_USER=your_username
DB_PASSWORD=your_password
Start the MCP server to make it available to clients.
npm start
Configuration and usage notes
The server uses environment variables to connect to PostgreSQL. You can run the server locally by supplying these variables in a .env file or by exporting them in your shell before starting the service.
Security and best practices
This server only reads database metadata and does not expose actual table data. Use parameterized queries where applicable and restrict access to the MCP server to trusted clients. Store credentials securely and avoid sharing .env files publicly.
Troubleshooting
If the server cannot connect to the database, verify that your credentials in the environment file are correct and that PostgreSQL accepts connections from your host. If the MCP client cannot load the server, ensure the command path to the MCP entry point is correct and that Node.js is installed.
Notes
You can configure MCP clients to connect to this server through either a local stdio command or a remote HTTP endpoint, depending on your deployment needs.
Available tools
list_tables
Lists all tables in a specified schema (default is public)
describe_table
Provides detailed column information for a specific table
get_table_relationships
Shows foreign key relationships for a table
list_schemas
Lists all available schemas in the database
get_indexes
Shows indexes for a specific table