MCP Server for PostgreSQL
PostgreSQL용 MCP 서버
PostgreSQL을 위한 MCP(Model Context Protocol) 서버 구현으로, MCP를 통해 PostgreSQL 데이터베이스와 상호 작용할 수 있는 간단한 인터페이스를 제공합니다.
특징
매개변수화된 입력으로 SQL 쿼리 실행
INSERT/UPDATE/DELETE 작업 실행
새로운 데이터베이스 생성
테이블 스키마 생성 또는 업데이트
PostgreSQL 연결 디버깅
Docker로 컨테이너화하여 쉽게 배포 가능
환경 기반 구성
Related MCP server: MCP PostgreSQL Server
필수 조건
파이썬 3.8 이상
포스트그레SQL 10+
Docker(컨테이너화된 배포를 위한 선택 사항)
Docker Compose(선택 사항, 개발용)
설치
Docker 사용(권장)
저장소를 복제합니다.
지엑스피1
예제 환경 파일을 복사하세요.
cp .env.example .envPostgreSQL 자격 증명으로
.env파일을 업데이트합니다.PG_HOST=postgres PG_PORT=5432 PG_USER=postgres PG_PASSWORD=your_password PG_DATABASE=your_database HOST=0.0.0.0 PORT=8056Docker Compose를 사용하여 서비스를 시작합니다.
docker-compose up -d
수동 설치
저장소를 복제합니다.
git clone https://github.com/asadudin/mcp-server-postgres.git cd mcp-server-postgres가상 환경을 만들고 활성화하세요.
python -m venv venv source venv/bin/activate # On Windows: .\venv\Scripts\activate종속성 설치:
pip install -r requirements.txt예제 환경 파일을 복사하여 업데이트합니다.
cp .env.example .env # Edit .env with your configuration서버를 실행합니다:
python mcp_server_postgres.py
용법
MCP 서버는 다음과 같은 엔드포인트를 제공합니다.
sql_query
SELECT 쿼리를 실행하고 결과를 JSON으로 반환합니다.
매개변수:
query: SQL 쿼리 문자열params: 쿼리 매개변수의 선택적 JSON 문자열(목록 또는 사전)
예:
{
"query": "SELECT * FROM users WHERE id = $1",
"params": [1]
}sql_execute
INSERT/UPDATE/DELETE 문을 실행합니다.
매개변수:
query: SQL 문params: 쿼리 매개변수의 선택적 JSON 문자열(목록 또는 사전)
예:
{
"query": "INSERT INTO users (name, email) VALUES ($1, $2)",
"params": ["John Doe", "john@example.com"]
}create_database
새로운 PostgreSQL 데이터베이스를 만듭니다.
매개변수:
database_name: 생성할 데이터베이스의 이름
create_or_update_table
테이블 스키마를 생성하거나 업데이트합니다.
매개변수:
sql: CREATE TABLE 또는 ALTER TABLE SQL 문
debug_postgres_connection
PostgreSQL 연결을 디버깅합니다.
환경 변수
변하기 쉬운 | 기본 | 설명 |
PG_호스트 | 로컬호스트 | PostgreSQL 호스트 |
PG_PORT | 5432 | PostgreSQL 포트 |
PG_USER | 포스트그레스 | PostgreSQL 사용자 이름 |
PG_비밀번호 | PostgreSQL 비밀번호 | |
PG_데이터베이스 | 포스트그레스 | 기본 데이터베이스 이름 |
주인 | 0.0.0.0 | MCP 서버를 바인딩할 호스트 |
포트 | 8056 | MCP 서버를 실행할 포트 |
개발
테스트 실행
# Install test dependencies
pip install -r requirements-dev.txt
# Run tests
pytestDocker 이미지 빌드
docker build -t mcp-server-postgres .API 문서
자세한 API 문서는 OpenAPI 사양을 참조하세요.
기여하다
기여를 환영합니다! 풀 리퀘스트를 제출해 주세요.
특허
이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여되었습니다. 자세한 내용은 라이선스 파일을 참조하세요.
감사의 말
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
- SupabaseOAuthcom.supabase
MCP server for interacting with the Supabase platform
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Related MCP Servers
- AlicenseBqualityBmaintenanceA Model Context Protocol server that enables powerful PostgreSQL database management capabilities including analysis, schema management, data migration, and monitoring through natural language interactions.181,692198AGPL 3.0
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables performing PostgreSQL database operations (create, read, update, delete) on User and Post entities through MCP tools.607MIT
- AlicenseNot gradedqualityCmaintenanceA Model Context Protocol server that enables interaction with PostgreSQL databases to list tables, retrieve schemas, and execute read-only SQL queries.29MIT
- FlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI assistants to interact with PostgreSQL databases by executing SQL queries and inspecting database schemas. It provides tools for standardized database exploration and management through the Model Context Protocol.-
Appeared in Searches
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/asadudin/mcp-server-postgres'
If you have feedback or need assistance with the MCP directory API, please join our Discord server