mysql
MySQL MCP server project
claude mcp add --transport stdio michael7736-mysql-mcp-server node /path/to/mysql-mcp-server/build/index.js \ --env MYSQL_HOST="localhost" \ --env MYSQL_PORT="3306" \ --env MYSQL_USER="mcp101" \ --env MYSQL_DATABASE="mcpdb" \ --env MYSQL_PASSWORD="123qwe"
How to use
The MySQL MCP Server provides programmatic access to a MySQL database through the Model Context Protocol. It exposes tools that let you run SQL queries, create tables, and modify data, with results returned in JSON format for easy integration in conversations. You typically configure the server with environment variables for the database connection, then invoke the server via your MCP client (such as Claude) using the available tools. The core capability is run_sql_query for SELECT statements, but you can also use create_table, insert_data, update_data, and delete_data to perform a wide range of DDL/DML operations. Each operation is designed to be auditable with transaction IDs for traceability.
To use it in a chat session, you initialize the MCP server via your configured command (for example, node /path/to/mysql-mcp-server/build/index.js) and then issue tool requests like run_sql_query with a JSON payload containing your SQL query. For example, asking for all users in the test_users table will trigger a SELECT query and return the results in a JSON structure that can be consumed by your app or displayed in the chat.
The available tools include:
- run_sql_query: Executes read-only SELECT statements and returns results as JSON.
- create_table: Executes a CREATE TABLE statement to define a new table.
- insert_data: Executes INSERT INTO statements to add rows.
- update_data: Executes UPDATE statements to modify existing rows.
- delete_data: Executes DELETE statements to remove rows.
By ensuring proper privileges for the configured MySQL user and securing credentials, you can safely operate against your database within the MCP workflow.
How to install
Prerequisites
- Node.js v14 or higher
- Access to a MySQL server
- MCP SDK or MCP-compatible client for your environment
Installation steps
-
Clone or download the repository:
git clone https://github.com/your-org/mysql-mcp-server.git cd mysql-mcp-server
-
Install dependencies:
npm install
- Build the server (if a build step exists):
npm run build
- Configure environment variables for MySQL access (example values):
export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=mcp101
export MYSQL_PASSWORD=123qwe
export MYSQL_DATABASE=mcpdb
- Run the MCP server:
node build/index.js
- Verify the server is reachable via your MCP client and that the environment is correctly wired to the database.
Additional notes
Tips and considerations:
- Use a dedicated MySQL user with the minimum required privileges for the MCP server. Consider read-only privileges if you only need queries.
- Store credentials securely and avoid embedding them in publicly accessible settings files.
- Ensure the MySQL server is reachable from the host running the MCP server (consider network ACLs and firewall rules).
- If you encounter connection errors, verify MYSQL_HOST, MYSQL_PORT, and that the user has access to the specified database.
- All operations can be logged with transaction IDs for auditing; consider enabling this in your transport/search configuration if available.
- When sharing configurations (e.g., Claude settings), avoid exposing plaintext passwords in shared files; use secret management where possible.
Related MCP Servers
zen
Selfhosted notes app. Single golang binary, notes stored as markdown within SQLite, full-text search, very low resource usage
MCP -Deepseek_R1
A Model Context Protocol (MCP) server implementation connecting Claude Desktop with DeepSeek's language models (R1/V3)
mcp-fhir
A Model Context Protocol implementation for FHIR
mcp
Inkdrop Model Context Protocol Server
mcp-appium-gestures
This is a Model Context Protocol (MCP) server providing resources and tools for Appium mobile gestures using Actions API..
dubco -npm
The (Unofficial) dubco-mcp-server enables AI assistants to manage Dub.co short links via the Model Context Protocol. It provides three MCP tools: create_link for generating new short URLs, update_link for modifying existing links, and delete_link for removing short links.