VOOZH about

URL: https://glama.ai/mcp/servers/llm-graph/postgres-mcp?locale=ko-KR

⇱ FastPostgresMCP by llm-graph | Glama


FastPostgresMCP 🐘⚑️ (λͺ¨λ“  κΈ°λŠ₯을 κ°–μΆ˜ 닀쀑 DB MCP μ„œλ²„)

이 ν”„λ‘œμ νŠΈλŠ” AI μ—μ΄μ „νŠΈ(예: Cursor, Claude Desktop)κ°€ μ—¬λŸ¬ PostgreSQL λ°μ΄ν„°λ² μ΄μŠ€μ™€ μƒν˜Έ μž‘μš©ν•˜κ³  ν…Œμ΄λΈ” λ‚˜μ—΄ 및 μŠ€ν‚€λ§ˆ 검사λ₯Ό μˆ˜ν–‰ν•  수 μžˆλ„λ‘ μ„€κ³„λœ 맀우 λΉ λ₯΄κ³  μœ ν˜•μ΄ μ•ˆμ „ν•˜λ©° λͺ¨λ“  κΈ°λŠ₯을 κ°–μΆ˜ Model Context Protocol(MCP) μ„œλ²„λ₯Ό κ΅¬ν˜„ν•©λ‹ˆλ‹€.

Bun, TypeScript, postgres 둜 κ΅¬μΆ•λ˜μ—ˆμœΌλ©°, κ²¬κ³ ν•œ MCP μ„œλ²„λ₯Ό κ΅¬μΆ•ν•˜κΈ° μœ„ν•œ fastmcp ν”„λ ˆμž„μ›Œν¬μ˜ κ³ κΈ‰ κΈ°λŠ₯을 ν™œμš©ν•©λ‹ˆλ‹€.

πŸ‘ λΌμ΄μ„ΌμŠ€: MIT
πŸ‘ fastmcp둜 ꡬ동됨
πŸ‘ Bun으둜 μ œμž‘
πŸ‘ postgresλ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€
πŸ‘ νƒ€μž…μŠ€ν¬λ¦½νŠΈ
πŸ‘ GitHub μ €μž₯μ†Œ
πŸ‘ NPM νŒ¨ν‚€μ§€

λͺ©μ : AI μ—μ΄μ „νŠΈλ₯Ό μœ„ν•œ MCP μ„œλ²„

이 λΌμ΄λΈŒλŸ¬λ¦¬λŠ” μ½”λ“œμ— μž„ν¬νŠΈν•  수 μ—†μŠ΅λ‹ˆλ‹€ . λ…λ¦½ν˜• μ„œλ²„ μ• ν”Œλ¦¬μΌ€μ΄μ…˜ μž…λ‹ˆλ‹€. ν”„λ‘œμ„ΈμŠ€λ‘œ μ‹€ν–‰ν•˜λ©΄ MCP ν΄λΌμ΄μ–ΈνŠΈ(AI μ—μ΄μ „νŠΈ λ“±)λŠ” JSON 기반 λͺ¨λΈ μ»¨ν…μŠ€νŠΈ ν”„λ‘œν† μ½œ(v2.0)을 μ‚¬μš©ν•˜μ—¬ ν†΅μ‹ ν•©λ‹ˆλ‹€. 일반적으둜 ν΄λΌμ΄μ–ΈνŠΈ μ• ν”Œλ¦¬μΌ€μ΄μ…˜(예: Cursor)μ—μ„œ κ΄€λ¦¬ν•˜λŠ” stdio 연결을 톡해 ν†΅μ‹ ν•©λ‹ˆλ‹€.

Related MCP server: Postgres MCP Pro

문제 ν•΄κ²° 및 개발

ν…ŒμŠ€νŠΈλ₯Ό μœ„ν•œ CLI μ‚¬μš©

νŒ¨ν‚€μ§€μ—λŠ” MCP μ„œλ²„λ₯Ό 직접 ν…ŒμŠ€νŠΈν•˜κΈ° μœ„ν•œ λ‚΄μž₯ CLI λͺ…령이 ν¬ν•¨λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

μ§€μ—‘μŠ€ν”Ό1

λ‚΄μž₯된 MCP κ²€μ‚¬κΈ°λ‘œ ν…ŒμŠ€νŠΈ

MCP Inspectorλ₯Ό μ‚¬μš©ν•˜μ—¬ μ‹œκ°μ μœΌλ‘œ ν…ŒμŠ€νŠΈν•˜κ³  디버깅할 μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.

# From the project repository:
bun run inspect

일반적인 문제

bunx postgres-mcp μ‹€ν–‰ν•  λ•Œ λ‹€μŒ 였λ₯˜κ°€ ν‘œμ‹œλ˜λ©΄:

FastPostgresMCP started
[warning] FastMCP could not infer client capabilities

ping λ©”μ‹œμ§€κ°€ λ’€λ”°λ₯΄λŠ” 경우 λ‹€μŒμ„ μ˜λ―Έν•©λ‹ˆλ‹€.

  1. MCP μ„œλ²„κ°€ μ„±κ³΅μ μœΌλ‘œ μ‹œμž‘λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

  2. ν΄λΌμ΄μ–ΈνŠΈκ°€ μ„±κ³΅μ μœΌλ‘œ μ—°κ²°λ˜μ—ˆμŠ΅λ‹ˆλ‹€

  3. ν•˜μ§€λ§Œ ν΄λΌμ΄μ–ΈνŠΈλŠ” ping μš”μ²­λ§Œ 보내고 κΈ°λŠ₯을 μ œλŒ€λ‘œ ν˜‘μƒν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

