AP

ahmedmustahid/postgres-mcp-server

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

31 stars 16 forks 품질 56 트렌드 0

ahmedmustahid/postgres-mcp-server는 MCP 서버 후보자는 https://github.com/ahmedmustahid/postgres-mcp-server.]에서 수입했습니다

개요

ahmedmustahid/postgres-mcp-server는 MCP 서버 후보자는 https://github.com/ahmedmustahid/postgres-mcp-server.]에서 수입했습니다

개요(AI 번역)

PostgreSQL 데이터베이스와 상호 작용하는 HTTP 및 Stdio 전송을 제공하는 모델 Context Protocol (MCP) 서버. 이 서버는 다른 환경에서 유연한 통합을 허용하는 전송 방법을 통해 데이터베이스 리소스 및 도구를 노출합니다.

특징

  • Dual Transport Support: HTTP(StreamableHTTPServerTransport) 및 Stdio(StdioServerTransport) 모두
  • Database Resources: 테이블 및 검색 스키마 정보 -Query Tool: 읽기 전용 SQL 쿼리 실행
  • Stateful Sessions: HTTP 수송 지원 세션 관리
  • Docker Support: 수송을 위한 컨테이너화된 배치 -Production Ready: 화려한 폐쇄, 오류 처리 및 로깅

빠른 시작

환경 설정

데이터베이스 자격은 다음과 같이 통과해야합니다.

  1. 어떤 환경 변수

  2. 또는 작업 디렉토리에서 (npx] 명령이 실행될 경우): .env 파일 생성 (패키지 사용 dotenv 패키지)

런 사용 npx

  1. 여기에서 node.js 및 npm 다운로드

  2. 포장을 실행하십시오. 기본적으로 포트 3000에서 streamable http를 실행합니다.

  3. stdio 수송을 위해:

환경 설정

Copy 환경 템플릿

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.

README

원문 README의 일부입니다. 원문 보기.

MCP PostgreSQL Server (Stateful and Dual Transport)

A Model Context Protocol (MCP) server that provides both HTTP and Stdio transports for interacting with PostgreSQL databases. This server exposes database resources and tools through both transport methods, allowing for flexible integration in different environments.

Features

  • Dual Transport Support: Both HTTP (StreamableHTTPServerTransport) and Stdio (StdioServerTransport)
  • Database Resources: List tables and retrieve schema information
  • Query Tool: Execute read-only SQL queries
  • Stateful Sessions: HTTP transport supports session management
  • Docker Support: Containerized deployments for both transports
  • Production Ready: Graceful shutdown, error handling, and logging

Quick Start

Environment Setup

The database credentials must be passed as:

  1. Either environment variables
# PostgreSQL Database Connection String
export POSTGRES_URL=your_connection_string

# PostgreSQL Database Configuration if POSTGRES_URL is not provided
export POSTGRES_USERNAME=your_username
export POSTGRES_PASSWORD=your_password
export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432 # this is the default
export POSTGRES_DATABASE=your_database

# HTTP Server Configuration
# Following are the default values
export PORT=3000
export HOST=0.0.0.0

# CORS Configuration (comma-separated list of allowed origins)
# Following are the default values
export CORS_ORIGIN=http://localhost:8080,http://localhost:3000

# Environment
# Following are the default values
export NODE_ENV=development

  1. Or in the working directory (directory where npx command will be run): create a .env file (the package uses dotenv package)
# .env.example
# PostgreSQL Database Configuration
POSTGRES_USERNAME=your_username
POSTGRES_PASSWORD=your_password
POSTGRES_HOST=localhost
POSTGRES_DATABASE=your_database

# HTTP Server Configuration
PORT=3000
HOST=0.0.0.0

# CORS Configuration (comma-separated list of allowed origins)
CORS_ORIGIN=http://localhost:8080,http://localhost:3000

# Environment
NODE_ENV=development

Run using npx

  1. Download node.js and npm from here
  2. Run the package. By default, it will run streamable http on port 3000:
npx @ahmedmustahid/postgres-mcp-server
# or npx @ahmedmustahid/postgres-mcp-server --port 3000 --verbose
  1. For stdio transport:
npx @ahmedmustahid/postgres-mcp-server stdio
# npx @ahmedmustahid/postgres-mcp-server stdio --verbose

Environment Setup

Copy environment template

cp .env.example .env

Edit your database credentials

nano .env

Podman(or Docker) Usage

  1. Install podman from here
  2. Install uv from here
  3. Install podman compose package: uv add podman-compose (or uv sync to sync packages in pyproject.toml)
GitHub에서 전체 README 보기

설치

npx @ahmedmustahid/postgres-mcp-server stdio
MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →

설정

{ "mcpServers": { "postgres-mcp-server": { "command": "npx", "args": [ "@ahmedmustahid/postgres-mcp-server", "stdio" ], "env": { "POSTGRES_USERNAME": "your-username", "POSTGRES_PASSWORD": "your-password", "POSTGRES_HOST": "hostname", "POSTGRES_DATABASE": "database-name" } } } }