mysql
mysql数据库的快速自然语言开发的MCP-server
claude mcp add --transport stdio blackdesert5410-mysql-mcp-server node src/index.js your_username your_password \ --env MYSQL_HOST="" \ --env MYSQL_PORT="" \ --env MYSQL_USER="" \ --env MYSQL_DATABASE="" \ --env MYSQL_PASSWORD=""
How to use
This MCP server provides a full MySQL management interface via a local MCP service. It exposes tools to test connections, manage databases and tables, perform CRUD operations, execute arbitrary SQL, and retrieve detailed database schemas including relationships and indexes. You can access these tools through the MCP interface in your client (Cursor or other MCP clients) by selecting the mysql server and invoking the available commands such as test_connection, list_databases, create_database, drop_database, use_database, list_tables, describe_table, create_table, drop_table, and the CRUD commands (select, insert, update, delete) along with execute_sql. The natural language to SQL support is built in, enabling agents to generate and run SQL queries based on the database schema you expose with tools like get_database_schema, get_table_schema, and get_sample_data. To use it, start the server with your credentials (username and password) or configure the environment variables for connection details, then point your MCP client to the running node process and begin issuing commands or natural language prompts that translate into SQL.
Typical workflows include connecting to your MySQL instance, inspecting the schema with get_database_schema or get_table_schema, and then generating and executing queries with select or execute_sql. For example, you can describe a table, retrieve its columns, and then craft a query like SELECT * FROM users WHERE active = true, which the agent can construct automatically once it understands the schema. Remember to choose the appropriate authentication method (command line args or environment variables) and ensure your MySQL server is reachable from the machine running the MCP server.
How to install
Prerequisites:
- Node.js 18+ installed on the host
- MySQL server running and accessible
- Basic familiarity with running Node applications
Installation steps:
- Clone the repository:
git clone https://github.com/blackdesert5410/mysql-mcp-server.git
cd mysql-mcp-server
- Install dependencies:
npm install
- Configure connection details:
- Either pass credentials via command line when starting the server:
node src/index.js <用户名> <密码> - Or set environment variables (MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE) in a .env file or your environment and run:
node src/index.js
- Start the server using one of the supported methods (examples shown in README):
# With command line args
node src/index.js your_username your_password
# Or via npm script if configured to read env vars
npm start
- Verify the server is running and accessible from your MCP client by using test_connection or list_databases tools.
Additional notes
Notes and tips:
- Ensure MySQL service is running (e.g., on Windows you might start it with
net start mysql80). - If you use environment variables, ensure your MCP client or shell session is aware of them before starting the server.
- When configuring Cursor or other MCP clients, follow the provided mcp.json examples, ensuring the command points to node and the index.js path is correct for your environment.
- For the natural language to SQL features, first explore the database schema with get_database_schema and get_table_schema to understand available tables and columns before generating queries.
- Do not commit real passwords into shared configuration files. Use environment variables or secure secrets 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.