Provides direct access to MySQL databases, allowing execution of SQL queries to read data, create tables, insert data, update records, and delete information, with results returned in JSON format.
Serves as the runtime environment for the MCP server, enabling server-side JavaScript execution for database operations.
MySQL MCP Server
This is a Model Context Protocol (MCP) server that provides access to a MySQL database. It allows agent to execute SQL queries against a MySQL database.
Features
- Execute SQL queries against a MySQL database:
- Read data (SELECT statements)
- Create tables (CREATE TABLE statements)
- Insert data (INSERT INTO statements)
- Update data (UPDATE statements)
- Delete data (DELETE FROM statements)
- Returns query results in JSON format
- Configurable database connection settings
- Transaction logging with unique IDs
Prerequisites
- Node.js (v14 or higher)
- MySQL server
- MCP SDK
Installation
- Clone or download this repository
- Install dependencies:
- Build the server:
Configuration
The MySQL MCP server uses the following environment variables for configuration:
MYSQL_HOST
: MySQL server hostname (default: 'localhost')MYSQL_PORT
: MySQL server port (default: 3306)MYSQL_USER
: MySQL username (default: 'mcp101')MYSQL_PASSWORD
: MySQL password (default: '123qwe')MYSQL_DATABASE
: MySQL database name (default: 'mcpdb')
Database Setup
- Create a MySQL database:
- Create a MySQL user with access to the database:
- Create a test table with sample data:
MCP Configuration
Add the MySQL MCP server to your MCP settings file:
VSCode (Claude Extension)
File: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
Change the args according your MySQL configuruation
Claude Desktop App
File: ~/Library/Application Support/Claude/claude_desktop_config.json
Usage
Once configured, you can use the MySQL MCP server in your conversations with Claude. For example:
"Can you show me all the users in the test_users table?"
Claude will use the run_sql_query
tool to execute:
Available Tools
run_sql_query
Executes a read-only SQL query (SELECT statements only) against the MySQL database.
Parameters:
query
: The SQL SELECT query to execute.
Example:
create_table
Creates a new table in the MySQL database.
Parameters:
query
: The SQL CREATE TABLE query to execute.
Example:
insert_data
Inserts data into a table in the MySQL database.
Parameters:
query
: The SQL INSERT INTO query to execute.
Example:
update_data
Updates data in a table in the MySQL database.
Parameters:
query
: The SQL UPDATE query to execute.
Example:
delete_data
Deletes data from a table in the MySQL database.
Parameters:
query
: The SQL DELETE FROM query to execute.
Example:
Security Considerations
- Use a dedicated MySQL user with appropriate privileges for the MCP server
- Consider using read-only privileges if you only need to query data
- Store sensitive information like database credentials securely
- All operations are logged with unique transaction IDs for auditing
This server cannot be installed
A Model Context Protocol server that provides Claude agents with the ability to execute SQL queries against a MySQL database, supporting both read operations (SELECT) and write operations (CREATE, INSERT, UPDATE, DELETE).
Related MCP Servers
- -securityFlicense-qualityA Model Context Protocol server that enables SQL query execution, database management, and business intelligence capabilities through MySQL connections.Last updated -JavaScript
- AsecurityFlicenseAqualityA secure Model Context Protocol server that allows Claude to execute read-only SQL queries against a PostgreSQL database, enabling natural language interaction with database data.Last updated -1TypeScript
- AsecurityFlicenseAqualityA Model Context Protocol server that allows AI agents to execute SQL queries against a MySQL database, supporting operations like reading data, creating tables, inserting, updating, and deleting records.Last updated -68682JavaScript
- -securityFlicense-qualityA Model Context Protocol server that allows Large Language Models like Claude to execute SQL queries, explore database schemas, and maintain persistent connections to SQL Server databases.Last updated -TypeScript