MCP PostgreSQL 서버
다음을 수행하는 모델-컨트롤러-공급자(MCP) 서버:
PostgreSQL 데이터베이스에 연결합니다
테이블 스키마를 리소스로 노출합니다.
읽기 전용 SQL 쿼리를 실행하기 위한 도구를 제공합니다.
일반적인 데이터 분석 작업에 대한 프롬프트가 포함되어 있습니다.
특징
스키마 탐색 : 데이터베이스 스키마, 테이블 및 열 탐색
읽기 전용 쿼리 실행 : 데이터베이스에 대해 SQL 쿼리를 안전하게 실행합니다.
데이터 분석 프롬프트 : 일반적인 분석 작업을 위한 미리 작성된 SQL 템플릿
데이터 시각화 : 시각화를 위한 데이터 생성
관계 탐색 : 테이블 관계 및 외래 키 시각화
API 문서 : 자동 생성된 OpenAPI 사양
Related MCP server: PostgreSQL MCP Server
건축학
이 애플리케이션은 MCP(모델-컨트롤러-공급자) 패턴을 따릅니다.
모델 계층 : 데이터베이스와의 직접적인 상호 작용
공급자 계층 : 비즈니스 로직 및 데이터 처리
컨트롤러 계층 : API 엔드포인트 및 요청 처리
보안 기능
읽기 전용 쿼리 검증
SQL 주입 보호
속도 제한
매개변수화된 쿼리
인증 지원
CORS 구성
설치
저장소를 복제합니다.
지엑스피1
종속성 설치:
npm install.env.template기반으로.env파일을 만듭니다.cp .env.template .env.env파일을 PostgreSQL 데이터베이스 자격 증명으로 업데이트합니다.서버를 시작합니다:
npm start
구성
모든 구성은 환경 변수를 통해 관리됩니다.
서버 : 포트, 환경, CORS 설정
데이터베이스 : 연결 세부 정보, 풀 설정
보안 : JWT 설정, 속도 제한
쿼리 : 실행 제한, 결과 크기 제한
API 엔드포인트
스키마 엔드포인트
GET /api/schemas- 모든 스키마 나열GET /api/schemas/:schema/tables- 스키마의 테이블 나열GET /api/schemas/:schema/tables/:table- 테이블 스키마 세부 정보 가져오기GET /api/schemas/:schema/relationships- 테이블 관계 가져오기GET /api/structure- 전체 데이터베이스 구조 가져오기GET /api/search?q=term- 테이블 및 열 검색
쿼리 엔드포인트
POST /api/query- SQL 쿼리 실행POST /api/query/explain- 쿼리 실행 계획 가져오기GET /api/schemas/:schema/tables/:table/sample- 샘플 데이터 가져오기GET /api/schemas/:schema/tables/:table/stats- 테이블 통계 가져오기
분석 프롬프트 엔드포인트
GET /api/prompts- 분석 프롬프트 템플릿 목록GET /api/prompts/:templateId- 프롬프트 템플릿 세부 정보 가져오기POST /api/prompts/:templateId/generate- 템플릿에서 SQL 생성GET /api/schemas/:schema/tables/:table/analysis/suggest- 분석 제안 받기
예제 쿼리
기본 테이블 쿼리
// API request
fetch('/api/query', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
sql: 'SELECT * FROM users LIMIT 10'
})
})
.then(response => response.json())
.then(data => console.log(data));분석 프롬프트 사용
// Get suggested analysis for a table
fetch('/api/schemas/public/tables/orders/analysis/suggest')
.then(response => response.json())
.then(suggestions => {
// Use a suggestion
const suggestionId = suggestions.data[0].templateId;
const params = suggestions.data[0].params;
// Generate SQL from the template
return fetch(`/api/prompts/${suggestionId}/generate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ params })
});
})
.then(response => response.json())
.then(data => {
// Execute the generated SQL
return fetch('/api/query', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ sql: data.data.sql })
});
})
.then(response => response.json())
.then(results => console.log(results));개발
개발 모드에서 실행:
npm run dev테스트 실행:
npm test린트 코드:
npm run lint
특허
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Appeared in Searches
- A database for searching medical and scientific research articles
- PostgreSQL MCP (Multi-Version Concurrency Control or specific usage)
- Information about PostgreSQL MCP (Managed Cloud Provider or other related concepts)
- Search for information about 'rag'
- Overview and Resources for PostgreSQL Database System
Latest Blog Posts
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/Maxim2324/mcp-server-test'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
