SQL MCP Server

SQL MCP Server

Enables AI models to interact with multiple database types (MySQL, MSSQL, Oracle, Sybase) through a unified interface with standardized tools for querying, inspecting schemas, and managing connections without requiring separate server configurations.

Category
Visit Server

README

SQL MCP Server

The SQL MCP Server is a unified agentic interface that allows AI models (like Claude) to inspect, query, and interact with multiple types of databases through a single, standardized set of tools.

Instead of installing and configuring separate servers for MySQL, SQL Server, Oracle, etc., this single package handles them all by dynamically loading the correct "adapter" based on your configuration.

🚀 Features

  • Standardized Toolset: The AI always sees the same tools (execute_query, describe_table, get_db_version), no matter if it's talking to Oracle or MySQL. This reduces hallucinations and improves query accuracy.
  • Resources: Automatically exposes database tables as MCP Resources for easy inspection.
  • Smart Adapters:
    • MySQL: Uses mysql-connector-python with connection pooling.
    • MSSQL: Uses pymssql and auto-detects schema names (e.g., dbo.Users).
    • Sybase / SAP IQ: Uses pyodbc and intelligently handles dba. prefixes and server names.
    • Oracle: Uses oracledb (Thin mode) for easy connectivity without complex driver installs.
  • Unicode Ready: All connections default to UTF-8 to handle special characters seamlessly.

🛠️ Installation

  1. Clone the repository:

    git clone https://github.com/BryR0/sql-mcp.git
    cd sql-mcp
    
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: .\venv\Scripts\activate
    
  3. Install dependencies:

    pip install -e .
    

⚙️ Configuration

You define which database to use via the DB_TYPE environment variable.

Supported Environment Variables

Variable Description Required Default
DB_TYPE Type of DB: mysql, mssql, sybase, oracle Yes mysql
DB_HOST Hostname or IP address Yes localhost
DB_USER Database username Yes root
DB_PASSWORD Database password Yes (empty)
DB_DATABASE Database name Yes test
DB_PORT Port number No Auto (3306, 1433, etc.)
DB_DSN Connection string (Oracle/Sybase advanced) No (empty)
DB_SERVER_NAME Explicit Server Name (Sybase only) No (empty)

Claude Desktop Config Example

Add this to your claude_desktop_config.json. Note that DB_PORT is optional and will default to the standard port for the chosen DB type if omitted.

{
  "mcpServers": {
    "sql_mcp_mysql": {
      "command": "C:\\path\\to\\venv\\python.exe",
      "args": ["-m", "sql_mcp"],
      "env": {
        "DB_TYPE": "mysql",
        "DB_HOST": "localhost",
        "DB_USER": "root",
        "DB_PASSWORD": "password",
        "DB_DATABASE": "my_db"
      }
    },
    "sql_mcp_mssql": {
      "command": "C:\\path\\to\\venv\\python.exe",
      "args": ["-m", "sql_mcp"],
      "env": {
        "DB_TYPE": "mssql",
        "DB_HOST": "192.168.1.50",
        "DB_USER": "sa",
        "DB_PASSWORD": "password",
        "DB_DATABASE": "DataWarehouse"
      }
    }
  }
}

🏗️ Architecture

The project uses an Adapter Pattern:

  1. Server receives a request (e.g., execute_query).
  2. Factory checks DB_TYPE and instantiates the correct class (e.g., MSSQLAdapter).
  3. Adapter translates the generic request into specific driver calls (pymssql, pyodbc, etc.).
  4. Response is formatted back to a standard JSON structure for the AI.

This means you can switch databases just by changing the config, without changing the AI's prompts or logic.

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured