DatabaseMCP
MCP 데이터베이스 인텔리전스 서버 아키텍처
시스템 개요
이 시스템은 **MCP(Model Context Protocol)**를 사용하여 AI 에이전트에 데이터베이스 기능을 노출합니다.
MCP 서버는 다음 요소들 사이의 가교 역할을 합니다:
AI 어시스턴트
데이터베이스 메타데이터
저장 프로시저
데이터베이스 탐색 도구
상위 수준 아키텍처
AI 에이전트 / MCP 클라이언트 │ ▼ MCP 서버 (FastMCP) │ ├── 탐색 도구 │ (데이터베이스 탐색) │ ├── 동적 프로시저 도구 │ (데이터베이스 프로시저에서 생성됨) │ ▼ 인텔리전스 엔진 (프로시저 메타데이터 + 분류) │ ▼ 데이터베이스 액세스 계층 │ ▼ MySQL 데이터베이스
핵심 구성 요소
Related MCP server: MySQL MCP Server
1. MCP 서버 (main.py)
MCP 서버는 FastMCP를 사용하여 생성됩니다.
역할:
MCP 서버 초기화
탐색 도구 등록
동적 프로시저 도구 등록
2. 데이터베이스 액세스 계층 (db.py)
이 모듈은 모든 데이터베이스 통신을 관리합니다.
역할:
데이터베이스 연결 관리
저장 프로시저 실행
메타데이터 검색
결과 제한 적용
모든 데이터베이스 상호작용은 이 계층을 통과합니다.
3. 도구 생성기 (tool_generator.py)
이 모듈은 데이터베이스 저장 프로시저를 MCP 도구로 동적으로 변환합니다.
수행 단계:
데이터베이스에서 프로시저 메타데이터 로드
프로시저 매개변수 감지
MCP 도구 함수 동적 생성
MCP 서버에 도구 등록
이를 통해 시스템은 데이터베이스에 추가된 새로운 프로시저를 자동으로 지원할 수 있습니다.
4. 인텔리전스 엔진 (intelligence_engine.py)
인텔리전스 엔진은 저장 프로시저를 분석하여 메타데이터를 생성합니다.
기능:
프로시저 분류
설명 생성
매개변수 분석
분류 예시:
프로시저 패턴 | 카테고리 |
GetLinkCount | 네트워크 분석 |
GetWeekData | 시간 분석 |
InterfaceLinkType | 인터페이스 분석 |
이 메타데이터는 AI 에이전트가 각 도구의 목적을 이해하는 데 도움을 줍니다.
5. 탐색 도구 (discovery_tools.py)
탐색 도구를 통해 AI 에이전트는 데이터베이스 구조를 탐색할 수 있습니다.
구현된 도구:
list_databases list_tables describe_table
이 도구들은 다음의 데이터베이스 메타데이터를 활용합니다:
INFORMATION_SCHEMA
보안 아키텍처
안전한 데이터베이스 상호작용을 보장하기 위해 여러 안전장치가 구현되어 있습니다.
키워드 제한
위험한 키워드가 포함된 프로시저는 차단됩니다.
예시:
DELETE DROP TRUNCATE UPDATE INSERT ALTER
쿼리 결과 제한
시스템은 구성 가능한 값을 사용하여 결과 크기를 제한합니다:
MAX_QUERY_ROWS
이는 대량의 데이터 추출을 방지합니다.
속도 제한
MCP 서버는 과도한 사용을 방지하기 위해 요청 속도 제한을 적용합니다.
제한된 데이터베이스 사용자
MCP 서버에서 사용하는 데이터베이스 사용자는 다음 권한만 가져야 합니다:
SELECT EXECUTE
이는 프로덕션 데이터의 수정을 방지합니다.
메타데이터 소스
시스템은 MySQL 시스템 테이블에서 메타데이터를 검색합니다.
예시:
INFORMATION_SCHEMA.ROUTINES INFORMATION_SCHEMA.PARAMETERS INFORMATION_SCHEMA.TABLES INFORMATION_SCHEMA.COLUMNS
이 테이블들을 통해 MCP 서버는 데이터베이스 구조를 자동으로 이해할 수 있습니다.
AI 상호작용 흐름 예시
AI 에이전트와 데이터베이스 간의 상호작용 예시:
list_databases() ↓ list_tables() ↓ describe_table("interface_stats") ↓ GetLinkCount("NodeA")
이를 통해 AI는 분석 프로시저를 실행하기 전에 데이터베이스 구조를 탐색할 수 있습니다.
확장성
이 시스템은 추가적인 데이터베이스 객체를 지원하도록 설계되었습니다.
향후 확장 기능:
list_views list_functions list_triggers search_tables explain_query
모듈식 아키텍처를 통해 새로운 도구를 쉽게 추가할 수 있습니다.
결론
이 아키텍처는 MCP 서버가 어떻게 데이터베이스 기능을 AI 시스템에 안전하게 노출할 수 있는지 보여줍니다.
핵심 설계 원칙:
• 모듈식 아키텍처 • 동적 도구 생성 • 메타데이터 기반 탐색 • 안전한 데이터베이스 액세스
이 접근 방식은 안전하고 확장 가능한 AI-데이터베이스 통합을 가능하게 합니다.
상세한 시스템 다이어그램은 docs/ 디렉토리에서 확인할 수 있습니다.
This server cannot be deployed
Maintenance
Related MCP Connectors
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
MCP server for building and testing AI agents with multi-model experimentation and insights.
- mcpOAuthcom.gibsonai
GibsonAI MCP server: manage your databases with natural language
The Remote MCP server acts as a standardized bridge between LLM applications (like Claude, ChatGPT, and Cursor) and external services, enabling AI agents to access external tools and resources. Its primary capability is providing a centralized search tool to discover other MCP servers and their respective tools. Unlike local implementations, it runs remotely with OAuth authentication and permission controls for security.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA high-performance MCP server that enables AI assistants to safely interact with MySQL databases through secure CRUD operations, schema inspection, and parameterized queries with built-in SQL injection prevention.1-
- AlicenseNot gradedqualityDmaintenanceA MySQL MCP server for secure database interaction, enabling schema inspection, query execution, and RBAC via AI coding assistants.1,352 npm5MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that connects AI agents to MySQL databases for schema exploration, data querying, and SQL execution via natural language.2MIT
- AlicenseNot gradedqualityDmaintenanceA production-ready MCP server for MySQL database integration with AI agents, enabling database exploration, CRUD operations, schema management, and performance monitoring through natural language.744 npmMIT