μ΄λŠ” 일반적으둜 μ μ ˆν•œ MCP ν΄λΌμ΄μ–ΈνŠΈλ₯Ό μ‚¬μš©ν•΄μ•Ό 함을 λ‚˜νƒ€λƒ…λ‹ˆλ‹€. λ‹€μŒμ„ μ‹œλ„ν•΄ λ³΄μ„Έμš”.

  • bun run cli μ‚¬μš©ν•˜μ—¬ MCP CLI둜 ν…ŒμŠ€νŠΈ

  • μ„€μΉ˜ μ„Ήμ…˜μ— μ„€λͺ…λœ λŒ€λ‘œ Cursor λ˜λŠ” Claude Desktopμ—μ„œ MCP μ„œλ²„ ꡬ성

μ‚¬μš©μž μ •μ˜ MCP ν΄λΌμ΄μ–ΈνŠΈλ₯Ό κ°œλ°œν•˜λŠ” 경우 κΈ°λŠ₯ ν˜‘μƒμ„ ν¬ν•¨ν•˜μ—¬ MCP ν”„λ‘œν† μ½œμ„ μ˜¬λ°”λ₯΄κ²Œ κ΅¬ν˜„ν–ˆλŠ”μ§€ ν™•μΈν•˜μ„Έμš”.

✨ 핡심 κΈ°λŠ₯

  • πŸš€ 맀우 빠름: Bunκ³Ό fastmcp 기반으둜 ꡬ좕됨.

  • πŸ”’ Type-Safe: Zod μŠ€ν‚€λ§ˆ 검증을 ν†΅ν•œ 쒅단 κ°„ TypeScript.

  • 🐘 닀쀑 λ°μ΄ν„°λ² μ΄μŠ€ 지원: .env 에 μ •μ˜λœ μ—¬λŸ¬ PostgreSQL μΈμŠ€ν„΄μŠ€μ— μ—°κ²°ν•˜κ³  μƒν˜Έμž‘μš©μ„ κ΄€λ¦¬ν•©λ‹ˆλ‹€.

  • πŸ›‘οΈ λ³΄μ•ˆμ„ κ³ λ €ν•œ 섀계: postgres ν†΅ν•œ λ§€κ°œλ³€μˆ˜ν™”λœ μΏΌλ¦¬λŠ” SQL μ£Όμž…μ„ λ°©μ§€ν•©λ‹ˆλ‹€.

  • πŸ”‘ 선택적 인증: API ν‚€ 검증( fastmcp 의 authenticate 후크)을 μ‚¬μš©ν•˜μ—¬ λ„€νŠΈμ›Œν¬ 기반 μ—°κ²°(SSE/HTTP)을 λ³΄ν˜Έν•©λ‹ˆλ‹€.

  • πŸ“„ MCP λ¦¬μ†ŒμŠ€λ₯Ό ν†΅ν•œ λ°μ΄ν„°λ² μ΄μŠ€ μŠ€ν‚€λ§ˆ:

    • ν…Œμ΄λΈ” λͺ©λ‘: db://{dbAlias}/schema/tables 톡해 λ°μ΄ν„°λ² μ΄μŠ€μ˜ ν…Œμ΄λΈ” λͺ©λ‘μ„ κ°€μ Έμ˜΅λ‹ˆλ‹€.

    • ν…Œμ΄λΈ” μŠ€ν‚€λ§ˆ 검사: db://{dbAlias}/schema/{tableName} 톡해 νŠΉμ • ν…Œμ΄λΈ”μ— λŒ€ν•œ μžμ„Έν•œ μ—΄ 정보λ₯Ό κ°€μ Έμ˜΅λ‹ˆλ‹€.

  • πŸ’¬ ν–₯μƒλœ 도ꡬ μƒν˜Έμž‘μš©:

    • 도ꡬ λ‚΄ λ‘œκΉ…: λ„κ΅¬λŠ” μžμ„Έν•œ 둜그λ₯Ό ν΄λΌμ΄μ–ΈνŠΈλ‘œ λ‹€μ‹œ λ³΄λƒ…λ‹ˆλ‹€( log μ»¨ν…μŠ€νŠΈ).

    • μ§„ν–‰ 상황 보고: μž₯κΈ° μ‹€ν–‰ μž‘μ—…μ€ μ§„ν–‰ 상황을 λ³΄κ³ ν•©λ‹ˆλ‹€( reportProgress μ»¨ν…μŠ€νŠΈ).

  • 🧠 μ„Έμ…˜ 인식: 도ꡬ μ‹€ν–‰ μ»¨ν…μŠ€νŠΈ( session μ»¨ν…μŠ€νŠΈ) λ‚΄μ—μ„œ μ„Έμ…˜ 정보에 μ•‘μ„ΈμŠ€ν•©λ‹ˆλ‹€.

  • πŸ“‘ 이벀트 기반: μ—°κ²°/μ„Έμ…˜ 이벀트 처리λ₯Ό μœ„ν•΄ server.on 및 session.on μ‚¬μš©ν•©λ‹ˆλ‹€.

  • πŸ”§ μ΅œμ‹  개발자 κ²½ν—˜(DX): λͺ…ν™•ν•œ ꡬ성, 직관적인 API, fastmcp 도ꡬλ₯Ό μ‚¬μš©ν•œ κ°„νŽΈν•œ ν…ŒμŠ€νŠΈ.

