Connect to MySQL databases easily with NodeJS-based MCP server for schema inspection and read-only queries
The MCP (Model Context Protocol) server for MySQL based on NodeJS is a specialized adapter that enables AI applications to securely and efficiently connect to and interact with MySQL databases. This server supports read-only access, allowing AI models like Claude Desktop, Continue, Cursor, and more to query database schemas and execute SQL queries within a transaction-level guarantee of Read Only.
This server offers several key features and capabilities that are essential for integrating with various AI applications:
sql
as a string to this function, which ensures all queries are executed within a READ ONLY transaction.The server provides detailed schema information for each table in the database:
The architecture of this MCP server integrates seamlessly with Model Context Protocol servers, enabling a standardized approach for connecting AI applications to specific data sources. This ensures interoperability across multiple platforms and clients while maintaining security and efficiency.
graph TD
A[AI Application] -->|MCP Client| B[MCP Server]
B --> C[MySQL Database]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#e8f5e8
graph TD
A[Data Source] -->|Schema Info| B[MCP Server]
B --> C[AI Application]
D[MCP Server] --> E[Database Queries]
style A fill:#e8f5e8
style B fill:#f3e5f5
style C fill:#e1f5fe
To get started with the MCP server for MySQL, follow these straightforward steps:
Installation Command: Use npx
to install the MCP server:
npx @benborla29/mcp-server-mysql
Environment Variables: Set up environment variables for your MySQL database connection details:
export MYSQL_HOST=127.0.0.1
export MYSQL_PORT=3306
export MYSQL_USER=root
export MYSQL_PASS=
export MYSQL_DB=db_name
Configuration File: Modify the claude_desktop_config.json
to include details for MCP server configuration:
{
"mcpServers": {
"mcp_server_mysql": {
"command": "npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "",
"MYSQL_DB": "db_name"
}
}
}
}
Running the Server: Start the MCP server using the configured command.
The following is a compatibility matrix for selected MCP clients:
MCP Client | Resources | Tools | Prompts |
---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ |
Continue | ✅ | ✅ | ✅ |
Cursor | ❌ | ✅ | ❌ |
Note: The compatibility with prompts is currently not supported.
Adding specific paths to binaries can resolve connection issues:
{
"mcpServers": {
"mcp_server_mysql": {
"command": "/path/to/npx/binary/npx",
"args": [
"-y",
"@benborla29/mcp-server-mysql"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "",
"MYSQL_DB": "db_name",
"PATH": "/path/to/node/bin:/usr/bin:/bin"
}
}
}
}
mysql_query
tool?
mysql_query
tool is designed for read-only operations. Write operations are unsupported and may result in undefined behavior.By implementing this MCP server, you can enhance your AI applications' capabilities, ensuring smooth data interactions and analysis within secured environments. Whether you're a developer building advanced AI systems or an organization looking to integrate database management with AI, this MCP server provides the tools and protocols needed for seamless integration and productivity.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods