MCP ExplorerExplorer

Mcp Postgres

@yuefeng-cnon 10 months ago
1 MIT
FreeCommunity
AI Systems
MCP-Postgres is a Node.js project for configuring PostgreSQL servers.

Overview

What is Mcp Postgres

mcp-postgres is a server designed to facilitate interactions with PostgreSQL databases through AI agents, enabling developers to leverage AI capabilities in database management and queries.

Use cases

Use cases for mcp-postgres include automating database queries, enhancing database management with AI, and providing developers with intelligent assistance while working with PostgreSQL.

How to use

To use mcp-postgres, install the latest Node.js, clone the repository, and run ‘npm i && npm run build’. Configure the server settings in your IDE (e.g., VScode or Cursor) by specifying the command and environment variables in the respective configuration files.

Key features

Key features of mcp-postgres include easy integration with IDEs, support for environment variable configuration, and the ability to switch to ‘Agent’ mode for AI-assisted queries.

Where to use

mcp-postgres can be used in software development environments where PostgreSQL databases are utilized, particularly in projects that benefit from AI-driven database interactions.

Content

Usage

  • Install latest Node.js.

  • Clone this repository.

  • Run command: npm i && npm run build.

  • Add configuration in you IDE or other supported AI agents.

    • In VScode:

      Configuration file path: .vscode/mcp.json

      {
          "servers": {
              // you will see service start button here.
              "postgres": {
                  "command": "node",
                  "args": [
                      "/Users/xxx/project/personal/mcp-postgre/build/index.js" // the absolute path to your compiled JS file
                  ],
                  "env": {
                      "POSTGRES_HOST": "localhost",
                      "POSTGRES_PORT": "5432",
                      "POSTGRES_DB": "postgres",
                      "POSTGRES_USER": "postgres",
                      "POSTGRES_PASSWORD": "123456",
                  }
              }
          }
      }
      
    • In Cursor

      You can also add configuration by UI in Cursor Settings -> MCP, or configuration file path: .cursor/mcp.json.

      {
        "mcpServers": {
          "postgres": {
            "command": "node",
            "args": ["/Users/xxx/project/personal/mcp-postgre/build/index.js"], // the absolute path to your compiled JS file
            "env": {
              "POSTGRES_HOST": "localhost",
              "POSTGRES_PORT": "5432",
              "POSTGRES_DB": "postgres",
              "POSTGRES_USER": "postgres",
              "POSTGRES_PASSWORD": "123456"
            }
          }
        }
      }
      
  • And then, you can switch your copilot to Agent mode and ask som questions in AI chat window.

    • If you are using Cursor, ask questions directly.
    • If you are using VScode, start server manuraly first in mcp.json. You can also use Command + Shift + P, and type MCP into input box to run some commands, including start and stop MCP servers.

    image

To avoid strange problems, make sure you are using the latest VScode and Cursor.

See more details in https://modelcontextprotocol.io/quickstart/server

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers