MySQL MCP Server
Provides tools for MySQL schema introspection (tables, columns, indexes, relationships) and guarded read-only queries with access control.
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 schema of the orders table"
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
An open-source Model Context Protocol (MCP) server for MySQL schema introspection and guarded read-only queries. It helps MCP clients discover tables, columns, indexes, relationships, and safe queryable data from one configured MySQL database.
Features
Schema tools for tables, views, columns, primary keys, foreign keys, indexes, and approximate table statistics
Table and column search with simple
*and?wildcardsRelationship discovery for join-path exploration
Optional read-only
execute_querytool with SELECT-only validation, access control, and automaticLIMITInternal
src/coreboundary for code that can later be shared with other database-specific MCP servers
Related MCP server: MySQL MCP Server
Requirements
Node.js 18+
MySQL 8.x or a compatible MySQL service
A MySQL user with read access to the configured database
Setup
Fast path for users installing from npm:
npx -y @sigma4life/mysql-mcp-server initThen edit .env and check the connection:
npx -y @sigma4life/mysql-mcp-server doctorLocal development from this repository:
npm install
cp .env.example .env
npm run build
npm startConfigure .env:
DATABASE_URL=mysql://mcp_reader:change_me@localhost:3306/app_db
SCHEMA_ONLY_MODE=trueYou can also use individual DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD, and DB_SSL variables. Individual variables override DATABASE_URL.
This server connects to one configured database per process. Tool inputs may include database for compatibility, but it must match the configured database.
Least-Privilege MySQL User
Schema-only usage needs metadata visibility and table access. Read-query usage also needs SELECT on allowed tables.
CREATE USER 'mcp_reader'@'%' IDENTIFIED BY 'change_me';
GRANT SELECT, SHOW VIEW ON app_db.* TO 'mcp_reader'@'%';
FLUSH PRIVILEGES;Use a stronger host restriction and password in production.
MCP Client Example
Client-specific docs:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@sigma4life/mysql-mcp-server"],
"env": {
"DATABASE_URL": "mysql://mcp_reader:change_me@localhost:3306/app_db",
"SCHEMA_ONLY_MODE": "true"
}
}
}
}To enable execute_query, set SCHEMA_ONLY_MODE=false and provide QUERY_ACCESS_CONFIG.
Access Control
execute_query is blocked unless QUERY_ACCESS_CONFIG points to a JSON policy file. Example:
{
"requireExplicitColumns": true,
"databases": {
"app_db": {
"tables": {
"mode": "whitelist",
"list": ["customers", "orders", "products", "order_items"],
"columnAccess": {
"customers": {
"mode": "exclusion",
"columns": ["password_hash", "api_token"]
}
}
}
}
}
}Tools
get_schemaget_table_infofind_tablessearch_objectsget_relationshipsvalidate_objectsget_accessible_schemaget_accessible_table_infoexecute_querywhen schema-only mode is disabled
Example prompts:
"Show me the schema for the customers and orders tables."
"Find tables with a column matching
*email*.""Show relationships from orders to customers."
"Run
SELECT id, email FROM customers ORDER BY id LIMIT 20."
Development
npm run build
npm test
npm run lintThe first implementation is MySQL-specific. Shared logic lives under src/core so future database-specific repos can extract or reuse it without carrying MySQL catalog code.
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.
Latest Blog Posts
- 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/eltonf/mysql-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server