Skip to main content
Glama
MIT License
23
17
  • Linux
  • Apple

MCP 데이터베이스 서버

다양한 데이터베이스 시스템에 연결하고 작업하기 위한 MCP(모델 컨텍스트 프로토콜) 구현입니다.

지원되는 데이터베이스

  • SQLite
  • 포스트그레스큐엘
  • 마이크로소프트 SQL 서버
  • 몽고디비

설치

지엑스피1

용법

MCP 데이터베이스 서버는 두 가지 모드로 사용할 수 있습니다.

SSE 모드(기본값)

기본적으로 서버는 포트 3001에서 SSE(Server-Sent Events) 모드로 실행됩니다.

npx mcp-dbs

이렇게 하면 http://localhost:3001/mcp 에서 SSE 엔드포인트가 있는 HTTP 서버가 시작됩니다.

사용자 정의 포트

--port 옵션을 사용하여 사용자 정의 포트를 지정할 수 있습니다.

npx mcp-dbs --port 8080

STDIO 모드

표준 입출력을 통해 통신하는 도구의 경우 --stdio 옵션을 사용할 수 있습니다.

npx mcp-dbs --stdio

Claude 데스크톱 통합

Claude 설정 파일에 mcp-dbs를 추가하면 Claude Desktop과 통합할 수 있습니다.

구성 단계

  1. Claude Desktop 구성 파일을 열거나 만드세요
  2. mcpServers 섹션에 mcp-dbs 구성을 추가합니다.
{ "mcpServers": { "mcp-dbs": { "command": "node", "args": [ "/path/to/your/mcp-dbs/dist/cli.js", "--stdio" ], "env": { "MCP_MONGODB_URI": "mongodb://localhost:27017", "MCP_MONGODB_DATABASE": "your-database-name" } } } }

환경 변수를 사용자의 데이터베이스 연결 세부정보로 바꾸세요.

노트

  • command``node 여야 합니다.
  • args 에 mcp-dbs 설치의 cli.js 파일에 대한 절대 경로를 제공하세요.
  • 데이터베이스 유형에 적합한 환경 변수를 구성하세요(아래 환경 변수 섹션 참조)
  • 지원되는 모든 데이터베이스(SQLite, PostgreSQL, SQL Server 또는 MongoDB)에 환경 변수를 사용할 수 있습니다.

Claude와 함께 사용

설정이 완료되면 Claude는 아래 설명된 MCP 도구를 사용하여 데이터베이스에 액세스할 수 있습니다. Claude에게 다음 작업을 요청할 수 있습니다.

  • 데이터베이스에 연결하세요
  • 쿼리를 실행하고 결과를 얻습니다.
  • 데이터베이스 스키마 탐색
  • 테이블 및 데이터 작업

도구

  • connect-database : 데이터베이스에 연결
  • disconnect-database : 데이터베이스와의 연결을 끊습니다.
  • execute-query : 쿼리를 실행하고 결과를 반환합니다.
  • execute-update : 결과를 반환하지 않고 쿼리를 실행합니다.

자원

  • database-schema : 전체 데이터베이스 스키마를 가져옵니다.
  • table-schema : 특정 테이블의 스키마를 가져옵니다
  • tables-list : 모든 테이블 목록을 가져옵니다

구성을 위한 환경 변수 사용

환경 변수를 사용하여 데이터베이스 연결을 구성할 수 있습니다.

SQLite
# Set these environment variables before connecting export MCP_SQLITE_FILENAME="path/to/database.db" export MCP_SQLITE_CREATE_IF_NOT_EXISTS="true"
포스트그레스큐엘
# Set these environment variables before connecting export MCP_POSTGRES_HOST="your-postgres-host" export MCP_POSTGRES_PORT="5432" export MCP_POSTGRES_DATABASE="your-database-name" export MCP_POSTGRES_USER="your-username" export MCP_POSTGRES_PASSWORD="your-password" export MCP_POSTGRES_SSL="false"
SQL 서버
# Set these environment variables before connecting export MCP_MSSQL_SERVER="your-server-address" export MCP_MSSQL_PORT="1433" export MCP_MSSQL_DATABASE="your-database-name" export MCP_MSSQL_USER="your-username" export MCP_MSSQL_PASSWORD="your-password" export MCP_MSSQL_ENCRYPT="true" export MCP_MSSQL_TRUST_SERVER_CERTIFICATE="true"
몽고디비
# Set these environment variables before connecting export MCP_MONGODB_URI="mongodb://localhost:27017" export MCP_MONGODB_DATABASE="your-database-name" export MCP_MONGODB_MAX_POOL_SIZE="10" export MCP_MONGODB_USE_UNIFIED_TOPOLOGY="true"

이러한 환경 변수는 connect-database 도구에 전달된 모든 구성보다 우선합니다.

MCP 도구

서버는 다음과 같은 MCP 도구를 제공합니다.

연결-데이터베이스

데이터베이스에 연결합니다.

매개변수:

  • connectionId : 연결에 대한 고유 식별자
  • type : 데이터베이스 유형( sqlite , postgres , mssql 또는 mongodb )

SQLite의 예:

{ "connectionId": "my-sqlite-db", "type": "sqlite" }

PostgreSQL의 예:

{ "connectionId": "my-postgres-db", "type": "postgres" }

SQL Server의 예:

{ "connectionId": "my-mssql-db", "type": "mssql" }

MongoDB의 예:

{ "connectionId": "my-mongodb-db", "type": "mongodb" }