포함 사항(fastmcp κΈ°λŠ₯ ν™œμš©)

  • FastMCP μ„œλ²„ μ½”μ–΄

  • server.addTool ( query_tool , execute_tool , schema_tool 및 transaction_tool 용)

  • server.addResourceTemplate (ν…Œμ΄λΈ” λ‚˜μ—΄ 및 ν…Œμ΄λΈ” μŠ€ν‚€λ§ˆ κ²€μ‚¬μš©)

  • server.start ( stdio 포컀슀 포함, sse / http 에 맞게 μ‘°μ • κ°€λŠ₯)

  • 선택 사항: authenticate 후크(API ν‚€ κ²€μ¦μš©)

  • 도ꡬ μ‹€ν–‰ context ( log , reportProgress , session )

  • λ§€κ°œλ³€μˆ˜ μŠ€ν‚€λ§ˆ 검증을 μœ„ν•œ Zod

  • server.on (μ—°κ²° λ‘œκΉ…μš©)

  • (잠재적으둜) μ„Έμ…˜λ³„ 논리λ₯Ό μœ„ν•œ session.on

πŸ“‹ ν•„μˆ˜ 쑰건

  • Bun (v1.0 이상 ꢌμž₯): μ„€μΉ˜λ˜μ—ˆμœΌλ©° PATH에 μžˆμŠ΅λ‹ˆλ‹€.

  • PostgreSQL λ°μ΄ν„°λ² μ΄μŠ€: μ•‘μ„ΈμŠ€ 자격 증λͺ… 및 μ—°κ²°. μ‚¬μš©μžμ—κ²Œ information_schema 쿼리 κΆŒν•œμ΄ ν•„μš”ν•©λ‹ˆλ‹€.

βš™οΈ μ„€μΉ˜

μ˜΅μ…˜ 1: NPM νŒ¨ν‚€μ§€

# Install globally
npm install -g postgres-mcp

# Or install locally in your project
npm install postgres-mcp

npm νŒ¨ν‚€μ§€λŠ” https://www.npmjs.com/package/postgres-mcp μ—μ„œ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

μ˜΅μ…˜ 2: μ €μž₯μ†Œ 볡제

  1. μ €μž₯μ†Œλ₯Ό λ³΅μ œν•©λ‹ˆλ‹€.

    # Replace with your actual repository URL
    git clone https://github.com/llm-graph/postgres-mcp.git
    cd postgres-mcp
  2. 쒅속성 μ„€μΉ˜:

    bun install

πŸ”‘ ꡬ성(닀쀑 λ°μ΄ν„°λ² μ΄μŠ€ 및 선택적 인증)

μ μ ˆν•œ .env νŒŒμΌμ—μ„œ λ‘œλ“œλœ ν™˜κ²½ λ³€μˆ˜λ₯Ό 톡해 κ΅¬μ„±ν•©λ‹ˆλ‹€.

  1. ν™˜κ²½ νŒŒμΌμ„ λ§Œλ“­λ‹ˆλ‹€.

    • ν”„λ‘œλ•μ…˜μ˜ 경우: cp .env.example .env

    • 개발용: cp .env.development.example .env.development

  2. ν™˜κ²½ 파일 λ‘œλ”© μˆœμ„œ: μ„œλ²„λŠ” λ‹€μŒ μš°μ„ μˆœμœ„ μˆœμ„œμ— 따라 νŒŒμΌμ—μ„œ ν™˜κ²½ λ³€μˆ˜λ₯Ό λ‘œλ“œν•©λ‹ˆλ‹€.

    • .env.<NODE_ENV> (예: .env.development , .env.production , .env.staging )

    • .env.local (버전 μ œμ–΄λ˜μ§€ μ•ŠλŠ” 둜컬 μž¬μ •μ˜μš©)

    • .env (κΈ°λ³Έ λŒ€μ²΄) 이λ₯Ό 톡해 λ‹€μ–‘ν•œ ν™˜κ²½μ— 맞게 λ‹€μ–‘ν•œ ꡬ성이 κ°€λŠ₯ν•©λ‹ˆλ‹€.

  3. λ°μ΄ν„°λ² μ΄μŠ€ μ—°κ²°κ³Ό 인증을 μ •μ˜ν•˜λ €λ©΄ ν™˜κ²½ νŒŒμΌμ„ νŽΈμ§‘ν•˜μ„Έμš” .

    • DB_ALIASES - κ³ μœ ν•œ DB λ³„μΉ­μ˜ μ‰Όν‘œλ‘œ κ΅¬λΆ„λœ λͺ©λ‘

    • DEFAULT_DB_ALIAS - 도ꡬ ν˜ΈμΆœμ—μ„œ 'dbAlias'κ°€ μƒλž΅λœ 경우 κΈ°λ³Έ 별칭

    • 각 별칭에 λŒ€ν•œ λ°μ΄ν„°λ² μ΄μŠ€ μ—°κ²° μ„ΈλΆ€ 정보(예: DB_MAIN_HOST , DB_REPORTING_HOST )

    • 선택적 API ν‚€ 인증( ENABLE_AUTH , MCP_API_KEY )

# Example .env file - Key Variables

# REQUIRED: Comma-separated list of unique DB aliases
DB_ALIASES=main,reporting

# REQUIRED: Default alias if 'dbAlias' is omitted in tool calls
DEFAULT_DB_ALIAS=main

# OPTIONAL: Enable API Key auth (primarily for network transports)
ENABLE_AUTH=false
MCP_API_KEY=your_super_secret_api_key_here # CHANGE THIS

