mysql-readonly-mcp
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-readonly-mcpShow me all tables in the database"
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 Read-Only MCP Server
MySQL Read-Only MCP Server is a Model Context Protocol (MCP) server that provides secure, read-only access to a single MySQL database. It is designed for MCP-compatible clients that need to inspect schema details, preview table data, and run analytical queries without allowing data or schema changes.
Overview
Read-only query execution for MySQL
Single database configuration per server instance
Built-in query validation and row limits
Schema inspection and relationship discovery tools
Compatible with MCP clients such as Claude Desktop and editor integrations
Related MCP server: MySQL MCP Server
Installation
Run with npx
npx -y mysql-readonly-mcpPrefer npx or a globally installed binary in MCP client configuration. Do not point MCP clients to a cloned repository checkout such as .../mysql-readonly-mcp/dist/index.js, because some clients and agents may treat that checkout as part of the active workspace.
Global installation
npm install -g mysql-readonly-mcp
mysql-readonly-mcpConfiguration
The server reads its connection settings from environment variables.
Variable | Description | Default |
| MySQL host |
|
| MySQL port |
|
| MySQL user |
|
| MySQL password | empty |
| Database name |
|
| Query execution timeout in milliseconds (minimum |
|
Each server instance connects to one database. To work with multiple databases, configure multiple MCP server entries and point each one to a different MYSQL_DATABASE value.
Client setup
Claude Desktop
Configuration file locations:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"mysql-production": {
"command": "npx",
"args": ["-y", "mysql-readonly-mcp"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "readonly_user",
"MYSQL_PASSWORD": "your-password",
"MYSQL_DATABASE": "production_db"
}
}
}
}Generic MCP configuration
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "mysql-readonly-mcp"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "password",
"MYSQL_DATABASE": "app_db"
}
}
}
}This is the recommended setup for editor and assistant clients because it keeps the MCP server isolated from the repository source tree.
Multiple database connections
Use separate MCP server entries when you need access to more than one database.
{
"mcpServers": {
"mysql-production": {
"command": "npx",
"args": ["-y", "mysql-readonly-mcp"],
"env": {
"MYSQL_HOST": "prod-db.example.com",
"MYSQL_USER": "readonly_user",
"MYSQL_PASSWORD": "your-password",
"MYSQL_DATABASE": "production"
}
},
"mysql-staging": {
"command": "npx",
"args": ["-y", "mysql-readonly-mcp"],
"env": {
"MYSQL_HOST": "staging-db.example.com",
"MYSQL_USER": "readonly_user",
"MYSQL_PASSWORD": "your-password",
"MYSQL_DATABASE": "staging"
}
}
}
}Available tools
Tool | Purpose | Parameters |
| List tables and views with metadata | None |
| Describe table columns, keys, and indexes |
|
| Preview rows from a table |
|
| Execute validated read-only SQL |
|
| Show incoming and outgoing foreign key relations |
|
| Summarize database size and largest tables | None |
| Show which database this server instance is connected to | None |
Tool details
list_tables
Returns table name, table type, row count estimate, and storage engine for the configured database.
describe_table
Returns:
Column definitions
Primary key columns
Foreign key relationships
Index information
preview_data
Parameters:
table(required)columns(optional)limit(optional, default10, max100)where(optional basic filter expression, without theWHEREkeyword)
For complex filtering, joins, unions, or advanced SQL expressions, use run_query instead of preview_data.
run_query
Accepted statements:
SELECTSHOWDESCRIBEEXPLAIN
Rejected statements include data modification, schema modification, and permission-changing queries such as INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, GRANT, REVOKE, and LOCK.
show_relations
Returns:
Tables that reference the target table
Tables referenced by the target table
Relationship type when it can be inferred
db_stats
Returns:
Total table count
Estimated total row count
Total database size
Largest tables by row count
Largest tables by size
db_info
Returns the connection details for this server instance: database name, host, port, user, and active query timeout. Useful when multiple MCP server instances are configured and you need to confirm which one you are addressing. The password is never included in the output.
Prompts
The server exposes a connection_info prompt for MCP clients that support prompts. When retrieved, it provides a summary of the database this server connects to and a reminder that the server is scoped to that single database. This helps LLM clients avoid routing queries to the wrong server instance.
Security model
The server is intended for inspection and analysis, not for write operations.
Query validation blocks non-read-only statements
Preview queries are capped at 100 rows
Custom queries are capped at 5000 rows
Query execution timeout defaults to 30 seconds and is configurable via
MYSQL_QUERY_TIMEOUT_MSSensitive credentials are sanitized in error messages
Troubleshooting
Connection refused
Confirm that MySQL is running
Confirm that
MYSQL_HOSTandMYSQL_PORTare correctConfirm that network access to the MySQL server is allowed
Access denied
Confirm that
MYSQL_USERandMYSQL_PASSWORDare correctConfirm that the user has read access to the configured database
Confirm that the MySQL user is allowed to connect from the current host
Query rejected
Confirm that the query is read-only
Use only
SELECT,SHOW,DESCRIBE, orEXPLAIN
License
MIT. See LICENSE for details.
Links
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/beydemirfurkan/mysql-readonly-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server