SD

souhar-dya/mcp-db-server

Database management

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

19 stars 14 forks Качество 69 Тренд 30NOASSERTION

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-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.
  • Added PostgreSQL sslmode=require compatibility for asyncpg connections.
  • Updated Docker Compose, environment examples, and documentation for secure API-key configuration.
  • Published Docker images:
    • souhardyak/mcp-db-server:1.4.0
    • souhardyak/mcp-db-server:latest
  • Added GitHub Container Registry publishing for:
    • ghcr.io/souhar-dya/mcp-db-server:1.4.0
    • ghcr.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

  1. 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
    
  2. Test the endpoints:

Открыть полный README на GitHub

Установка

docker run --rm -i -e DATABASE_URL=sqlite+aiosqlite:////data/default.db souhardyak/mcp-db-server:1.3.1
Новичок в MCP? Начните с руководства на mcpskill.org →