PostgreSQL MCP Server

by hthuong09
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Enables interaction with PostgreSQL databases, allowing users to list tables, retrieve schemas, and execute read-only SQL queries against PostgreSQL databases.

MCP PostgreSQL 서버

PostgreSQL 데이터베이스와 상호 작용하는 모델 컨텍스트 프로토콜 서버입니다. PostgreSQL 데이터베이스를 쿼리하고 스키마를 검사할 수 있는 읽기 전용 인터페이스를 제공합니다.

설치

지엑스피1

구성

서버는 여러 가지 방법으로 구성할 수 있으며, 우선순위 순으로 나열되어 있습니다.

  1. 환경 변수
    • POSTGRES_URL : 전체 데이터베이스 URL(예: postgres://user:pass@host:5432/dbname )
    • 개별 연결 매개변수:
      • POSTGRES_HOST : 데이터베이스 호스트
      • POSTGRES_PORT : 데이터베이스 포트(기본값: 5432)
      • POSTGRES_DB : 데이터베이스 이름
      • POSTGRES_USER : 데이터베이스 사용자
      • POSTGRES_PASSWORD : 데이터베이스 비밀번호
      • POSTGRES_SSL : SSL 모드 활성화(활성화하려면 'true'로 설정)
      • POSTGRES_SCHEMA : 데이터베이스 스키마(기본값: 'public')
    • 추가 구성:
      • DOTENV_PATH : .env 파일에 대한 사용자 지정 경로
      • DEBUG_MCP : 디버그 로깅을 활성화합니다(활성화하려면 'true'로 설정)
  2. 명령줄
    npx @hthuong09/postgres-mcp "postgres://user:pass@host:5432/dbname"

자원

  • 테이블 스키마: 데이터베이스의 각 테이블은 리소스로 노출됩니다.
  • 리소스 URI 형식: postgres://user@host/dbname/table_name/schema
  • 응답 형식: 열 정의(이름 및 데이터 유형)의 JSON 배열

사용 예

  1. 환경 변수 사용:
    export POSTGRES_HOST=localhost export POSTGRES_DB=mydb export POSTGRES_USER=myuser export POSTGRES_PASSWORD=mypassword npx @hthuong09/postgres-mcp
  2. 연결 URL 사용:
    npx @hthuong09/postgres-mcp "postgres://myuser:mypassword@localhost:5432/mydb"
  3. SSL과 함께 환경 변수 사용:
    export POSTGRES_HOST=db.example.com export POSTGRES_DB=mydb export POSTGRES_USER=myuser export POSTGRES_PASSWORD=mypassword export POSTGRES_SSL=true npx @hthuong09/postgres-mcp
  4. 사용자 지정 .env 파일 위치 사용:
    DOTENV_PATH=/path/to/.env npx @hthuong09/postgres-mcp

보안 고려 사항

  • 데이터베이스 자격 증명은 안전하게 보관해야 합니다.
  • 프로세스 목록에 자격 증명이 노출되는 것을 방지하려면 프로덕션에서 명령줄 인수 대신 환경 변수나 .env 파일을 사용하세요.
  • 프로덕션 환경에서 SSL 사용을 고려하세요
  • 서버는 안전을 위해 읽기 전용 거래만 허용합니다.
  • 비밀번호는 리소스 URI에서 자동으로 제거됩니다.

개발

서버를 로컬로 빌드하려면:

npm install npm run build

개발 중에 감시 모드로 실행하려면:

npm run watch

디버깅

디버그 로깅을 활성화하려면 DEBUG_MCP=true 설정하세요. 로그는 다음 위치에 기록됩니다.

  • Unix/macOS: /tmp/postgres-mcp-debug.json
  • 윈도우: %TEMP%/postgres-mcp-debug.json

특허

MIT

-
security - not tested
F
license - not found
-
quality - not tested

PostgreSQL 데이터베이스와 상호작용하여 테이블 나열, 스키마 검색, 읽기 전용 SQL 쿼리 실행 등을 가능하게 하는 모델 컨텍스트 프로토콜 서버입니다.

  1. Installation
    1. Configuration
      1. Resources
    2. Usage Examples
      1. Security Considerations
        1. Development
          1. Debugging
            1. License
              ID: c92j003vx0