
netanelbollag/simple-psql-mcp
Developer tools이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기
PostgreSQL 커넥터가 포함된 초소형 MCP 서버 템플릿은 깨끗하고 사용하기 쉬운 코드입니다.
개요
MCP 서버를 구축하려는 사람들을 위한 템플릿 프로젝트입니다. 나는 이해하고 적응하기 위해 드문 간단한 설계 - 코드는 빠른 속도를 얻을 수 있도록 MCP docs로 곧게됩니다. TL;DR - AI 용 플러그인을 작성하는 방법입니다 Model Context Protocol (MCP)은 외부 도구와 데이터와 상호 작용하는 LLM의 표준 방법입니다. nutshell에서: - LLM 명령을 실행할 수 있습니다 (데이터베이스 쿼리 실행과 같은) - 대화에 첨부할 수 있는 데이터입니다 (예를 들어 프롬프트에 첨부) - 일관된 LLM 지침을 생성하는 템플릿입니다. 1. - execute query - 데이터베이스에 대한 SQL 쿼리를 실행 - test connection - 데이터베이스 연결 확인 2. - db://tables - schema의 모든 테이블 목록 - db://tables/{table name} - 특정 테이블에 대한 Schema 정보 - db://schema - 데이터베이스의 모든 테이블에 대한 완전한 스키마 정보 3. 명세.
개요(AI 번역)
MCP 서버를 구축하려는 사람들을 위한 템플릿 프로젝트입니다. 나는 이해하고 적응하기 위해 드문 간단한 설계 - 코드는 빠른 속도를 얻을 수 있도록 MCP docs로 곧게됩니다.
MCP는 무엇입니까?
*TL;DR - AI *에 대한 플러그인을 작성하는 방법입니다
Model Context Protocol (MCP)은 외부 도구와 데이터와 상호 작용하는 LLM의 표준 방법입니다. nutshell에서:
-Tools는 LLM을 실행할 수 있습니다. -Resources는 대화에 첨부할 수 있는 데이터입니다. (파일을 프롬프트에 첨부)
- Prompts는 일관된 LLM 지침을 생성하는 템플릿입니다.
특징
이 PostgreSQL MCP 서버는 다음과 같습니다.
1.도구
execute_query- 데이터베이스에 대한 SQL 쿼리 실행test_connection- 데이터베이스 연결을 검증
- 자료
db://tables- 스키마의 모든 테이블 목록db://tables/{table_name}- 특정 테이블에 대한 Schema 정보db://schema- 데이터베이스의 모든 테이블에 대한 완전한 스키마 정보
- 프로그램
- Query 세대 템플릿
- 분석 쿼리 빌더
- 이 저장소에 템플릿을 기반으로
필수품
- 파이썬 3.8+
이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.
README
원문 README의 일부입니다. 원문 보기.
Simple PostgreSQL MCP Server
This is a template project for those looking to build their own MCP servers. I designed it to be dead simple to understand and adapt - the code is straightforward with MCP docs attached so you can quickly get up to speed.
What is MCP?
TL;DR - It’s a way to write plugins for AI
Model Context Protocol (MCP) is a standard way for LLMs to interact with external tools and data. In a nutshell:
- Tools allow the LLM to execute commands (like running a database query)
- Resources are data you can attach to conversations (like attaching a file to a prompt)
- Prompts are templates that generate consistent LLM instructions
Features
This PostgreSQL MCP server implements:
-
Tools
execute_query- Run SQL queries against your databasetest_connection- Verify the database connection is working
-
Resources
db://tables- List of all tables in the schemadb://tables/{table_name}- Schema information for a specific tabledb://schema- Complete schema information for all tables in the database
-
Prompts
- Query generation templates
- Analytical query builders
- Based on the templates in this repo
Prerequisites
- Python 3.8+
- uv - Modern Python package manager and installer
- npx (included with Node.js)
- PostgreSQL database you can connect to
Quick Setup
-
Create a virtual environment and install dependencies:
# Create a virtual environment with uv uv venv # Activate the virtual environment source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install dependencies uv pip install -r requirements.txt -
Run the server with the MCP Inspector:
# Replace with YOUR actual database credentials npx @modelcontextprotocol/inspector uv --directory . run postgres -e DSN=postgresql://username:password@hostname:port/database -e SCHEMA=publicNote: If this is your first time running npx, you’ll be prompted to approve the installation. Type ‘y’ to proceed.
After running this command, you’ll see the MCP Inspector interface launched in your browser. You should see a message like:
MCP Inspector is up and running at http://localhost:5173If the browser doesn’t open automatically, copy and paste the URL into your browser. You should see something like this:
-
Using the Inspector:
- Click the “Connect” button in the interface (unless there’s an error message in the console on the bottom left)
- Explore the “Tools”, “Resources”, and “Prompts” tabs to see available functionality
- Try clicking on listed commands or typing resource names to retrieve resources and prompts
- The interface allows you to test queries and see how the MCP server responds
-
Take a look at the official docs
설치
npx @modelcontextprotocol/inspector uv --directory . run postgres -e DSN=postgresql://username:password@hostname:port/database -e SCHEMA=public설정
{
"mcpServers": {
"postgres": {
"command": "/path/to/uv",
"args": [
"--directory",
"/path/to/simple-psql-mcp",
"run",
"postgres"
],
"env": {
"DSN": "postgresql://username:password@localhost:5432/my-db",
"SCHEMA": "public"
}
}
}
}