
souhar-dya/mcp-db-server
Database management이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기
MCP Database Server with natural language SQL queries
개요
An MCP (Model Context Protocol) server that exposes relational databases (PostgreSQL/MySQL) to AI agents with natural language query support. Transform natural language questions into SQL queries and get structured results. - : Works with PostgreSQL and MySQL - : Convert plain English queries to SQL using HuggingFace transformers - : Clean FastAPI-based endpoints for database operations - : Read-only operations with query validation and result limits - : Complete containerization with Docker Compose - : Health checks, logging, and error handling - : Designed specifically for AI agent integration - Added mandatory X-API-Key authentication for all database HTTP endpoints; /health remains public for health checks. - Removed unrestricted credentialed CORS and made allowed origins explicitly configurable. - Changed the default HTTP bind address to 127.0.0.1. - Added table-name validation against existing database tables to block SQL injection through table routes.
README
원문 README의 일부입니다. 원문 보기.
mcp-db-server
An MCP (Model Context Protocol) server that exposes relational databases (PostgreSQL/MySQL) to AI agents with natural language query support. Transform natural language questions into SQL queries and get structured results.
Features
- Multi-Database Support: Works with PostgreSQL and MySQL
- Natural Language to SQL: Convert plain English queries to SQL using HuggingFace transformers
- RESTful API: Clean FastAPI-based endpoints for database operations
- Safety First: Read-only operations with query validation and result limits
- Docker Ready: Complete containerization with Docker Compose
- Production Ready: Health checks, logging, and error handling
- AI Agent Friendly: Designed specifically for AI agent integration
Version 1.4.0 Changes
- Added mandatory
X-API-Keyauthentication for all database HTTP endpoints;/healthremains public for health checks. - Removed unrestricted credentialed CORS and made allowed origins explicitly configurable.
- Changed the default HTTP bind address to
127.0.0.1. - Added table-name validation against existing database tables to block SQL injection through table routes.
- Added PostgreSQL
sslmode=requirecompatibility forasyncpgconnections. - Updated Docker Compose, environment examples, and documentation for secure API-key configuration.
- Published Docker images:
souhardyak/mcp-db-server:1.4.0souhardyak/mcp-db-server:latest
- Added GitHub Container Registry publishing for:
ghcr.io/souhar-dya/mcp-db-server:1.4.0ghcr.io/souhar-dya/mcp-db-server:latest
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check and service status |
/mcp/list_tables |
GET | List all available tables with column counts |
/mcp/describe/{table_name} |
GET | Get detailed schema for a specific table |
/mcp/query |
POST | Execute natural language queries |
/mcp/tables/{table_name}/sample |
GET | Get sample data from a table |
Quick Start
Option 1: Docker Compose (Recommended)
-
Clone and start the services:
git clone https://github.com/Souhar-dya/mcp-db-server.git cd mcp-db-server export MCP_API_KEY="$(openssl rand -hex 32)" docker-compose up --build -
Test the endpoints:
설치
docker run --rm -i -e DATABASE_URL=sqlite+aiosqlite:////data/default.db souhardyak/mcp-db-server:1.3.1