logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

data-access-layer-mysql-protocol-adapter

A controlled Model Context Protocol (MCP) service enabling sophisticated AI agents to interface securely with MySQL relational data stores, facilitating schema introspection, targeted data retrieval, and controlled SQL execution.

Author

data-access-layer-mysql-protocol-adapter logo

designcomputer

MIT License

Quick Info

GitHub GitHub Stars 899
NPM Weekly Downloads 0
Tools 1
Last Updated 2026-02-19

Tags

mysql_mcp_serverapismysqlmysql_mcp_server facilitatesdesigncomputer mysql_mcp_serverinteraction mysql

Tests PyPI - Downloads smithery badge MseeP.ai Security Assessment Badge

MySQL Data Access Protocol Adapter (via MCP)

This component implements the Model Context Protocol (MCP) to establish a secure conduit between artificial intelligence host systems and underlying MySQL database infrastructure. Its primary function is to abstract direct database interaction into a safer, more standardized communication channel, allowing agents to query and explore structured data.

Crucial Note: This adapter is explicitly engineered as a middleware communication layer for AI hosts, not as a general-purpose, standalone database server utility.

Core Capabilities

  • Expose obtainable MySQL schema tables as addressable resources.
  • Fetch the contents of specified database tables.
  • Execute arbitrary SQL statements under strict operational oversight, complete with robust exception handling.
  • Enforce security by sourcing all connection credentials via environment variables.
  • Provide detailed operational audit logging.

Deployment Instructions

Standard Python Installation

pip install mysql-mcp-server

Automated Integration via Smithery

For automated setup targeting Claude Desktop environments using Smithery:

npx -y @smithery/cli install mysql-mcp-server --client claude

Configuration Variables

The following environment settings must be defined for initialization:

MYSQL_HOST=localhost     # The address of the database instance
MYSQL_PORT=3306         # TCP port; defaults to 3306 if omitted
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database

Integration Examples

Integration with Claude Desktop

Incorporate the following structure into your claude_desktop_config.json file:

