Cover image
Try Now
2025-04-09

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

MCP Stdio Server (MySQL/MariaDB)

이 프로젝트는 Cursor IDE와 연동 가능한 Model Context Protocol (MCP) Stdio 서버입니다. MySQL 또는 MariaDB 데이터베이스의 테이블 구조와 관계를 반환합니다.

✅ 기능

  • MCP 공식 Python SDK 기반
  • stdio 모드로 Cursor IDE 연동
  • .env 파일 기반 DB 설정
  • 테이블 목록, 컬럼, 외래키 관계 반환
  • 데이터 조회 및 분석 기능
  • 쿼리 실행 및 최적화 기능
  • 데이터베이스 모니터링 기능
  • 성능 분석 및 최적화 제안

📦 설치

git clone <this-repo-url>
cd db-mcp-server
python -m venv venv
source venv/bin/activate  # 또는 venv\Scripts\activate (Windows)
pip install -r requirements.txt

⚙️ .env 설정

루트에 .env 파일을 아래와 같이 작성하세요:

# Database connection settings for MCP Python server
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=your_db
DB_CHARSET=utf8mb4

🚀 실행

Cursor IDE에서 MCP Server 추가 > Transport: stdio > Command: python main.py

📡 지원 메서드

스키마 조회

  • mysql.get_schema: 모든 테이블 구조 + 외래키 반환

데이터 조회 및 분석

  • mysql.get_table_stats: 테이블별 통계 정보 (행 수, NULL 값 비율, 고유값 수)
  • mysql.get_sample_data: 테이블의 샘플 데이터 조회
  • mysql.get_column_stats: 특정 컬럼의 상세 통계 정보

쿼리 실행 및 최적화

  • mysql.execute_query: 안전한 읽기 전용 쿼리 실행
  • mysql.explain_query: 쿼리 실행 계획 분석
  • mysql.optimize_query: 쿼리 최적화 제안

데이터베이스 모니터링

  • mysql.get_db_status: 데이터베이스 상태 정보 (연결 수, 쿼리 통계 등)
  • mysql.get_table_size: 테이블별 크기 정보
  • mysql.get_index_usage: 인덱스 사용 통계

성능 분석

  • mysql.analyze_performance: 성능 병목 지점 분석
  • mysql.suggest_indexes: 인덱스 생성 제안
  • mysql.optimize_tables: 테이블 최적화 제안

📝 예시 결과

스키마 조회

{
  "schema": {
    "users": {
      "columns": [...],
      "foreign_keys": [...]
    }
  }
}

테이블 통계

{
  "table_name": "users",
  "total_rows": 1000,
  "column_stats": {
    "id": {
      "total_rows": 1000,
      "null_count": 0,
      "null_ratio": 0.0,
      "unique_values": 1000
    }
  }
}

쿼리 실행 계획

{
  "explain_plan": [...],
  "handler_stats": {...},
  "suggestions": [
    {
      "type": "index",
      "message": "정렬 작업이 발생하고 있습니다. ORDER BY 절에 사용된 컬럼에 대한 인덱스 추가를 고려하세요."
    }
  ]
}

성능 분석

{
  "slow_queries": 5,
  "bottlenecks": [
    {
      "type": "large_table",
      "table": "orders",
      "rows": 1500000,
      "message": "테이블 'orders'이(가) 1,500,000개의 행을 가지고 있습니다. 파티셔닝을 고려하세요."
    }
  ],
  "recommendations": [...]
}

✅ 요구사항

  • Python 3.8+
  • MySQL/MariaDB

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • pontusab
  • La comunidad de cursor y windsurf, encontrar reglas y MCP

  • ravitemer
  • Un poderoso complemento Neovim para administrar servidores MCP (protocolo de contexto del modelo)

  • jae-jae
  • Servidor MCP para obtener contenido de la página web con el navegador sin cabeza de dramaturgo.

  • patruff
  • Puente entre los servidores Ollama y MCP, lo que permite a LLM locales utilizar herramientas de protocolo de contexto del modelo

  • av
  • Ejecute sin esfuerzo LLM Backends, API, frontends y servicios con un solo comando.

  • chongdashu
  • Habilite clientes asistentes de IA como Cursor, Windsurf y Claude Desktop para controlar el motor irreal a través del lenguaje natural utilizando el Protocolo de contexto del modelo (MCP).

  • wgpsec
  • 一款基于各大企业信息 API 的工具 , 解决在遇到的各种针对国内企业信息收集难题。一键收集控股公司 解决在遇到的各种针对国内企业信息收集难题。一键收集控股公司 ICP 备案、 Aplicación 、小程序、微信公众号等信息聚合导出。支持 MCP 接入

    Reviews

    4 (1)
    Avatar
    user_jVBD3WrT
    2025-04-17

    As a dedicated user of db-mcp-server, I can confidently say this tool by zerogon1203 is a game-changer! It offers seamless integration and robust performance for managing your database needs. The user-friendly interface and comprehensive documentation make it incredibly easy to set up and use. Highly recommend checking it out on GitHub!