PostgreSQL MCP server
2026년 11월 9일 커밋AI 어시스턴트가 PostgreSQL 데이터베이스의 스키마를 탐색하고, 데이터 프로파일링을 수행하며, 안전하게 읽기/쓰기 작업을 할 수 있도록 구조화된 액세스를 제공합니다.
다른 이름 ralscha/postgresql-mcp
- 스타
- 0
- Tools
- 24
- 다운로드, 30일
- —
- 최신 버전
- —
- 마지막 커밋
- 2026년 11월 9일
- 라이선스
- MIT
PostgreSQL MCP란?
PostgreSQL은(는) MCP server입니다. AI 어시스턴트가 PostgreSQL 데이터베이스의 스키마를 탐색하고, 데이터 프로파일링을 수행하며, 안전하게 읽기/쓰기 작업을 할 수 있도록 구조화된 액세스를 제공합니다. 24개 도구를 제공합니다. 예: search_schema, describe_table, list_table.
프로젝트 README에서 생성된 요약
PostgreSQL MCP server 정보
이 서버는 AI 어시스턴트를 PostgreSQL 데이터베이스에 연결하여 스키마 탐색 및 데이터 관리를 가능하게 합니다. 개발자가 단순한 테이블 설명부터 복잡한 관계 분석 및 쿼리 성능 검사에 이르기까지 다양한 작업을 수행할 수 있도록 구조화된 인터페이스를 제공합니다. 로컬 stdio 통신과 원격 HTTP 전송을 모두 지원하여 다양한 클라이언트 환경에 유연하게 통합할 수 있습니다.
보안은 POSTGRESQL_ACCESS_LEVEL 변수로 제어되는 계층형 액세스 모델을 통해 관리됩니다. 사용자는 스키마 검색 및 데이터 프로파일링을 위한 READONLY 모드, 행 삽입 또는 업데이트를 위한 DML-RW 모드, 테이블 생성 및 삭제를 위한 DDL-RW 모드로 동작할 수 있습니다. 실수로 인한 데이터 손실을 방지하기 위해, POSTGRESQL_REQUIRE_CONFIRMATION이 활성화되면 쓰기 실행 전 영향을 받는 행을 보여주는 변경 확인 시스템이 작동합니다.
기술적 특징으로는 JSON 실행 계획을 통한 쿼리 설명, jsonb 데이터의 자동 디코딩, 클라이언트 과부하 방지를 위한 권한 있는 행 제한 기능이 있습니다. 개발자는 환경 변수를 통해 host, port, SSL mode와 같은 연결 세부 정보를 구성할 수 있으며, bearer token을 사용하여 HTTP 엔드포인트를 보호할 수 있습니다.
활용 사례
- 1데이터베이스 스키마 구조 분석AI에게 특정 테이블을 찾거나 데이터베이스 내의 컬럼 및 키를 설명하도록 요청합니다.
- 2느린 SQL 쿼리 최적화특정 쿼리의 성능이 낮은 원인을 파악하기 위해 실행 계획을 요청합니다.
- 3테이블 통계 프로파일링특정 테이블의 행 수, null 값, 데이터 분포에 대한 요약을 가져옵니다.
프로젝트의 README를 바탕으로 작성되었습니다. 모든 활용 사례는 해당 내용의 인용문과 대조하여 확인합니다.
PostgreSQL MCP 도구 24
README에서 감지됨search_schemadescribe_tablelist_tablelist_databaseslist_environmentsprofile_tableinspect_relationshipsinspect_dependenciesexplain_queryread_datatest_connectionvalidate_environment_config
| search_schema | — | |
| describe_table | — | |
| list_table | — | |
| list_databases | — | |
| list_environments | — | |
| profile_table | — | |
| inspect_relationships | — | |
| inspect_dependencies | — | |
| explain_query | — | |
| read_data | — | |
| test_connection | — | |
| validate_environment_config | — |
도구 24개 모두 보기도구 수 줄이기
list_schemaslist_extensionslist_viewslist_triggersshow_create_tabletable_sizeinsert_dataupdate_datadelete_datacreate_tablecreate_indexdrop_table
| list_schemas | — | |
| list_extensions | — | |
| list_views | — | |
| list_triggers | — | |
| show_create_table | — | |
| table_size | — | |
| insert_data | — | |
| update_data | — | |
| delete_data | — | |
| create_table | — | |
| create_index | — | |
| drop_table | — |
구성
POSTGRESQL_ACCESS_LEVELPOSTGRESQL_DATABASEPOSTGRESQL_HOSTPOSTGRESQL_HTTP_ADDRPOSTGRESQL_HTTP_PATHPOSTGRESQL_PASSWORDPOSTGRESQL_SSLMODEPOSTGRESQL_TRANSPORTPOSTGRESQL_USER
| 이름 | 설명 | 유형 |
|---|---|---|
| POSTGRESQL_ACCESS_LEVEL | — | |
| POSTGRESQL_DATABASE | — | |
| POSTGRESQL_HOST | — | |
| POSTGRESQL_HTTP_ADDR | — | |
| POSTGRESQL_HTTP_PATH | — | |
| POSTGRESQL_PASSWORD | — | |
| POSTGRESQL_SSLMODE | — | |
| POSTGRESQL_TRANSPORT | — | |
| POSTGRESQL_USER | — |
자동 검사
2026년 11월 14일에 실행됨전체 보고서 →아직 인증되지 않았습니다. 서버는 80점 이상의 점수, 심각한 결함 없음, 그리고 검사에 충분한 데이터를 갖추어야 합니다. 검사 방식 · 점수를 높이기 위해 수정할 항목
- 소스 저장소 연결 및 접근 가능ralscha/postgresql-mcp is public and reachablegithub.com/ralscha/postgresql-mcp ↗통과
- 패키지가 이 저장소를 소스로 명시검사되지 않음
- 빌드 출처(Sigstore 증명)검사되지 않음
- 오픈 소스 라이선스 (OSI)MITspdx.org/licenses/MIT.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit or release 2026-11-09github.com/ralscha/postgresql-mcp ↗통과
- OpenSSF Scorecard검사되지 않음
- 패키지 이름이 인기 패키지와 유사하지 않음검사되지 않음
- 패키지 및 해당 종속성에 중요한 보안 권고 없음검사되지 않음
- 모델에 대한 숨겨진 지침 없음24 tool descriptions and the README read; no override phrases, credential paths or hidden characters통과
- 파괴적인 도구에 라벨 표시됨검사되지 않음
- 원격 엔드포인트가 MCP 핸드셰이크에 응답검사되지 않음
README
GitHub에서 보기postgresql-mcp
An MCP (Model Context Protocol) server that gives AI assistants structured, read-optimized access to PostgreSQL databases. It exposes schema exploration, data profiling, relationship analysis, query explanation, and safe read/write operations through a standardized MCP interface.
Features
- 24 MCP tools covering schema search, table description, data profiling, relationship/dependency inspection, query explanation, connection testing, schema/extension/view/trigger listing, CREATE TABLE DDL generation, table sizing, and tiered write access
- Tiered access model via
POSTGRESQL_ACCESS_LEVEL:READONLY(default),DML-RW(adds insert/update/delete),DDL-RW(adds create/drop table/index) - SQL-safe design with identifier validation, exact named-parameter binding, single-statement checks, and database-enforced read-only transactions
- Authoritative row limits that cap
read_dataresults even when the submitted query contains its own largerLIMIT - Mutation confirmation with preview mode that shows affected rows before executing writes when
POSTGRESQL_REQUIRE_CONFIRMATIONis enabled - Explain plan via
EXPLAIN (FORMAT JSON)for understanding query performance - Connection testing that validates connectivity and reports latency
- Environment listing showing current host, database, and access-level configuration
- Optional HTTP bearer authentication, same-origin protection, request-size limits, and graceful shutdown
Installation
Download the latest release for your platform from the Releases page.
Usage
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
POSTGRESQL_HOST |
Yes | — | PostgreSQL hostname or IP |
POSTGRESQL_DATABASE |
Yes | — | Database name |
POSTGRESQL_USER |
Yes | — | Login username |
POSTGRESQL_PASSWORD |
Yes | — | Login password |
POSTGRESQL_PORT |
No | 5432 |
PostgreSQL port |
POSTGRESQL_SSLMODE |
No | prefer |
SSL mode: disable, allow, prefer, require, verify-ca, verify-full |
POSTGRESQL_ACCESS_LEVEL |
No | READONLY |
READONLY, DML-RW, or DDL-RW |
POSTGRESQL_CONNECTION_TIMEOUT |
No | 30 |
Connection timeout in seconds |
POSTGRESQL_QUERY_TIMEOUT |
No | 120 |
Query timeout in seconds |
POSTGRESQL_MAX_ROWS_DEFAULT |
No | 1000 |
Default row limit for queries |
POSTGRESQL_REQUIRE_CONFIRMATION |
No | true |
Require confirm flag for writes |
POSTGRESQL_TRANSPORT |
No | stdio |
MCP transport: stdio or http |
POSTGRESQL_HTTP_ADDR |
No | 127.0.0.1:8080 |
HTTP listen address when POSTGRESQL_TRANSPORT=http |
POSTGRESQL_HTTP_PATH |
No | /mcp |
Stateless Streamable HTTP endpoint path when POSTGRESQL_TRANSPORT=http |
POSTGRESQL_HTTP_BEARER_TOKEN |
No | — | Require Authorization: Bearer <token> for HTTP requests |
Running as an MCP Server
By default, the server communicates over stdio. Configure your MCP client to launch it:
{
"mcpServers": {
"postgresql": {
"command": "/path/to/bin/postgresql-mcp",
"env": {
"POSTGRESQL_HOST": "localhost",
"POSTGRESQL_DATABASE": "YourDatabase",
"POSTGRESQL_USER": "postgres",
"POSTGRESQL_PASSWORD": "YourPassword",
"POSTGRESQL_SSLMODE": "disable",
"POSTGRESQL_ACCESS_LEVEL": "READONLY"
}
}
}
}
To serve MCP using the stateless Streamable HTTP transport, set POSTGRESQL_TRANSPORT=http:
POSTGRESQL_TRANSPORT=http \
POSTGRESQL_HTTP_ADDR=127.0.0.1:8080 \
POSTGRESQL_HTTP_PATH=/mcp \
/path/to/bin/postgresql-mcp
Then configure a Streamable HTTP MCP client to connect to:
http://localhost:8080/mcp
Set POSTGRESQL_HTTP_BEARER_TOKEN when the endpoint is reachable by anything other than a trusted local client. Binding to a non-loopback address without authentication exposes every tool allowed by POSTGRESQL_ACCESS_LEVEL.
Access Levels
READONLY(default) — Schema exploration, data reading, profiling, relationship inspection, query explanation, connection testing, schema listing, extensions, views, triggers, CREATE TABLE DDL generation, table sizing. 18 tools.DML-RW— All read-only tools plusinsert_data,update_data,delete_data. 21 tools.DDL-RW— All DML tools pluscreate_table,create_index,drop_table. 24 tools.
Mutations (update_data, delete_data, drop_table) require a "confirm": true flag when POSTGRESQL_REQUIRE_CONFIRMATION is enabled (the default). Without confirmation, the server returns a preview of the affected rows instead.
update_data and delete_data predicates use named placeholders. For example, use "where": "id = $id AND tenant = $tenant" with "params": {"id": 42, "tenant": "acme"}. Every placeholder must have a value and every supplied parameter must be used.
Query results decode json/jsonb into structured JSON, encode bytea as base64, and suffix duplicate column names (id, id_2, and so on) so joined results do not silently lose values.
MCP Tools
Read-Only (READONLY)
| Tool | Description |
|---|---|
search_schema |
Search tables and columns by name pattern with pagination |
describe_table |
Get columns, primary keys, foreign keys, and indexes for a table |
list_table |
List tables, optionally filtered by schema and name |
list_databases |
List all databases on the server |
list_environments |
Show current connection and access-level configuration |
profile_table |
Row count, null counts, distinct counts, min/max when supported, with optional data samples |
inspect_relationships |
List foreign keys going out of and into a table |
inspect_dependencies |
Find objects (views, functions) that depend on a table |
explain_query |
Get the JSON execution plan for a read-only query |
read_data |
Execute a read-only SELECT query with row limits |
test_connection |
Ping the server and return latency and server version info |
validate_environment_config |
Validate that all environment variables are correctly configured |
list_schemas |
List all user schemas with owner and description |
list_extensions |
List installed PostgreSQL extensions with version |
list_views |
List views with their SQL definitions |
list_triggers |
List triggers with event, timing, and definition |
show_create_table |
Generate CREATE TABLE DDL including defaults, generated/identity columns, and table constraints |
table_size |
Table and index sizes, toast size, and estimated row counts, optionally for one table |
DML (DML-RW)
| Tool | Description |
|---|---|
insert_data |
Insert one or more rows into a table |
update_data |
Update rows matching a WHERE clause (with optional preview) |
delete_data |
Delete rows matching a WHERE clause (with optional preview) |
DDL (DDL-RW)
| Tool | Description |
|---|---|
create_table |
Create a table with column definitions, primary keys, and identity columns |
create_index |
Create a standard or unique index on specified columns |
drop_table |
Drop a table (with optional preview/confirmation) |
License
MIT License. See LICENSE for details.
PostgreSQL MCP 질문
PostgreSQL MCP는 어떤 도구를 제공하나요?
24개 도구를 제공합니다. 예: search_schema, describe_table, list_table, list_databases, list_environments.
어떤 액세스 수준을 사용할 수 있나요?
이 서버는 READONLY(기본값), DML-RW(insert/update/delete 추가), DDL-RW(create/drop table/index 추가)의 세 가지 계층형 액세스 수준을 지원합니다.
쓰기 작업의 안전성을 어떻게 보장하나요?
POSTGRESQL_REQUIRE_CONFIRMATION을 true로 설정하면 변경 확인 모드를 활성화할 수 있습니다. 이 모드에서는 쓰기 작업을 실행하기 전에 영향을 받는 행을 미리 보여줍니다.
HTTP를 통해 이 서버를 사용할 수 있나요?
네, POSTGRESQL_TRANSPORT 환경 변수를 'http'로 설정하면 상태가 없는 streamable HTTP 엔드포인트를 통해 MCP를 제공할 수 있습니다.
대규모 쿼리 결과는 어떻게 처리하나요?
서버는 쿼리 자체에 더 큰 LIMIT 절이 포함되어 있더라도, read_data 도구의 결과가 클라이언트에 과부하를 주지 않도록 권한 있는 행 제한(authoritative row limits)을 사용합니다.