Cover image
Try Now
2025-04-01

用于与PostgreSQL产品数据库进行交互的MCP服务器。

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

PostgreSQL Products MCP Server

This is a Model Context Protocol (MCP) server designed to interact with a PostgreSQL database containing product information. It allows clients (like AI assistants) to query the database using SQL.

Prerequisites

  • Node.js (v18 or later recommended)
  • npm or yarn
  • Access to a PostgreSQL database with the products schema.

Installation

  1. Clone this repository (or download the source code):
    git clone https://github.com/michael7736/postgres-mcp-server.git
    cd postgres-mcp-server
    
  2. Install dependencies:
    npm install
    # or
    yarn install
    

Building

Compile the TypeScript code to JavaScript:

npm run build
# or
yarn build

This will create the executable file in the build/ directory (build/index.js).

Configuration

This server requires PostgreSQL connection details to be provided via environment variables when it's configured in your MCP client settings (e.g., cline_mcp_settings.json or claude_desktop_config.json).

The required environment variables are:

  • PGHOST: Hostname of the PostgreSQL server.
  • PGPORT: Port number of the PostgreSQL server (default: 5432).
  • PGUSER: Username for the database connection.
  • PGPASSWORD: Password for the database connection.
  • PGDATABASE: Name of the database to connect to.

Example MCP Settings Configuration:

{
  "mcpServers": {
    "postgres-products": {
      "command": "node",
      "args": ["/path/to/your/postgres-mcp-server/build/index.js"],
      "env": {
        "PGHOST": "your_db_host",
        "PGPORT": "5432",
        "PGUSER": "your_db_user",
        "PGPASSWORD": "your_db_password",
        "PGDATABASE": "your_db_name"
      },
      "disabled": false, // Ensure it's enabled
      "autoApprove": [] // Configure auto-approval if needed
    }
    // ... other servers
  }
}

Replace /path/to/your/postgres-mcp-server/build/index.js with the actual path to the built server file on your system, and fill in your specific database credentials in the env section.

Usage

Once configured and running via your MCP client, this server provides the following tool:

run_sql_query

Executes a read-only SQL query (SELECT statements only) against the configured products database.

Input Schema:

{
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "description": "The SQL SELECT query to execute."
    }
  },
  "required": ["query"]
}

Example Tool Call:

<use_mcp_tool>
  <server_name>postgres-products</server_name>
  <tool_name>run_sql_query</tool_name>
  <arguments>
  {
    "query": "SELECT product_name, stock_quantity FROM products WHERE category = 'Electronics';"
  }
  </arguments>
</use_mcp_tool>

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Lists Tailwind CSS classes in monospaced font

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • Yasir Eryilmaz
  • AI scriptwriting assistant for short, engaging video content.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • HiveNexus
  • 一个适用于中小型团队的AI聊天机器人,支持DeepSeek,Open AI,Claude和Gemini等车型。 专为中小团队设计的ai聊天应用,支持deepSeek,打开ai,claude,双子座等模型。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

    Reviews

    3 (1)
    Avatar
    user_1MIGxsUF
    2025-04-16

    I have been using MCP SERVER by amit-singh-mobcoder and it has been a game changer for my projects. The integration is seamless, and the welcome information is incredibly helpful for first-time users. Highly recommend checking out the details at the provided link for more insights into its capabilities.