PostgreSQL MCP란?
PostgreSQL은(는) MCP server입니다. AI 코딩 에이전트가 PostgreSQL 데이터베이스를 쿼리, 수정, 검사하고 연결 프로필 관리 및 성능 진단을 수행할 수 있도록 지원합니다.
프로젝트 README에서 생성된 요약
PostgreSQL MCP server 정보
PostgreSQL 데이터베이스와 직접 상호작용해야 하는 코딩 에이전트는 쿼리, 스키마 설계, 진단 및 CSV 임포트를 위해 postgres-mcp를 호출할 수 있습니다. 이 서버는 Node.js 22+ 기반의 stdio 방식 MCP server로 동작하며, 별도의 설치 과정 없이 npx를 통해 실행됩니다. GitHub Copilot, Claude Code, Codex, Open Code, Cursor, VS Code, Claude Desktop을 포함한 모든 MCP 클라이언트와 호환됩니다. 클라이언트 설정은 npx 실행 명령을 가리키며 인증 정보를 포함하지 않으며, 에이전트가 런타임에 저장된 프로필을 불러옵니다.
프로필은 libpq URI 또는 key=value 문자열을 사용하는 connection add 명령으로 한 번 생성하며, 비밀번호는 설정 파일 대신 OS 키링에 보관됩니다. 키링이 없는 헤드리스 또는 CI 환경에서는 환경 변수로부터 연결 문자열을 전달받을 수 있습니다. Azure 프로필의 경우 키링에 저장된 비밀번호가 없으면 Microsoft Entra ID를 자동으로 선택합니다. 도구 세트에는 postgres_mcp_query를 통한 읽기 전용 SQL, postgres_mcp_modify를 통한 DDL 및 DML, 테이블/인덱스/함수/시퀀스 생성을 위한 CREATE 스크립트, COPY를 통한 CSV 설명 및 대량 로드, 기능 탐색 및 성능 메트릭 그룹이 포함됩니다.
서버가 해당 사용자로 요청을 실행하므로 액세스 제어는 데이터베이스 역할(role)에 따라 결정됩니다. 읽기 전용 프로필은 access_mode: ro로 설정합니다. 로컬 파일 읽기는 경로가 명시적으로 허용되지 않는 한 시작 작업 디렉토리로 제한되며, 오류 메시지에서 비밀 정보는 삭제됩니다.
활용 사례
- 1Postgres에서 최근 주문 내역 가져오기SQL 클라이언트를 열지 않고도 테스트 데이터를 확인할 수 있도록 에이전트에게 최근 주문 10개를 보여달라고 요청하세요.
- 2현재 데이터베이스 병목 현상 찾기에이전트가 성능 메트릭 그룹을 수집하여 현재 서버 속도를 저하시키는 요인이 무엇인지 확인하게 하세요.
- 3데이터베이스 테이블 목록 조회스키마 작업을 시작하기 위한 기초 단계로 연결된 데이터베이스의 테이블 목록을 가져오세요.
프로젝트의 README를 바탕으로 작성되었습니다. 모든 활용 사례는 해당 내용의 인용문과 대조하여 확인합니다.
PostgreSQL MCP 설치 방법
형식 확인: 2026년 11월 10일Claude Code에 PostgreSQL MCP 설치
$ claude mcp add postgres-mcp -- npx -y @microsoft/postgres-mcpCursor에 PostgreSQL MCP 설치
~/.cursor/mcp.json
{
"mcpServers": {
"postgres-mcp": {
"command": "npx",
"args": [
"-y",
"@microsoft/postgres-mcp"
]
}
}
}VS Code에 PostgreSQL MCP 설치
.vscode/mcp.json
{
"servers": {
"postgres-mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@microsoft/postgres-mcp"
]
}
}
}Claude Desktop에 PostgreSQL MCP 설치
claude_desktop_config.json
{
"mcpServers": {
"postgres-mcp": {
"command": "npx",
"args": [
"-y",
"@microsoft/postgres-mcp"
]
}
}
}Codex에 PostgreSQL MCP 설치
~/.codex/config.toml
[mcp_servers.postgres-mcp] command = "npx" args = ["-y", "@microsoft/postgres-mcp"]
Gemini CLI에 PostgreSQL MCP 설치
~/.gemini/settings.json
{
"mcpServers": {
"postgres-mcp": {
"command": "npx",
"args": [
"-y",
"@microsoft/postgres-mcp"
]
}
}
}자동 검사
2026년 11월 13일에 실행됨전체 보고서 →자동 검사를 통과했습니다. 이는 보안 감사가 아닙니다. 코드를 직접 읽고 서버에 필요한 최소한의 권한만 부여하십시오. 검사 방식
- 소스 저장소 연결 및 접근 가능통과
- 오픈 소스 라이선스 (OSI)통과
- 최근 1년 내 커밋 또는 릴리스통과
- 패키지 이름이 인기 패키지와 유사하지 않음통과
- 원격 엔드포인트가 HTTPS 사용검사되지 않음
- 파괴적인 도구에 라벨 표시됨검사되지 않음
- 모델에 대한 숨겨진 지침 없음통과
- 패키지와 의존성에 심각한 보안 권고 없음검사되지 않음
README
GitHub에서 보기Postgres MCP Server
Connect your coding agent to PostgreSQL. postgres-mcp lets you generate
queries and run analytics, design database schemas, diagnose performance of the
server and queries, securely manage connections, and import data. It is
compatible with any MCP client — GitHub Copilot, Claude Code, Codex, Open Code,
Cursor, VS Code, and more.
- npm: https://www.npmjs.com/package/@microsoft/postgres-mcp
- No install required — run it straight from
npx.
Quick start
1. Save a connection profile
Create a named profile once — the password is stored in your OS keyring, never in a config file:
# add a profile from a libpq URI or key=value string
npx -y @microsoft/postgres-mcp connection add local \
"postgresql://postgres@localhost:5432/postgres"
# store its password securely (hidden prompt)
npx -y @microsoft/postgres-mcp connection set-password local
# check it
npx -y @microsoft/postgres-mcp connection list
Profiles created by
connection addpermit write tools unlessaccess_mode: rois set. For autonomous agents that should not write, use an explicit read-only profile and a read-only database role — see Read-only profiles.
2. Add postgres-mcp to your coding agent
The server speaks MCP over stdio. Point your client at
npx @microsoft/postgres-mcp run — no credentials go in the client config; the
coding agent discovers and connects to your saved profile at runtime.
GitHub Copilot CLI, Claude Code, Cursor & Claude Desktop — clients that use the mcpServers format (~/.copilot/mcp-config.json, mcp.json, .cursor/mcp.json, claude_desktop_config.json, …):
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@microsoft/postgres-mcp", "run"]
}
}
}
Running headless or in CI, without a keyring? The server can also take a database connection string from the environment — see Connecting without a profile in the guide.
3. Ask your coding agent
"List the tables in my PostgreSQL database." "Show me the 10 most recent orders from my PostgreSQL database." "What's slowing down my PostgreSQL server right now?"
The agent calls the server's tools (postgres_mcp_connect,
postgres_mcp_query, postgres_mcp_db_context, …) for you.
What it can do
| Area | Tools |
|---|---|
| Connections | list / add / remove profiles, connect, disconnect, list databases |
| Query | read‑only SQL (postgres_mcp_query), DDL/DML (postgres_mcp_modify) |
| Schema | fetch CREATE scripts for tables, indexes, functions, sequences… |
| Data | describe a CSV, bulk‑load a CSV via COPY |
| Diagnostics | probe server capabilities, collect performance metric groups |
See the usage guide for tools, configuration, authentication (including Microsoft Entra ID), TLS, and the security model.
Security in one minute
- The server doesn't decide what's allowed — your database does. It just passes requests along to PostgreSQL and runs them as the database user in your connection profile. It can't tell the difference between a request you meant to make and one the AI invented or was tricked into making, so anything that database user can do, the AI can do. What actually protects you is the permissions you give that user, the approval prompts in your MCP client, and the model you choose to run. See Security model for who's responsible for what, plus a checklist for locking things down.
postgres_mcp_queryis read‑only. Omitted profileaccess_modepermits write tools; setaccess_mode: roand use a read-only database role unless writes are intentionally delegated.- Microsoft Entra ID (AAD) is selected automatically for Azure profiles without a stored keyring password. Store a profile password to use password authentication instead.
- Local file reads (
postgres_mcp_bulk_load_csv,postgres_mcp_describe_csv) are limited to the MCP server's startup working directory by default and paths allowed withallow-access-to-path <path>. A file allows only itself; a directory allows recursive access. - Secrets are scrubbed from error messages before they leave the process.
See more info about security model in the usage guide.
Requirements
- Node.js 22+ (to run via
npx). - Linux x64/arm64, macOS x64/arm64, or Windows x64. Windows ARM uses x64 emulation.
- A reachable PostgreSQL database — local, Docker, on‑premises, Azure Database for PostgreSQL, Amazon RDS/Aurora, Google Cloud SQL/AlloyDB, or any wire‑compatible server.
Changelog
See CHANGELOG.md for release notes.
License
This repository is a getting started information package. It is licensed under the MIT License © Microsoft. The postgres-mcp project itself is proprietary and its source code is not avialable under MIT license.
PostgreSQL MCP 질문
PostgreSQL MCP를 Claude Code에 추가하려면 어떻게 하나요?
터미널에서 claude mcp add postgres-mcp -- npx -y @microsoft/postgres-mcp를 실행합니다. 모든 프로젝트에서 사용할 수 있게 하려면 --scope user를 추가합니다.
PostgreSQL MCP를 Cursor에 추가하려면 어떻게 하나요?
~/.cursor/mcp.json를 열고 mcpServers 아래에 서버를 추가합니다. 위 설치 섹션에 표시된 Cursor 구성을 사용합니다.
postgres-mcp를 Claude Code 또는 GitHub Copilot에 어떻게 연결하나요?
클라이언트의 mcpServers 설정에 npx @microsoft/postgres-mcp run을 가리키는 stdio 항목을 추가하세요. 해당 설정에는 인증 정보를 포함하지 않습니다.
데이터베이스 비밀번호는 어디에 저장되나요?
비밀번호는 설정 파일이 아닌 connection set-password 명령을 통해 OS 키링에 저장됩니다.
쿼리 도구는 읽기 전용인가요?
네, postgres_mcp_query는 읽기 전용입니다. 하지만 프로필의 access_mode가 ro로 설정되어 있지 않다면 쓰기 도구를 사용할 수 있습니다.
CI 환경처럼 프로필을 저장하지 않고 사용할 수 있나요?
네, 키링을 사용할 수 없는 경우 서버가 환경 변수에서 데이터베이스 연결 문자열을 가져올 수 있습니다.
필요한 Node.js 버전은 무엇인가요?
npx를 통해 실행하려면 Node.js 22 이상이 필요합니다.