SD

souhar-dya/mcp-db-server

Database management

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

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:

GitHub で README 全文を見る

インストール

docker run --rm -i -e DATABASE_URL=sqlite+aiosqlite:////data/default.db souhardyak/mcp-db-server:1.3.1
MCP 初心者?mcpskill.org のガイドから始めましょう →