# Define DB connection details for each alias (DB_MAIN_*, DB_REPORTING_*, etc.)
DB_MAIN_HOST=localhost
DB_MAIN_PORT=5432
DB_MAIN_NAME=app_prod_db
DB_MAIN_USER=app_user
DB_MAIN_PASSWORD=app_secret_password
DB_MAIN_SSL=disable

# Alternative: Use connection URLs
# DB_MAIN_URL=postgres://user:password@localhost:5432/database?sslmode=require

# --- Optional: Server Logging Level ---
# LOG_LEVEL=info # debug, info, warn, error (defaults to info)

πŸš€ μ„œλ²„ μ‹€ν–‰(ν”„λ‘œμ„ΈμŠ€λ‘œ)

Bun을 μ‚¬μš©ν•˜μ—¬ 이 μ„œλ²„λ₯Ό 직접 μ‹€ν–‰ν•˜μ„Έμš”. AI ν΄λΌμ΄μ–ΈνŠΈ(Cursor와 μœ μ‚¬)κ°€ 일반적으둜 이 λͺ…령을 μ‹€ν–‰ν•˜κ³  관리해 μ€λ‹ˆλ‹€.

μ˜΅μ…˜ 1: κΈ€λ‘œλ²Œν•˜κ²Œ μ„€μΉ˜λœ νŒ¨ν‚€μ§€ μ‚¬μš©

  • μˆ˜λ™μœΌλ‘œ μ‹€ν–‰ν•˜λ €λ©΄: postgres-mcp

μ˜΅μ…˜ 2: ν”„λ‘œμ νŠΈμ—μ„œ νŒ¨ν‚€μ§€ μ‚¬μš©

  • ν”„λ‘œμ νŠΈμ—μ„œ μ‹€ν–‰ν•˜λ €λ©΄: npx postgres-mcp

  • λ˜λŠ” ν”„λ‘œκ·Έλž˜λ° λ°©μ‹μœΌλ‘œ κ°€μ Έμ˜€κΈ°:

    // server.js
    import { startServer } from 'postgres-mcp';
    
    // Start the MCP server
    startServer();

μ˜΅μ…˜ 3: 볡제된 μ €μž₯μ†Œμ—μ„œ

  • μˆ˜λ™μœΌλ‘œ μ‹€ν–‰ν•˜λ €λ©΄(ν…ŒμŠ€νŠΈμš©): bun run src/index.ts

  • μˆ˜λ™ 개발 λͺ¨λ“œ: bun run --watch src/index.ts

fastmcp CLI λ„κ΅¬λ‘œ ν…ŒμŠ€νŠΈ

  • λŒ€ν™”ν˜• 터미널: bunx fastmcp dev src/index.ts

  • μ›Ή UI 검사기: bunx fastmcp inspect src/index.ts

πŸ’» ν”„λ‘œκ·Έλž˜λ° API μ‚¬μš©(라이브러리둜)

postgres-mcpλŠ” λ…λ¦½ν˜• MCP μ„œλ²„λ‘œ μ‹€ν–‰ν•˜λŠ” 것 외에도 Node.js/TypeScript μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ—μ„œ 라이브러리둜 ν”„λ‘œκ·Έλž˜λ° λ°©μ‹μœΌλ‘œ μ‚¬μš©ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.

κΈ°λ³Έ μ‚¬μš©λ²•

import { createPostgresMcp } from 'postgres-mcp';

// Create the PostgresMcp instance
const postgresMcp = createPostgresMcp();

// Start the server
postgresMcp.start();

// Direct database operations
const results = await postgresMcp.executeQuery(
 'SELECT * FROM users WHERE role = $1',
 ['admin'],
 'main' // optional database alias
);

// When done, stop the server and close connections
await postgresMcp.stop();

직접 ν•¨μˆ˜ κ°€μ Έμ˜€κΈ°

더 κ°„λ‹¨ν•œ μ‚¬μš© μ‚¬λ‘€μ—μ„œλŠ” νŠΉμ • ν•¨μˆ˜λ₯Ό 직접 κ°€μ Έμ˜¬ 수 μžˆμŠ΅λ‹ˆλ‹€.

import { 
 initConnections, 
 closeConnections, 
 executeQuery, 
 executeCommand, 
 executeTransaction, 
 getTableSchema,
 getAllTableSchemas
} from 'postgres-mcp';

// Configure database connections
const dbConfigs = {
 main: {
 host: 'localhost',
 port: 5432,
 database: 'my_db',
 user: 'db_user',
 password: 'db_password'
 }
};

// Initialize connections
initConnections(dbConfigs);

// Execute a query
const results = await executeQuery(
 'SELECT * FROM users WHERE role = $1',
 ['admin'],
 'main'
);

// Get schema for a single table
const schema = await getTableSchema('users', 'main');

// Get schema for all tables in the database
const allSchemas = await getAllTableSchemas('main');

// Close connections when done
await closeConnections();

ꡬ성 μ˜΅μ…˜

const postgresMcp = createPostgresMcp({
 // Custom database configurations (override .env)
 databaseConfigs: {
 main: {
 host: 'localhost',
 port: 5432,
 database: 'app_db',
 user: 'app_user',
 password: 'password',
 ssl: 'disable'
 }
 },
 // Server configuration
 serverConfig: {
 name: 'Custom PostgresMCP',
 defaultDbAlias: 'main'
 },
 // Transport options: 'stdio', 'sse', or 'http'
 transport: 'http',
 port: 3456
});

ν”„λ‘œκ·Έλž˜λ° API에 λŒ€ν•œ 전체 μ„€λͺ…μ„œλŠ” docs/programmatic-api.mdλ₯Ό μ°Έμ‘°ν•˜μ„Έμš”.

