MySql MCP Server
The MySQL MCP Server bridges AI models and MySQL databases through a structured interface following the Model Context Protocol, enabling AI assistants to interact with MySQL data. With this server, you can:
Connect to MySQL databases using specified credentials
Execute SQL queries and handle prepared statements
Inspect database structure (list tables, describe table structures)
List and switch between accessible databases
Monitor and check connection status
Toggle read-only mode for database access
Disconnect from the current database
Test tools via web interface
Deploy with Docker
Monitor in real-time using Server-Sent Events (SSE)
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MySql MCP Server show me the top 10 customers by total purchase amount"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MySQL MCP Server
A Model Context Protocol (MCP) server for MySQL databases that enables AI models to interact with MySQL databases through a structured interface.
Overview
The MySQL MCP Server provides a bridge between AI models and MySQL databases, allowing AI agents to query and analyze MySQL data. This implementation follows the Model Context Protocol specification and offers both web server and CLI modes of operation.
Related MCP server: MySQL MCP Server
Features
MySQL database connection management
SQL query execution
Table listing and structure inspection
Database listing and selection
Real-time status monitoring via SSE (Server-Sent Events)
Web interface for testing MCP tools
Support for both stdio and SSE transport methods
Docker deployment ready
Installation
# Global installation
npm install -g mysql-mcp
# Local installation
npm install mysql-mcpUsing with AI Assistants
Using the Published Server on Smithery.ai
The MySQL MCP Server is published on Smithery.ai and can be easily used with various AI assistants:
Access the server: Visit https://smithery.ai/server/@sussa3007/mysql-mcp
Configure the server:
Set your MySQL database connection details:
MYSQL_HOST
MYSQL_PORT
MYSQL_USER
MYSQL_PASSWORD
MYSQL_DATABASE
MYSQL_READONLY (optional, set to True for read-only access)
Connect with supported AI platforms:
Anthropic Claude
Cursor AI
Windsurf
Cline
Witsy
Enconvo
Goose
Authentication: Login to Smithery.ai to save your configuration and generate authentication tokens.
Use in AI prompts: Once connected, you can utilize MySQL tools in your AI conversations by asking the assistant to perform database operations.
Using After Local Installation
To use a locally developed version:
Run
npm linkin your project directoryConfigure your settings file as follows:
{
"mcpServers": {
"mysql": {
"command": "node",
"args": ["mysql-mcp"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database",
"MYSQL_READONLY": "true"
}
}
}
}Tools
status
Check the current database connection status.
Inputs: No parameters required
Returns: Connection status information, including host, port, database, and username if connected.
connect
Connect to a MySQL database.
Inputs:
host (optional string): Database server hostname or IP address
port (optional string): Database server port
user (optional string): Database username
password (optional string): Database password
database (optional string): Database name to connect to
Returns: Connection success message or error details.
disconnect
Close the current MySQL database connection.
Inputs: No parameters required
Returns: Disconnection success message or error details.
query
Execute an SQL query on the connected database.
Inputs:
sql (string): SQL query to execute
params (optional array): Parameters for prepared statements
Returns: Query results as JSON or error message.
list_tables
Get a list of tables in the current database.
Inputs: No parameters required
Returns: List of table names in the current database.
describe_table
Get the structure of a specific table.
Inputs:
table (string): Name of the table to describe
Returns: Table structure details including columns, types, keys, and other attributes.
list_databases
Get a list of all accessible databases on the server.
Inputs: No parameters required
Returns: List of database names available on the server.
use_database
Switch to a different database.
Inputs:
database (string): Name of the database to switch to
Returns: Confirmation message or error details.
Keywords
mysql, mcp, database, ai, model context protocol
License
MIT
Available Tools
9 toolsconnectC
Connect to a MySQL database.
Inputs: database, host, password, port, +1 more.
describe_tableA
Get the structure of a specific table.
Inputs: table (required).
disconnectB
Close the current MySQL database connection.
Inputs: random_string (required).
list_databasesB
Get a list of all accessible databases on the server.
Inputs: random_string (required).
list_tablesB
Get a list of tables in the current database.
Inputs: random_string (required).
queryC
Execute an SQL query on the connected database.
Inputs: sql (required), params.
set_readonlyB
Enable or disable read-only mode
Inputs: readonly (required).
statusC
Check the current database connection status.
Inputs: random_string (required).
use_databaseB
Switch to a different database.
Inputs: database (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool has a clearly distinct purpose with no ambiguity: connection management (connect, disconnect, status), database navigation (list_databases, use_database), table operations (list_tables, describe_table), query execution (query), and mode control (set_readonly). The descriptions reinforce non-overlapping functionality.
All tool names follow a consistent snake_case pattern with clear verb_noun combinations (e.g., list_databases, describe_table, use_database). The naming is predictable and readable throughout the set.
With 9 tools, the count is well-scoped for a MySQL database server, covering essential operations like connection management, database/table listing, query execution, and configuration. Each tool earns its place without redundancy.
The tool set provides strong coverage for core MySQL operations, including CRUD-like functionality via the query tool and lifecycle management. A minor gap is the lack of explicit tools for schema modification (e.g., create/alter/drop tables), but agents can work around this using SQL queries.
Related MCP Connectors
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Query, explore, and manage your databases through natural conversation.
Store, query, and update structured data from any AI agent
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI models to perform MySQL database operations through a standardized interface, supporting secure connections, query execution, and comprehensive schema management.781 npm33MIT
- FlicenseNot gradedqualityDmaintenanceEnables secure interaction with MySQL databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.-
- AlicenseNot gradedqualityDmaintenanceProvides secure access to MySQL databases for AI assistants, enabling safe SQL queries, table information retrieval, and data insertion with built-in security protections.896 npm2MIT
- AlicenseAqualityDmaintenanceA tool service that enables AI agents to interact with MySQL databases through natural language, supporting SQL queries, table structure retrieval, and connection testing.781 npm32Apache 2.0