mcp -mysql
MCP Tool server application with MySQL DDL operations, permission control and operation logs, supports npx/global commands.
claude mcp add --transport stdio liliangshan-mcp-server-mysql npx @liangshanli/mcp-server-mysql \ --env READONLY="false" \ --env ALLOW_DDL="true" \ --env ALLOW_DROP="false" \ --env MYSQL_HOST="localhost" \ --env MYSQL_PORT="3306" \ --env MYSQL_USER="root" \ --env TOOL_PREFIX="projA" \ --env ALLOW_DELETE="false" \ --env PROJECT_NAME="MyProject" \ --env MYSQL_DATABASE="your_database" \ --env MYSQL_PASSWORD="your_password"
How to use
This MCP server provides a MySQL-compatible interface with DDL support, permission controls, and operation logging. It exposes tools for executing SQL queries (sql_query), retrieving database information (get_database_info), accessing operation logs (get_operation_logs), and accessing DDL-related logs (get_ddl_sql_logs in v2.0.1+). You can run the server via npx or install it locally and start it with npm. To perform actions, send JSON-RPC requests to the server’s standard input/output stream after startup, using the tool names defined in the configuration (e.g., sql_query, get_database_info, get_operation_logs, get_ddl_sql_logs, check_permissions). When running multiple instances, each instance can use a different TOOL_PREFIX to isolate tools and logs.
How to install
Prerequisites:
- Node.js and npm installed
- Git installed (for source installation)
- Global installation (recommended):
npm install -g @liangshanli/mcp-server-mysql
- Local installation:
npm install @liangshanli/mcp-server-mysql
- From source:
git clone https://github.com/liliangshan/mcp-server-mysql.git
cd mcp-server-mysql
npm install
- Configure environment variables (example):
export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=root
export MYSQL_PASSWORD=your_password
export MYSQL_DATABASE=your_database
export READONLY=false
export ALLOW_DDL=true
export ALLOW_DROP=false
export ALLOW_DELETE=false
export TOOL_PREFIX="projA" # optional
export PROJECT_NAME="MyProject" # optional
- Start the server:
- Direct Run (if installed globally):
mcp-server-mysql
- Using npm scripts (local installation):
npm start
- Managed start (production):
npm run start-managed
Note: You can also run via npx without installation:
npx @liangshanli/mcp-server-mysql
Additional notes
Tips:
- Use TOOL_PREFIX to isolate tools and configuration when running multiple MySQL server instances. Each instance will have its own logs and DDL files (e.g., ./.setting.projA/).
- Enable READONLY to restrict commands to SELECT and SHOW for safety in production environments.
- The DDL logging (get_ddl_sql_logs) is available from v2.0.1+ and records only successful DDL operations with timestamps.
- If you enable DDL-related permissions, ensure ALLOW_DDL and related flags align with your security policy.
- For editor integration, you can define multiple MCP servers with different TOOL_PREFIX values to manage multiple databases concurrently.
- Ensure your environment variables are securely stored and not committed to source control.
- When using multiple instances, commands will be prefixed accordingly (e.g., local_sql_query vs online_sql_query) to avoid conflicts.
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.