MySQL MCP Server
Provides read-only access to MySQL databases with query validation, enabling AI assistants to execute SELECT queries securely while blocking dangerous SQL operations
Supports SSL/TLS connections to PlanetScale cloud databases, enabling secure read-only access to MySQL-compatible databases
Click on "Install 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 Servershow me the top 5 customers by total orders"
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 that provides AI assistants with read-only access to MySQL databases. The server validates all queries to ensure only SELECT statements are executed.
Features
Read-only access - Only SELECT queries are allowed
Query validation - Blocks dangerous SQL operations (INSERT, UPDATE, DELETE, DROP, etc.)
SSL/TLS support - Works with cloud databases like PlanetScale
Secure credentials - Database credentials stay on the server, never exposed to AI clients
Related MCP server: MySQL MCP Server
Prerequisites
Bun runtime
MySQL database with a read-only user
Installation
git clone <your-repo-url>
cd mysql-mcp
bun installConfiguration
Create a .env file in the project root:
DB_HOST=localhost
DB_USER=ai_readonly
DB_PASSWORD=your_password
DB_NAME=your_database
ENV=local # or staging/prodCreating a Read-Only MySQL User
For security, create a dedicated read-only user for the AI:
CREATE USER 'ai_readonly'@'%' IDENTIFIED BY 'STRONG_PASSWORD_HERE';
GRANT SELECT ON your_database.* TO 'ai_readonly'@'%';
FLUSH PRIVILEGES;Usage
With Claude Desktop
Add to your claude_desktop_config.json (located at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"mysql": {
"command": "bun",
"args": ["run", "/absolute/path/to/mysql-mcp/src/index.ts"]
}
}
}With Cursor
Add to your MCP server settings:
{
"mcpServers": {
"mysql": {
"command": "bun",
"args": ["run", "/absolute/path/to/mysql-mcp/src/index.ts"]
}
}
}Manual Testing
bun run startAvailable Tools
execute_sql
Executes a SELECT-only SQL query on the MySQL database.
Input:
{
"query": "SELECT * FROM users LIMIT 10"
}Output:
{
"rows": [
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" }
]
}Security
The server implements multiple layers of protection:
Query validation - Must start with
SELECTKeyword blocking - Blocks:
INSERT,UPDATE,DELETE,DROP,CREATE,ALTER,TRUNCATE,REPLACE,GRANT,REVOKE,COMMIT,ROLLBACK,LOCK,CALL,EXECUTE,PREPARE,LOAD,INTO OUTFILE,INTO DUMPFILEInjection prevention - Blocks semicolons (
;) and SQL comments (--,/*)Database-level enforcement - Use a MySQL user with only SELECT privileges
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceEnables secure interaction with MySQL databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.Last updated
- Alicense-qualityDmaintenanceProvides read-only access to MySQL databases with automatic schema discovery and secure query execution. Enables users to explore database structure and execute SELECT queries through natural language interactions.Last updatedMIT
- Alicense-qualityDmaintenanceEnables AI assistants to safely query MySQL databases with read-only access by default, supporting table listing, structure inspection, and SQL queries with optional write operation control.Last updated33MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to safely query MySQL databases with read-only access, featuring SQL injection protection, connection pooling, and automatic query limits for secure database exploration.Last updated450MIT
Related MCP Connectors
Read-only MCP server for Muovi, Argentina's trust-first local services marketplace (6 tools).
Read-only bank access for your AI agent. Connects Claude, ChatGPT, Cursor, Gemini, Codex.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Appeared in Searches
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/JoeWithGlide/mysql-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server