MCP 문서 관리

메뉴

DBHub

DBHub

DBHub는 다양한 데이터베이스에 연결할 수 있는 유니버설 데이터베이스 MCP 서버입니다. Model Context Protocol(MCP) 서버 인터페이스를 구현하여 MCP 호환 클라이언트가 여러 종류의 데이터베이스에 연결하고 탐색할 수 있게 합니다. MySQL, PostgreSQL, SQLite, DuckDB, MariaDB, SQL Server, Oracle 등 다양한 데이터베이스를 지원합니다.

특징

  • 다양한 데이터베이스 시스템 지원 (PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, Oracle)
  • 데모 모드에서 샘플 직원 데이터베이스를 제공하여 쉽게 테스트 가능
  • 스키마, 테이블, 인덱스, 프로시저 등 데이터베이스 구조 탐색 기능
  • SQL 쿼리 실행 기능
  • SSL/TLS 암호화 옵션 지원
  • 읽기 전용 모드 지원으로 보안 강화
  • stdio 및 sse 전송 옵션 지원
  • Claude Desktop 및 Cursor와 같은 MCP 클라이언트와 호환

제공 리소스

DBHub는 다음과 같은 데이터베이스 리소스를 제공합니다:

리소스 이름 URI 형식 지원 데이터베이스
스키마 db://schemas PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, Oracle
스키마의 테이블 db://schemas/{schemaName}/tables PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, Oracle
스키마의 테이블 구조 db://schemas/{schemaName}/tables/{tableName} PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, Oracle
테이블의 인덱스 db://schemas/{schemaName}/tables/{tableName}/indexes PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, Oracle
스키마의 프로시저 db://schemas/{schemaName}/procedures PostgreSQL, MySQL, MariaDB, SQL Server, Oracle
스키마의 프로시저 상세 db://schemas/{schemaName}/procedures/{procedureName} PostgreSQL, MySQL, MariaDB, SQL Server, Oracle

제공 도구

데이터베이스 작업 도구

  • execute_sql: SQL 쿼리 실행
  • 필수 매개변수: 실행할 SQL 쿼리
  • 지원 데이터베이스: PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, Oracle

  • list_connectors: 연결 가능한 데이터베이스 목록 조회

  • 필수 매개변수 없음
  • 지원 데이터베이스: PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, Oracle

프롬프트

  • generate_sql: SQL 쿼리 생성
  • 지원 데이터베이스: PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, Oracle

  • explain_db: 데이터베이스 요소 설명

  • 지원 데이터베이스: PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, Oracle

설치 및 사용 방법

Docker를 이용한 설치

PostgreSQL 예시:

docker run --rm --init \
  --name dbhub \
  --publish 8080:8080 \
  bytebase/dbhub \
  --transport sse \
  --port 8080 \
  --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"

데모 모드 (샘플 직원 데이터베이스 포함):

docker run --rm --init \
  --name dbhub \
  --publish 8080:8080 \
  bytebase/dbhub \
  --transport sse \
  --port 8080 \
  --demo

NPM을 이용한 설치

PostgreSQL 예시:

npx @bytebase/dbhub --transport sse --port 8080 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"

데모 모드:

npx @bytebase/dbhub --transport sse --port 8080 --demo

Claude Desktop 구성

Claude Desktop은 stdio 전송만 지원합니다. claude_desktop_config.json 파일에 다음 구성을 추가하세요:

{
  "mcpServers": {
    "dbhub-postgres-docker": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "bytebase/dbhub",
        "--transport",
        "stdio",
        "--dsn",
        "postgres://user:password@host.docker.internal:5432/dbname?sslmode=disable"
      ]
    },
    "dbhub-postgres-npx": {
      "command": "npx",
      "args": [
        "-y",
        "@bytebase/dbhub",
        "--transport",
        "stdio",
        "--dsn",
        "postgres://user:password@localhost:5432/dbname?sslmode=disable"
      ]
    },
    "dbhub-demo": {
      "command": "npx",
      "args": ["-y", "@bytebase/dbhub", "--transport", "stdio", "--demo"]
    }
  }
}

참고: Docker 내에서 실행할 때는 호스트 머신의 데이터베이스에 연결하려면 localhost 대신 host.docker.internal을 사용하세요.

구성 옵션

옵션 설명 기본값
demo 샘플 직원 데이터베이스가 포함된 데모 모드로 실행 false
dsn 데이터베이스 연결 문자열 데모 모드가 아닌 경우 필수
transport 전송 모드: stdio 또는 sse stdio
port HTTP 서버 포트 (--transport=sse 사용 시에만 적용) 8080
readonly SQL 실행을 읽기 전용 작업으로 제한 false

SSL 모드 옵션

DSN 문자열에 sslmode 매개변수를 사용하여 SSL 모드를 지정할 수 있습니다:

  • sslmode=disable: 모든 SSL/TLS 암호화를 비활성화합니다. 데이터는 평문으로 전송됩니다.
  • sslmode=require: 연결은 암호화되지만 서버 인증서는 확인되지 않습니다. 이는 패킷 스니핑을 방지하지만 중간자 공격에는 취약합니다. 신뢰할 수 있는 자체 서명 CA에 사용할 수 있습니다.

sslmode를 지정하지 않으면 대부분의 데이터베이스는 기본적으로 인증서 확인을 수행합니다.

예시:

# SSL 비활성화
postgres://user:password@localhost:5432/dbname?sslmode=disable
# 인증서 확인 없이 SSL 필요
postgres://user:password@localhost:5432/dbname?sslmode=require
# 인증서 확인을 포함한 표준 SSL (기본값)
postgres://user:password@localhost:5432/dbname

지원되는 데이터베이스 연결 문자열 형식

데이터베이스 DSN 형식 예시
MySQL mysql://[user]:[password]@[host]:[port]/[database] mysql://user:password@localhost:3306/dbname?sslmode=disable
MariaDB mariadb://[user]:[password]@[host]:[port]/[database] mariadb://user:password@localhost:3306/dbname?sslmode=disable
PostgreSQL postgres://[user]:[password]@[host]:[port]/[database] postgres://user:password@localhost:5432/dbname?sslmode=disable
SQL Server sqlserver://[user]:[password]@[host]:[port]/[database] sqlserver://user:password@localhost:1433/dbname?sslmode=disable
SQLite sqlite:///[path/to/file] 또는 sqlite::memory: sqlite:///path/to/database.db, sqlite:C:/Users/YourName/data/database.db (windows) 또는 sqlite::memory:
Oracle oracle://[user]:[password]@[host]:[port]/[service_name] oracle://username:password@localhost:1521/service_name?sslmode=disable

데모 모드

데모 모드는 직원, 부서, 급여 등에 대한 테이블이 포함된 SQLite 샘플 "직원" 데이터베이스를 번들로 제공합니다. 이를 통해 개발자는 자체 데이터베이스 환경을 설정하지 않고도 DBHub의 기능을 빠르게 테스트하고 실험할 수 있습니다.

데모 모드는 인 메모리 SQLite 데이터베이스를 사용하여 쉽게 배포할 수 있습니다.

디버깅

MCP Inspector를 사용하여 디버깅할 수 있습니다:

PostgreSQL 예시:

TRANSPORT=stdio DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable" npx @modelcontextprotocol/inspector node /path/to/dbhub/dist/index.js

또는 SSE 전송 모드에서:

# DBHub를 SSE 전송 모드로 시작
pnpm dev --transport=sse --port=8080
# 다른 터미널에서 MCP Inspector 시작
npx @modelcontextprotocol/inspector

연결된 구성 요소