mysql-readonly
MCP server for secure read-only MySQL database access. Let AI assistants explore schemas and run queries safely.
claude mcp add --transport stdio beydemirfurkan-mysql-readonly-mcp npx -y mysql-readonly-mcp \ --env MYSQL_HOST="localhost" \ --env MYSQL_PORT="3306" \ --env MYSQL_USER="your-user" \ --env MYSQL_DATABASE="your-database" \ --env MYSQL_PASSWORD="your-password"
How to use
This MCP server provides secure, read-only access to a MySQL database. It exposes a set of MCP tools that let you inspect schemas, preview data, and run constrained queries without risking data modification. The recommended setup uses npx so you can launch it on-demand without local installation. To use it, configure an MCP client to point at the server entry (for example, the my-database entry shown in the configuration). The available tools include: list_tables to enumerate tables and metadata, describe_table to view column definitions and keys, preview_data to sample rows with optional filters, run_query to execute safe SELECT-like queries with strict validation, show_relations to explore foreign key relationships, and db_stats to get a snapshot of database size and table counts. Each tool enforces the read-only policy and query limits described in the documentation, making it suitable for AI-assisted exploration and analysis.
How to install
Prerequisites:
- Node.js and npm installed on your machine
- Access to install global npm packages if you plan to install the binary globally
Install steps:
- Global installation (optional):
npm install -g mysql-readonly-mcp
mysql-readonly-mcp
- If you prefer to use npx (no installation):
npx -y mysql-readonly-mcp
- Run a local example (using the quick start configuration):
- Ensure you have a MySQL server reachable with the environment values you provide
- Start the MCP server with the configuration shown in the Quick Start example (or your own) to begin listening for MCP clients
Additional notes
Tips and considerations:
- The server enforces read-only actions. Attempts to modify data (INSERT, UPDATE, DELETE) or any schema changes (DROP, ALTER, CREATE, TRUNCATE) are blocked.
- Connection details are provided via environment variables (MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE). Do not expose sensitive credentials in logs.
- Query limits: previews are capped (default max 100 rows) and custom queries up to 5000 rows (timeout 30 seconds per query).
- For multi-database setups, create separate MCP entries with distinct MYSQL_HOST/PORT/DATABASE values.
- If you encounter connection issues, verify network access to MySQL, correct credentials, and that the user has appropriate privileges (SELECT/SHOW/DESCRIBE/EXPLAIN).
Related MCP Servers
mcp-graphql
Model Context Protocol server for GraphQL
mcp-google-map
A powerful Model Context Protocol (MCP) server providing comprehensive Google Maps API integration with LLM processing capabilities.
systemprompt-code-orchestrator
MCP server for orchestrating AI coding agents (Claude Code CLI & Gemini CLI). Features task management, process execution, Git integration, and dynamic resource discovery. Full TypeScript implementation with Docker support and Cloudflare Tunnel integration.
pluggedin-app
The Crossroads for AI Data Exchanges. A unified, self-hostable web interface for discovering, configuring, and managing Model Context Protocol (MCP) servers—bringing together AI tools, workspaces, prompts, and logs from multiple MCP sources (Claude, Cursor, etc.) under one roof.
rohlik
MCP server that lets you shop groceries across the Rohlik Group platforms (Rohlik.cz, Knuspr.de, Gurkerl.at, Kifli.hu, Sezamo.ro)
mcp -js
MCP server that exposes YepCode processes as callable tools for AI platforms. Securely connect AI assistants to your YepCode workflows, APIs, and automations.