πŸ”Œ AI ν΄λΌμ΄μ–ΈνŠΈ(Cursor, Claude Desktop)와 μ—°κ²°

AI μ—μ΄μ „νŠΈ(MCP ν΄λΌμ΄μ–ΈνŠΈ)λ₯Ό κ΅¬μ„±ν•˜μ—¬ λͺ…λ Ή/인수 λ©”μ»€λ‹ˆμ¦˜μ„ 톡해 이 μ„œλ²„ 슀크립트λ₯Ό μ‹€ν–‰ν•˜μ„Έμš” .

μ»€μ„œ AI - μžμ„Έν•œ 예

  1. μ»€μ„œ μ„€μ •/ν™˜κ²½ 섀정을 μ—½λ‹ˆλ‹€(Cmd+, λ˜λŠ” Ctrl+,).

  2. "ν™•μž₯ ν”„λ‘œκ·Έλž¨" -> "MCP"둜 μ΄λ™ν•©λ‹ˆλ‹€.

  3. "MCP μ„œλ²„ μΆ”κ°€"λ₯Ό ν΄λ¦­ν•˜κ±°λ‚˜ settings.json νŽΈμ§‘ν•©λ‹ˆλ‹€.

  4. λ‹€μŒ JSON ꡬ성을 μΆ”κ°€ν•©λ‹ˆλ‹€.

    // In Cursor's settings.json or MCP configuration UI
    {
     "mcpServers": {
     "postgres-mcp": { // Unique name for Cursor
     "description": "MCP Server for PostgreSQL DBs (Main, Reporting)",
     "command": "bunx", // Use 'bun' or provide absolute path: "/Users/your_username/.bun/bin/bun"
     "args": [
     "postgres-mcp"
     // or
     // *** ABSOLUTE PATH to your server's entry point ***
     // "/Users/your_username/projects/postgres-mcp/src/index.ts" /
     ],
     "env": {
     // .env file in project dir is loaded automatically by Bun.
     // Add overrides or Cursor-specific vars here if needed.
     },
     "enabled": true
     }
     }
    }
  5. μ»€μ„œλ₯Ό μ €μž₯ ν•˜κ³  λ‹€μ‹œ μ‹œμž‘ν•˜κ±°λ‚˜ "MCP μ„œλ²„ λ‹€μ‹œ λ‘œλ“œ"λ₯Ό ν΄λ¦­ν•©λ‹ˆλ‹€.

  6. μ»€μ„œμ˜ MCP μƒνƒœ/λ‘œκ·Έμ—μ„œ 연결을 ν™•μΈν•˜μ„Έμš” .

ν΄λ‘œλ“œ λ°μŠ€ν¬νƒ‘

  1. config.json μ°Ύμ•„ νŽΈμ§‘ν•©λ‹ˆλ‹€(κ²½λ‘œλŠ” 이전 README μ°Έμ‘°).

  2. args 에 μ ˆλŒ€ 경둜λ₯Ό μ‚¬μš©ν•˜μ—¬ mcpServers μ•„λž˜μ— λΉ„μŠ·ν•œ ν•­λͺ©μ„ μΆ”κ°€ν•©λ‹ˆλ‹€.

  3. Claude Desktop을 λ‹€μ‹œ μ‹œμž‘ν•©λ‹ˆλ‹€.

πŸ› οΈ MCP κΈ°λŠ₯ 곡개

인증(선택 사항)

  • ENABLE_AUTH=true 경우 MCP_API_KEY 와 μΌμΉ˜ν•˜λŠ” X-API-Key 헀더λ₯Ό 톡해 λ„€νŠΈμ›Œν¬ 전솑(HTTP/SSE)을 λ³΄ν˜Έν•©λ‹ˆλ‹€.

  • stdio μ—°κ²°(Cursor/Claude의 κΈ°λ³Έκ°’)은 일반적으둜 이 검사λ₯Ό μš°νšŒν•©λ‹ˆλ‹€.

μžμ›

1. λ°μ΄ν„°λ² μ΄μŠ€ ν…Œμ΄λΈ” λ‚˜μ—΄

  • URI ν…œν”Œλ¦Ώ: db://{dbAlias}/schema/tables

  • μ„€λͺ…: μ§€μ •λœ λ°μ΄ν„°λ² μ΄μŠ€ 별칭(일반적으둜 'public' μŠ€ν‚€λ§ˆμ—μ„œ) λ‚΄μ˜ μ‚¬μš©μž ν…Œμ΄λΈ” 이름 λͺ©λ‘μ„ κ²€μƒ‰ν•©λ‹ˆλ‹€.

  • λ¦¬μ†ŒμŠ€ μ •μ˜( addResourceTemplate ):

    • uriTemplate : "db://{dbAlias}/schema/tables"

    • arguments :

      • dbAlias : (λ¬Έμžμ—΄, ν•„μˆ˜) - λ°μ΄ν„°λ² μ΄μŠ€μ˜ 별칭( .env μ—μ„œ).

    • load({ dbAlias }) : λ°μ΄ν„°λ² μ΄μŠ€μ— μ—°κ²°ν•˜κ³  information_schema.tables (곡개 μŠ€ν‚€λ§ˆμ˜ κΈ°λ³Έ ν…Œμ΄λΈ”μ— λŒ€ν•΄ 필터링, κ΅¬ν˜„ μ‹œ μ‚¬μš©μž μ •μ˜ κ°€λŠ₯)λ₯Ό μΏΌλ¦¬ν•˜κ³  κ²°κ³Όλ₯Ό JSON λ¬Έμžμ—΄ λ°°μ—΄ ["table1", "table2", ...] 둜 ν¬λ§·ν•˜κ³  { text: "..." } λ°˜ν™˜ν•©λ‹ˆλ‹€.

