Skip to main content

A Model Context Protocol (MCP) server that enables secure interaction with XeSQL/UbiSQL/MySQL DataBases.

Project description

XeSQL MCP Server

A high-performance Model Context Protocol (MCP) server that enables secure and efficient interaction with MySQL-compatible databases including MySQL, MariaDB, TiDB, OceanBase, AWS RDS, and Aurora MySQL.

✨ Key Highlights

  • 🏗️ Professional Architecture: Modular design with singleton patterns and clean separation of concerns
  • ⚡ High Performance: Full async/await implementation with intelligent connection pooling
  • 🛡️ Enterprise Security: Multi-layer security with parameter validation and sensitive data protection
  • 🔧 Universal Compatibility: Support for 6+ MySQL-compatible database systems
  • 📊 Production Ready: Comprehensive logging, error handling, and resource management
  • 🎯 MCP Standard: Built on FastMCP framework with complete MCP protocol compliance

🚀 Core Features

MCP Protocol Implementation

  • Standard Tools & Resources: Complete MCP tool and resource definitions
  • FastMCP Framework: Built on robust FastMCP foundation for reliability
  • Async Communication: Non-blocking MCP message handling

Database Operation Tools

  • Universal SQL Execution: Execute any SQL statement with intelligent type detection
  • Table Structure Analysis: Comprehensive table metadata and schema information
  • Test Data Generation: Automated test data creation with customizable parameters
  • Query Optimization: Smart result handling for different SQL operation types

Advanced Architecture

  • Singleton Connection Pool: Efficient resource management with automatic cleanup
  • Smart Configuration: Multi-instance support with environment variable override
  • Async-First Design: Built from ground up for asynchronous operations
  • Modular Structure: Clean separation of tools, resources, utilities, and configuration

📋 Prerequisites

  • Python >= 3.12
  • XeSQL/MySQL/MariaDB/TiDB/OceanBase database instance
  • Network access to database server

🛠️ Installation

1. Install from PyPI (Recommended)

pip install xesql-mcp-server

2. Configure database connection

Edit dbconfig.json with your database credentials:

{
    "dbPoolSize": 5,
    "dbMaxOverflow": 10,
    "dbPoolTimeout": 30,
    "dbType-Comment": "The database currently in use,such as XeSQL/MySQL/MariaDB/UbiSQL OceanBase/RDS/Aurora MySQL DataBases",
    "dbList": [
        {   "dbInstanceId": "xesql_1",
            "dbHost": "localhost",
            "dbPort": 2281,
            "dbDatabase": "xesql_db",
            "dbUsername": "root",
            "dbPassword": "123456",
            "dbType": "XeSQL",
            "dbVersion": "V2.0.0",
            "dbActive": true
        },
        {   "dbInstanceId": "mysql_2",
            "dbHost": "localhost",
            "dbPort": 3306,
            "dbDatabase": "mysql_db",
            "dbUsername": "root",
            "dbPassword": "123456",
            "dbType": "MySQL",
            "dbVersion": "8.0",
            "dbActive": false
        },
        {   "dbInstanceId": "tidb_3",
            "dbHost": "localhost",
            "dbPort": 4000,
            "dbDatabase": "tidb_db",
            "dbUsername": "root",
            "dbPassword": "123456",
            "dbType": "UbiSQL",
            "dbVersion": "8.5.3",
            "dbActive": false
        }
    ],
    "logPath": "/path/to/logs",
    "logLevel": "info"
}
# dbType
Oceanbase Instance is in MySQL/MariaDB/TiDB OceanBase/RDS/Aurora MySQL DataBases.
# dbActive
Only database instances with dbActive set to true in the dbList configuration list are available. 
# logPath
MCP server log is stored in /path/to/logs/mcp_server.log.
# logLevel
TRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, CRITICAL

3. Configure MCP Client

Add to your MCP client configuration file:

{
  "mcpServers": {
    "xesql-mcp-client": {
      "command": "xesql-mcp-server",
      "env": {
        "config_file": "/path/to/your/dbconfig.json"
      },
      "disabled": false
    }
  }
}

Note: Replace /path/to/your/dbconfig.json with the actual path to your configuration file.

4. Clone the repository (Development Mode)

git clone https://github.com/j00131120/mcp_database_server.git
cd mcp_database_server/xesql_mcp_server
# Import project into your IDE

5. Configure MCP Client for Development

{
  "mcpServers": {
    "xesql-mcp-server": {
      "command": "/bin/uv",
      "args": ["run", "src/server.py"],
      "cwd": "/path/to/your/project",
      "env": {
        "config_file": "/path/to/your/dbconfig.json"
      },
      "disabled": false,
      "autoApprove": ["describe_table", "sql_exec", "generate_demo_data"]
    }
  }
}

# command
uv absolute path
# cwd
project absolute path
# config_file
dbconfig.json file path

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xesql_mcp_server-1.0.2.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xesql_mcp_server-1.0.2-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file xesql_mcp_server-1.0.2.tar.gz.

File metadata

  • Download URL: xesql_mcp_server-1.0.2.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for xesql_mcp_server-1.0.2.tar.gz
Algorithm Hash digest
SHA256 9a52e831bdd2ecbcbfa746f5dc0a12b96021c03d2ea6ad0d0df43e314a57d8c9
MD5 61c122cd189b0ef1b59bc532315e4f7f
BLAKE2b-256 3e24900ffb8c25ba6b76cb498844571a24b51bc9a0e6e7b244be0554a0fdcf65

See more details on using hashes here.

File details

Details for the file xesql_mcp_server-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for xesql_mcp_server-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 70565f09c220b48a1f8e3a33058b5ac89ac9cb43cee0167bc47ab2a3fdaa7f7c
MD5 04df7f8257e9209a7f915e42eb93cc34
BLAKE2b-256 9c46292794516c1e38afc3e4a7d69bec96f47bf77c70492801b9db2b3f740915

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page