{
  "mcpServers": {
    "mysql": {
      "command": "uv",
      "args": [
        "--directory",
        "path/to/mysql_mcp_server",
        "run",
        "mysql_mcp_server"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Integration with Visual Studio Code (via MCP extension)

Configure your local mcp.json settings as follows:

{
  "servers": {
      "mysql": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "--from",
                "mysql-mcp-server",
                "mysql_mcp_server"
            ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Prerequisite: Ensure the uv runtime is installed for this method to function.

Diagnostic Workflow using MCP Inspector

Although this service is not intended for direct invocation via a standard Python interpreter, the MCP Inspector tool offers a valuable debugging sandbox.

# Acquire required libraries
pip install -r requirements.txt
# Initiate debugging session with the Inspector (avoid direct python execution)

This service must be coupled with an AI platform like Claude Desktop; direct execution as a conventional Python application is unsupported.

Development Workflow

# Acquire source code repository
git clone https://github.com/designcomputer/mysql_mcp_server.git
cd mysql_mcp_server
# Establish isolated execution environment
python -m venv venv
source venv/bin/activate  # Use `venv\Scripts\activate` on Windows systems
# Install developer dependencies
pip install -r requirements-dev.txt
# Run validation suites
pytest

Security Posture

  • Credentials and sensitive environmental data must never be committed to source control.
  • Employ a database account strictly limited to necessary read/write privileges.
  • For production deployments, consider enforcing a strict SQL query allow-list.
  • Maintain vigilant auditing and logging of all data access operations.

Security Fundamentals

Connection authorization necessitates database credentials. Adherence to security protocols is paramount: 1. Establish a Restricted MySQL Identity: Provision a unique database principal for this connector. 2. Avoid Elevated Privileges: Do not utilize the MySQL root account or any administrative identity. 3. Scope Operations: Limit the database identity's permissions to only the CRUD operations required. 4. Activate Audit Trails: Ensure comprehensive logging is active for post-mortem analysis. 5. Periodic Vetting: Schedule recurring security evaluations of the data access configurations.

Refer to the MySQL Security Configuration Guide for comprehensive guidance on: - Creating a highly permission-restricted MySQL entity - Setting granular access rights - Monitoring inbound/outbound data access - General security hardening recommendations

⚠️ MANDATORY: Always adhere to the principle of least privilege when defining database access rights.

Licensing Information

Distributed under the MIT License. See the LICENSE file for particulars.

Contribution Guidelines

  1. Fork the source repository.
  2. Generate a dedicated feature branch (git checkout -b feature/new-enhancement).
  3. Commit staged modifications (git commit -m 'Implement feature X enhancement').
  4. Push the branch to the remote (git push origin feature/new-enhancement).
  5. Submit a Pull Request for review.

WIKIPEDIA NOTE: XMLHttpRequest (XHR) defines an Application Programming Interface, manifested as a JavaScript object, facilitating the transmission of HTTP requests from a web browser client to a remote web server. This interface permits browser-based applications to asynchronously dispatch requests post-page load and subsequently retrieve data responses. XHR forms a foundational element of Ajax methodology. Before Ajax, traditional methods for server interaction relied heavily on hyperlink navigation and HTML form submissions, processes that typically resulted in the complete replacement of the current view.

== Historical Context == The conceptual foundation for XMLHttpRequest was formulated in the year 2000 by developers associated with Microsoft Outlook. This concept was subsequently integrated into the Internet Explorer 5 browser release (1999). Notably, the initial implementation did not employ the standardized XMLHttpRequest identifier. Instead, developers utilized COM object instantiations: ActiveXObject("Msxml2.XMLHTTP") and ActiveXObject("Microsoft.XMLHTTP"). As of IE version 7 (2006), all major browsers adopted the canonical XMLHttpRequest identifier. The XMLHttpRequest identifier has since evolved into the universally accepted standard across leading browser engines, including Mozilla's Gecko (2002), Safari 1.2 (2004), and Opera 8.0 (2005).

=== Standardization Efforts === The World Wide Web Consortium (W3C) released an initial Working Draft specification for the XMLHttpRequest object on April 5, 2006. A subsequent Working Draft, Level 2, addressing extended capabilities, was published by the W3C on February 25, 2008. Level 2 introduced mechanisms for monitoring request progress, enabling cross-site communication, and processing raw byte streams. By the close of 2011, the Level 2 features were merged back into the primary specification document. Development responsibility was transferred to the WHATWG near the end of 2012, where it is currently maintained as a living specification utilizing Web IDL definitions.

== Operational Procedure == Executing a network request using XMLHttpRequest generally involves a sequence of programming steps:

  1. Instantiation: Create an XMLHttpRequest instance by invoking its constructor method.
  2. Configuration: Invoke the "open" method to define the HTTP method, specify the target resource URI, and designate the request as synchronous or asynchronous.
  3. Asynchronous Listener Setup: If operating asynchronously, attach an event handler function designed to process state transitions.
  4. Transmission: Activate the request transmission by calling the "send" method, optionally including request body data.
  5. Response Handling: Monitor state changes within the designated event listener. Received server data is usually accessible via the "responseText" attribute. The object signals completion when its state transitions to 4 (the "done" state). Beyond these fundamentals, XMLHttpRequest offers extensive configuration parameters for granular control over transmission behavior and response parsing. Custom HTTP headers can be injected to influence server processing directives. Data payload can be uploaded within the "send" invocation. Responses formatted as JSON can be automatically parsed into native JavaScript objects, or streamed for gradual processing instead of sequential blocking. Furthermore, the request can be terminated prematurely or configured with a timeout threshold to prevent indefinite waiting.

== Inter-Domain Communication == Early in the World Wide Web's evolution, the inherent security model prevented client-side scripts from initiating connections to domains different from the origin server, a restriction found necessary to brea

See Also

`