μ‚¬μš© 예(AI ν”„λ‘¬ν”„νŠΈ): "κΈ°λ³Έ λ°μ΄ν„°λ² μ΄μŠ€μ˜ ν…Œμ΄λΈ”μ„ λ‚˜μ—΄ν•˜λ €λ©΄ λ¦¬μ†ŒμŠ€ db://main/schema/tables κ°€μ Έμ˜΅λ‹ˆλ‹€."

2. ν…Œμ΄λΈ” μŠ€ν‚€λ§ˆ 검사

  • URI ν…œν”Œλ¦Ώ: db://{dbAlias}/schema/{tableName}

  • μ„€λͺ…: νŠΉμ • ν…Œμ΄λΈ”μ— λŒ€ν•œ μžμ„Έν•œ μŠ€ν‚€λ§ˆ 정보(μ—΄, μœ ν˜•, NULL ν—ˆμš© μ—¬λΆ€, κΈ°λ³Έκ°’)λ₯Ό μ œκ³΅ν•©λ‹ˆλ‹€.

  • λ¦¬μ†ŒμŠ€ μ •μ˜( addResourceTemplate ):

    • uriTemplate : "db://{dbAlias}/schema/{tableName}"

    • arguments :

      • dbAlias : (λ¬Έμžμ—΄, ν•„μˆ˜) - λ°μ΄ν„°λ² μ΄μŠ€ 별칭.

      • tableName : (λ¬Έμžμ—΄, ν•„μˆ˜) - ν…Œμ΄λΈ”μ˜ μ΄λ¦„μž…λ‹ˆλ‹€.

    • load({ dbAlias, tableName }) : μ—°κ²°ν•˜κ³ , νŠΉμ • ν…Œμ΄λΈ”μ— λŒ€ν•œ information_schema.columns μΏΌλ¦¬ν•˜κ³ , μ—΄ 개체의 JSON λ¬Έμžμ—΄ λ°°μ—΄λ‘œ ν¬λ§·ν•˜κ³ , { text: "..." } λ°˜ν™˜ν•©λ‹ˆλ‹€.

μ‚¬μš© μ˜ˆμ‹œ(AI ν”„λ‘¬ν”„νŠΈ): " db://reporting/schema/daily_sales λ¦¬μ†ŒμŠ€λ₯Ό μ„€λͺ…ν•˜μ„Έμš”."

응닡 λ‚΄μš© 예(JSON λ¬Έμžμ—΄):

"[{\"column_name\":\"session_id\",\"data_type\":\"uuid\",\"is_nullable\":\"NO\",\"column_default\":\"gen_random_uuid()\"},{\"column_name\":\"user_id\",\"data_type\":\"integer\",\"is_nullable\":\"NO\",\"column_default\":null},{\"column_name\":\"created_at\",\"data_type\":\"timestamp with time zone\",\"is_nullable\":\"YES\",\"column_default\":\"now()\"},{\"column_name\":\"expires_at\",\"data_type\":\"timestamp with time zone\",\"is_nullable\":\"YES\",\"column_default\":null}]"

도ꡬ

λ„κ΅¬λŠ” context 객체( log , reportProgress , session )λ₯Ό μˆ˜μ‹ ν•©λ‹ˆλ‹€.


1. query_tool

읽기 μ „μš© SQL 쿼리λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.

  • μ„€λͺ…: μ‹€ν–‰ λ‘œκΉ…/μ§„ν–‰ 상황을 κΈ°λ‘ν•˜μ—¬ 읽기 μ „μš© SQL을 μ•ˆμ „ν•˜κ²Œ μ‹€ν–‰ν•˜κ³  κ²°κ³Όλ₯Ό μ–»μŠ΅λ‹ˆλ‹€.

  • λ§€κ°œλ³€μˆ˜: statement (λ¬Έμžμ—΄), params (λ°°μ—΄, opt), dbAlias (λ¬Έμžμ—΄, opt).

  • μ»¨ν…μŠ€νŠΈ μ‚¬μš©: log.info/debug , 선택적 reportProgress , μ•‘μ„ΈμŠ€ session .

  • λ°˜ν™˜: ν–‰ λ°°μ—΄μ˜ JSON λ¬Έμžμ—΄.

μš”μ²­ μ˜ˆμ‹œ:

{
 "tool_name": "query_tool",
 "arguments": {
 "statement": "SELECT product_id, name, price FROM products WHERE category = $1 AND price < $2 ORDER BY name LIMIT 10",
 "params": ["electronics", 500],
 "dbAlias": "main"
 }
}

응닡 λ‚΄μš© 예(JSON λ¬Έμžμ—΄):

"[{\"product_id\":123,\"name\":\"Example Gadget\",\"price\":499.99},{\"product_id\":456,\"name\":\"Another Device\",\"price\":350.00}]"

2. execute_tool

