legion-mcp

by TheRaLabs
Verified

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Supports integration with FastAPI for running the MCP server, providing both standalone and integrated deployment options

  • Provides database access capabilities for MySQL, supporting query execution and schema exploration

  • Enables querying and interacting with PostgreSQL databases through SQL execution tools and schema resources

데이터베이스 MCP 서버(Legion AI 제공)

Legion Query Runner와 Model Context Protocol(MCP) Python SDK를 통합하여 데이터베이스의 데이터에 액세스하고 쿼리하는 데 도움이 되는 서버입니다.

특징

  • Legion Query Runner를 통한 데이터베이스 액세스
  • AI 어시스턴트를 위한 MCP(모델 컨텍스트 프로토콜) 지원
  • 데이터베이스 작업을 MCP 리소스, 도구 및 프롬프트로 노출
  • 다양한 배포 옵션(독립형 MCP 서버, FastAPI 통합)
  • 쿼리 실행 및 결과 처리
  • 환경 변수, 명령줄 인수 또는 MCP 설정 JSON을 통한 유연한 구성

지원되는 데이터베이스

데이터 베이스DB_TYPE 코드
포스트그레스큐엘페이지
적색편이적색편이
바퀴벌레DB바퀴벌레
MySQLMySQL
RDS MySQLrds_mysql
마이크로소프트 SQL 서버MSSQL
빅 쿼리빅쿼리
오라클 DB신탁
SQLiteSQLite

Legion Query Runner 라이브러리를 커넥터로 사용합니다. 자세한 내용은 API 문서 에서 확인하실 수 있습니다.

MCP란 무엇인가요?

모델 컨텍스트 프로토콜(MCP)은 AI 애플리케이션에서 컨텍스트를 유지하기 위한 사양입니다. 이 서버는 MCP Python SDK를 사용하여 다음을 수행합니다.

  • AI 어시스턴트를 위한 도구로서 데이터베이스 작업을 공개합니다.
  • 데이터베이스 스키마와 메타데이터를 리소스로 제공합니다.
  • 데이터베이스 작업에 유용한 프롬프트를 생성합니다.
  • 데이터베이스와의 상태 저장 상호 작용 활성화

설치 및 구성

필수 매개변수

모든 설치 방법에는 두 가지 매개변수가 필요합니다.

  • DB_TYPE : 데이터베이스 유형 코드(위 표 참조)
  • DB_CONFIG : 데이터베이스 연결을 위한 JSON 구성 문자열

DB_CONFIG 형식은 데이터베이스 유형에 따라 다릅니다. 데이터베이스별 구성에 대한 자세한 내용은 API 설명서를 참조하세요.

설치 방법

옵션 1: UV 사용(권장)

uv 사용하면 별도의 설치가 필요하지 않습니다. uvx 사용하여 database-mcp를 직접 실행합니다.

UV 구성 예:

지엑스피1

옵션 2: PIP 사용

pip를 통해 설치:

pip install database-mcp

PIP 구성 예:

{ "mcpServers": { "database": { "command": "python", "args": [ "-m", "database_mcp", "--repository", "path/to/git/repo" ], "env": { "DB_TYPE": "pg", "DB_CONFIG": "{\"host\":\"localhost\",\"port\":5432,\"user\":\"user\",\"password\":\"pw\",\"dbname\":\"dbname\"}" } } } }

서버 실행

개발 모드

mcp dev mcp_server.py

생산 모드

python mcp_server.py

구성 방법

환경 변수

export DB_TYPE="pg" # or mysql, postgresql, etc. export DB_CONFIG='{"host":"localhost","port":5432,"user":"username","password":"password","dbname":"database_name"}' mcp dev mcp_server.py

명령줄 인수

python mcp_server.py --db-type pg --db-config '{"host":"localhost","port":5432,"user":"username","password":"password","dbname":"database_name"}'

또는 UV를 사용하여:

uv mcp_server.py --db-type pg --db-config '{"host":"localhost","port":5432,"user":"username","password":"password","dbname":"database_name"}'

노출된 MCP 기능

자원

의지설명
schema://all전체 데이터베이스 스키마를 얻으세요

도구

도구설명
execute_querySQL 쿼리를 실행하고 결과를 마크다운 테이블로 반환합니다.
execute_query_jsonSQL 쿼리를 실행하고 결과를 JSON으로 반환합니다.
get_table_columns특정 테이블의 열 이름 가져오기
get_table_types특정 테이블의 열 유형 가져오기
get_query_history최근 쿼리 내역 가져오기

프롬프트

즉각적인설명
sql_query데이터베이스에 대한 SQL 쿼리를 만듭니다.
explain_querySQL 쿼리가 무엇을 하는지 설명하세요
optimize_query더 나은 성능을 위해 SQL 쿼리 최적화

개발

테스트

uv pip install -e ".[dev]" pytest

출판

rm -rf dist/ build/ *.egg-info/ && python -m build python -m build python -m twine upload dist/*

특허

이 저장소는 GPL 라이선스를 받았습니다.

-
security - not tested
F
license - not found
-
quality - not tested

모델 컨텍스트 프로토콜(MCP) Python SDK와 통합된 쿼리 러너를 사용하여 데이터베이스의 데이터에 액세스하고 쿼리할 수 있도록 지원하는 서버입니다. PostgreSQL, Redshift, MySQL, Microsoft SQL Server, Google API, Amazon Web Services(boto3를 통해), CockroachDB, SQLite 등의 데이터베이스를 지원합니다.

  1. Features
    1. Supported Databases
      1. What is MCP?
        1. Installation & Configuration
          1. Required Parameters
          2. Installation Methods
        2. Running the Server
          1. Development Mode
          2. Production Mode
          3. Configuration Methods
        3. Exposed MCP Capabilities
          1. Resources
          2. Tools
          3. Prompts
        4. Development
          1. Testing
          2. Publishing
        5. License
          ID: eznxyvc6od