데이터베이스 연결 해제

데이터베이스와의 연결을 끊습니다.

매개변수:

  • connectionId : 연결을 끊을 연결 ID

실행 쿼리

결과를 반환하는 쿼리를 실행합니다.

매개변수:

  • connectionId : 연결 ID
  • query : SQL 쿼리 또는 MongoDB 집계 파이프라인(JSON 문자열)
  • params : (선택 사항) 쿼리에 대한 매개변수 배열입니다. MongoDB의 경우 첫 번째 매개변수는 컬렉션 이름입니다.

SQL의 예:

{ "connectionId": "my-postgres-db", "query": "SELECT * FROM users WHERE age > $1", "params": [21] }

MongoDB의 예:

{ "connectionId": "my-mongodb-db", "query": "[{\"$match\": {\"age\": {\"$gt\": 21}}}, {\"$sort\": {\"name\": 1}}]", "params": ["users"] }

MongoDB의 예(임베디드 컬렉션이 있는 새로운 형식):

{ "connectionId": "my-mongodb-db", "query": "{\"collection\": \"users\", \"pipeline\": [{\"$match\": {\"age\": {\"$gt\": 21}}}, {\"$sort\": {\"name\": 1}}]}" }

MongoDB의 예(셸 구문):

{ "connectionId": "my-mongodb-db", "query": "db.getCollection('users').find({\"age\": {\"$gt\": 21}})" }

MongoDB의 예(직접 컬렉션 참조 셸 구문):

{ "connectionId": "my-mongodb-db", "query": "db.users.find({\"age\": {\"$gt\": 21}})" }

MongoDB의 예(원시 명령):

{ "connectionId": "my-mongodb-db", "query": "{\"find\": \"users\", \"filter\": {\"age\": {\"$gt\": 21}}}" }

실행-업데이트

결과를 반환하지 않는 쿼리(INSERT, UPDATE, DELETE)를 실행합니다.

매개변수:

  • connectionId : 연결 ID
  • query : SQL 쿼리 또는 MongoDB 명령(JSON 문자열)
  • params : (선택 사항) 쿼리에 대한 매개변수 배열입니다. MongoDB의 경우 첫 번째 매개변수는 컬렉션 이름입니다.

SQL의 예:

{ "connectionId": "my-postgres-db", "query": "INSERT INTO users (name, age) VALUES ($1, $2)", "params": ["John Doe", 30] }

MongoDB의 예:

{ "connectionId": "my-mongodb-db", "query": "{\"insertOne\": {\"name\": \"John Doe\", \"age\": 30}}", "params": ["users"] }

MongoDB의 예(임베디드 컬렉션이 있는 새로운 형식):

{ "connectionId": "my-mongodb-db", "query": "{\"collection\": \"users\", \"operation\": {\"insertOne\": {\"name\": \"John Doe\", \"age\": 30}}}" }

MongoDB의 예(셸 구문):

{ "connectionId": "my-mongodb-db", "query": "db.getCollection('users').insertOne({\"name\": \"John Doe\", \"age\": 30})" }

MongoDB의 예(직접 컬렉션 참조 셸 구문):

{ "connectionId": "my-mongodb-db", "query": "db.users.insertOne({\"name\": \"John Doe\", \"age\": 30})" }

MongoDB의 예(원시 명령):

{ "connectionId": "my-mongodb-db", "query": "{\"insert\": \"users\", \"documents\": [{\"name\": \"John Doe\", \"age\": 30}]}" }

MCP 리소스

서버는 다음과 같은 MCP 리소스를 제공합니다.

데이터베이스 스키마

URI: database://{connectionId}/schema

모든 테이블과 열을 포함하여 데이터베이스에 대한 스키마 정보를 반환합니다.

테이블 스키마

URI: database://{connectionId}/tables/{tableName}

열을 포함하여 특정 테이블의 스키마 정보를 반환합니다.

테이블 목록

URI: database://{connectionId}/tables

데이터베이스에 있는 모든 테이블의 목록을 반환합니다.

개발

테스트

테스트를 실행하세요:

npm test

프로젝트 지원하기

만약 이 프로젝트가 도움이 된다면, 저에게 커피 한 잔 사주세요!

위의 QR 코드를 스캔하거나 여기를 클릭하여 이 프로젝트 개발을 지원해주세요.

특허

MIT

Related MCP Servers

  • A
    security
    A
    license
    A
    quality
    A powerful Model Context Protocol (MCP) tool for exploring and managing different types of databases including PostgreSQL, MySQL, and Firestore.
    Last updated -
    9
    3
    TypeScript
    MIT License
  • A
    security
    A
    license
    A
    quality
    🗂️ A Model Context Protocol (MCP) server that provides integration with Turso databases for LLMs. This server implements a two-level authentication system to handle both organization-level and database-level operations, making it easy to manage and query Turso databases directly from LLMs.
    Last updated -
    8
    26
    6
    TypeScript
    MIT License
    • Linux
  • -
    security
    -
    license
    -
    quality
    A Model Context Protocol server that provides tools for connecting to and interacting with various database systems (SQLite, PostgreSQL, MySQL/MariaDB, SQL Server) through a unified interface.
    Last updated -
    Python
  • A
    security
    F
    license
    A
    quality
    A Model Context Protocol (MCP) server that interacts with system APIs, allowing users to check connections, search employees, register breakfast, and update chemical information by shifts.
    Last updated -
    21
    37
    JavaScript

View all related MCP servers

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/cuongtl1992/mcp-dbs'

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