데이터λ₯Ό μˆ˜μ •ν•˜λŠ” SQL 문을 μ‹€ν–‰ν•©λ‹ˆλ‹€.

  • μ„€λͺ…: μ‹€ν–‰ λ‘œκΉ…μ„ 톡해 데이터λ₯Ό μˆ˜μ •ν•˜λŠ” SQL을 μ•ˆμ „ν•˜κ²Œ μ‹€ν–‰ν•©λ‹ˆλ‹€.

  • λ§€κ°œλ³€μˆ˜: statement (λ¬Έμžμ—΄), params (λ°°μ—΄, opt), dbAlias (λ¬Έμžμ—΄, opt).

  • μ»¨ν…μŠ€νŠΈ μ‚¬μš©: log.info/debug , session 에 μ ‘κ·Όν•©λ‹ˆλ‹€.

  • λ°˜ν™˜κ°’: 영ν–₯을 λ°›λŠ” 행을 λ‚˜νƒ€λ‚΄λŠ” λ¬Έμžμ—΄μž…λ‹ˆλ‹€.

μš”μ²­ μ˜ˆμ‹œ:

{
 "tool_name": "execute_tool",
 "arguments": {
 "statement": "UPDATE users SET last_login = NOW() WHERE user_id = $1",
 "params": [54321]
 // dbAlias omitted, uses DEFAULT_DB_ALIAS
 }
}

응닡 λ‚΄μš© μ˜ˆμ‹œ(λ¬Έμžμ—΄):

"Rows affected: 1"

3. schema_tool

νŠΉμ • ν…Œμ΄λΈ”μ— λŒ€ν•œ μžμ„Έν•œ μŠ€ν‚€λ§ˆ 정보λ₯Ό κ²€μƒ‰ν•©λ‹ˆλ‹€.

  • μ„€λͺ…: λ°μ΄ν„°λ² μ΄μŠ€ ν…Œμ΄λΈ”μ— λŒ€ν•œ μ—΄ μ •μ˜μ™€ μ„ΈλΆ€ 정보λ₯Ό κ°€μ Έμ˜΅λ‹ˆλ‹€.

  • λ§€κ°œλ³€μˆ˜: tableName (λ¬Έμžμ—΄), dbAlias (λ¬Έμžμ—΄, opt).

  • μ»¨ν…μŠ€νŠΈ μ‚¬μš©: log.info , μ•‘μ„ΈμŠ€ session .

  • λ°˜ν™˜: μ—΄ 정보 객체의 JSON λ¬Έμžμ—΄ λ°°μ—΄μž…λ‹ˆλ‹€.

μš”μ²­ μ˜ˆμ‹œ:

{
 "tool_name": "schema_tool",
 "arguments": {
 "tableName": "user_sessions",
 "dbAlias": "main"
 }
}

응닡 λ‚΄μš© 예(JSON λ¬Έμžμ—΄):

"[{\"column_name\":\"session_id\",\"data_type\":\"uuid\",\"is_nullable\":\"NO\",\"column_default\":\"gen_random_uuid()\"},{\"column_name\":\"user_id\",\"data_type\":\"integer\",\"is_nullable\":\"NO\",\"column_default\":null},{\"column_name\":\"created_at\",\"data_type\":\"timestamp with time zone\",\"is_nullable\":\"YES\",\"column_default\":\"now()\"},{\"column_name\":\"expires_at\",\"data_type\":\"timestamp with time zone\",\"is_nullable\":\"YES\",\"column_default\":null}]"

4. transaction_tool

μ—¬λŸ¬ SQL 문을 μ›μžμ μœΌλ‘œ μ‹€ν–‰ν•©λ‹ˆλ‹€.

  • μ„€λͺ…: 단계별 λ‘œκΉ…/μ§„ν–‰ 상황을 κΈ°λ‘ν•˜μ—¬ νŠΈλžœμž­μ…˜μ—μ„œ SQL μ‹œν€€μŠ€λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.

  • λ§€κ°œλ³€μˆ˜: operations ({statement, params}의 λ°°μ—΄), dbAlias (λ¬Έμžμ—΄, opt).

  • μ»¨ν…μŠ€νŠΈ μ‚¬μš©: log.info/debug/error , reportProgress , access session .

  • λ°˜ν™˜: 성곡/μ‹€νŒ¨λ₯Ό μš”μ•½ν•œ JSON λ¬Έμžμ—΄: {"success": true, "results": [...]} λ˜λŠ” {"success": false, "error": ..., "failedOperationIndex": ...} .

μš”μ²­ μ˜ˆμ‹œ:

{
 "tool_name": "transaction_tool",
 "arguments": {
 "operations": [
 {
 "statement": "INSERT INTO orders (customer_id, order_date, status) VALUES ($1, NOW(), 'pending') RETURNING order_id",
 "params": [101]
 },
 {
 "statement": "INSERT INTO order_items (order_id, product_sku, quantity, price) VALUES ($1, $2, $3, $4)",
 "params": [9999, "GADGET-X", 2, 49.99]
 },
 {
 "statement": "UPDATE inventory SET stock_count = stock_count - $1 WHERE product_sku = $2 AND stock_count >= $1",
 "params": [2, "GADGET-X"]
 }
 ],
 "dbAlias": "main"
 }
}

성곡 응닡 μ½˜ν…μΈ  μ˜ˆμ‹œ(JSON λ¬Έμžμ—΄):

"{\"success\":true,\"results\":[{\"operation\":0,\"rowsAffected\":1},{\"operation\":1,\"rowsAffected\":1},{\"operation\":2,\"rowsAffected\":1}]}"

였λ₯˜ 응닡 λ‚΄μš© 예(JSON λ¬Έμžμ—΄):

"{\"success\":false,\"error\":\"Error executing operation 2: new row for relation \\\"inventory\\\" violates check constraint \\\"stock_count_non_negative\\\"\",\"failedOperationIndex\":2}"

μ„œλ²„ 및 μ„Έμ…˜ 이벀트

  • ν΄λΌμ΄μ–ΈνŠΈ 연결을 λ‘œκΉ…ν•˜λ €λ©΄ server.on('connect'/'disconnect') μ‚¬μš©ν•©λ‹ˆλ‹€.

  • ν•„μš”ν•œ 경우 보닀 세뢀적인 μ„Έμ…˜ 이벀트 처리λ₯Ό μœ„ν•΄ session.on(...) μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

πŸ”’ λ³΄μ•ˆ κ³ λ € 사항

  • SQL μ£Όμž…: λ§€κ°œλ³€μˆ˜ν™”λœ 쿼리λ₯Ό 톡해 μ™„ν™”λ©λ‹ˆλ‹€. 직접적인 μž…λ ₯ 연결은 μ—†μŠ΅λ‹ˆλ‹€.

  • λ°μ΄ν„°λ² μ΄μŠ€ κΆŒν•œ: μ€‘μš”. 각 DB_<ALIAS>_USER 에 μ΅œμ†Œν•œμ˜ κΆŒν•œμ„ ν• λ‹Ήν•˜μ„Έμš”. μ—¬κΈ°μ—λŠ” μŠ€ν‚€λ§ˆ/ν…Œμ΄λΈ” λͺ©λ‘ λ¦¬μ†ŒμŠ€μ— λŒ€ν•œ information_schema 읽기 κΆŒν•œμ΄ ν¬ν•¨λ©λ‹ˆλ‹€.

  • SSL/TLS: ν”„λ‘œλ•μ…˜μ— ν•„μˆ˜ ( DB_<ALIAS>_SSL=require λ˜λŠ” stricter).

  • λΉ„λ°€ 관리: .env νŒŒμΌμ„ λ³΄ν˜Έν•˜μ„Έμš”( .gitignore νŒŒμΌμ— μΆ”κ°€). 운영 ν™˜κ²½(Vault, Doppler, ν΄λΌμš°λ“œ λΉ„λ°€)에 μ•ˆμ „ν•œ λΉ„λ°€ 관리λ₯Ό μ‚¬μš©ν•˜μ„Έμš”.

  • 인증 λ²”μœ„: authenticate ν›„ν¬λŠ” 주둜 λ„€νŠΈμ›Œν¬ 전솑을 λ³΄ν˜Έν•©λ‹ˆλ‹€. stdio λ³΄μ•ˆμ€ μ‹€ν–‰ ν™˜κ²½μ— 따라 λ‹¬λΌμ§‘λ‹ˆλ‹€.

  • 데이터 민감성: μ—°κ²°/도ꡬλ₯Ό 톡해 μ ‘κ·Ό κ°€λŠ₯ν•œ 데이터λ₯Ό νŒŒμ•…ν•˜μ„Έμš”.

  • λ¦¬μ†ŒμŠ€ 쿼리: ν…Œμ΄λΈ”( information_schema.tables ) 및 μŠ€ν‚€λ§ˆ( information_schema.columns )λ₯Ό λ‚˜μ—΄ν•˜λŠ” 데 μ‚¬μš©λ˜λŠ” μΏΌλ¦¬λŠ” 일반적으둜 μ•ˆμ „ν•˜μ§€λ§Œ λ°μ΄ν„°λ² μ΄μŠ€ κΆŒν•œμ— μ˜μ‘΄ν•©λ‹ˆλ‹€. κ΅¬μ„±λœ μ‚¬μš©μžμ—κ²Œ μ μ ˆν•œ 읽기 κΆŒν•œμ΄ μžˆλŠ”μ§€ ν™•μΈν•˜μ‹­μ‹œμ˜€. λ³΄μ•ˆ λ˜λŠ” λͺ…확성을 μœ„ν•΄ ν•„μš”ν•œ 경우 ν…Œμ΄λΈ” λ‚˜μ—΄ 쿼리(예: μŠ€ν‚€λ§ˆ 필터링)λ₯Ό μ‚¬μš©μž μ •μ˜ν•˜μ‹­μ‹œμ˜€.

πŸ“œ λΌμ΄μ„ΌμŠ€

이 ν”„λ‘œμ νŠΈλŠ” MIT λΌμ΄μ„ μŠ€ 에 따라 λΌμ΄μ„ μŠ€κ°€ λΆ€μ—¬λ©λ‹ˆλ‹€. μžμ„Έν•œ λ‚΄μš©μ€ λΌμ΄μ„ μŠ€ νŒŒμΌμ„ μ°Έμ‘°ν•˜μ„Έμš”.

πŸ“‹ λ³€κ²½ 사항

1.0.0

  • 졜초 μΆœμ‹œ

  • PostgreSQL을 μœ„ν•œ λͺ¨λ“  κΈ°λŠ₯을 κ°–μΆ˜ MCP μ„œλ²„

  • 닀쀑 λ°μ΄ν„°λ² μ΄μŠ€ μ—°κ²° 지원

  • 쿼리, μ‹€ν–‰, μŠ€ν‚€λ§ˆ 검사 및 νŠΈλžœμž­μ…˜μ„ μœ„ν•œ 도ꡬ

  • μŠ€ν‚€λ§ˆ 내성을 μœ„ν•œ λ¦¬μ†ŒμŠ€

  • 포괄적인 λ¬Έμ„œ 및 예제

A
license - permissive license
B
quality
D
maintenance

Maintenance

–Maintainers
–Response time
–Release cycle
–Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

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/llm-graph/postgres-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server