read-only-local-mysql
MCP server from hovecapital/read-only-local-mysql-mcp-server
claude mcp add --transport stdio hovecapital-read-only-local-mysql-mcp-server npx -y @hovecapital/read-only-mysql-mcp-server@latest \ --env DB_HOST="localhost" \ --env DB_PORT="3306" \ --env DB_DATABASE="your_database_name" \ --env DB_PASSWORD="your_password" \ --env DB_USERNAME="your_username"
How to use
This MCP server exposes a read-only interface to a MySQL database, enabling Claude Desktop to translate natural language queries into safe, read-only SQL against the configured database. It validates queries to ensure only SELECT statements are executed and returns results in JSON format. To use it, configure Claude to connect to the MCP server via a MySQL MCP entry (the example uses the server name 'mysql'). Once connected, you can issue natural language questions such as requesting table lists, table schemas, or sample data, and Claude will generate and run the corresponding read-only SQL through the MCP server.
The MCP server exposes three core tools for Claude users:
- connect: Establish or change the active MySQL connection using a connection string. This persists for subsequent queries until you disconnect or change it.
- disconnect: End the current runtime connection and revert to the environment-configured defaults.
- query: Submit a read-only SQL query against the currently connected database. Claude will map your natural language request to a safe SELECT statement and return JSON results.
How to install
Prerequisites:
- Node.js (v16 or higher)
- MySQL server accessible with credentials
- Claude Desktop or Claude Code setup ready to configure MCP servers
Option A: Install from MCP Registry (Recommended)
- Install the MCP server via npx (automated):
claude mcp add mysql -s user -- npx -y @hovecapital/read-only-mysql-mcp-server@latest
- Set environment variables for your database credentials in Claude Desktop or Claude Code configuration as shown in the examples:
export DB_HOST=localhost
export DB_PORT=3306
export DB_DATABASE=your_database_name
export DB_USERNAME=your_username
export DB_PASSWORD=your_password
Option B: Manual JSON Configuration (Claude Desktop)
Edit Claude Desktop config:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@hovecapital/read-only-mysql-mcp-server@latest"],
"env": {
"DB_HOST": "localhost",
"DB_PORT": "3306",
"DB_DATABASE": "your_database_name",
"DB_USERNAME": "your_username",
"DB_PASSWORD": "your_password"
}
}
}
}
Option C: Install from npm (local development)
npm install -g @hovecapital/read-only-mysql-mcp-server
Option D: Manual Installation (source)
# Clone the repository
mkdir -p ~/mcp-servers/mysql
cd ~/mcp-servers/mysql
git clone https://github.com/hovecapital/read-only-local-mysql-mcp-server.git .
# Install dependencies and build
npm install
npm run build
Then point Claude to the produced entry point as shown in the manual Claude Code configuration example.
Additional notes
Environment variables:
- DB_HOST defaults to localhost if not set by your configuration
- DB_PORT defaults to 3306
- DB_DATABASE, DB_USERNAME, DB_PASSWORD are required for establishing a connection
- The server only allows read-only queries; attempts to run non-SELECT statements will be blocked for safety. If you need to switch databases, update the environment variables or reconnect using the connect tool. Common issues:
- Incorrect connection string or credentials causing authentication failures
- Network/firewall blocks preventing MySQL host/port access
- Claude tool misconfiguration pointing to the wrong MCP server name If you encounter issues, ensure the MCP server is reachable from Claude, and verify the environment variables are correctly set in the client configuration.
Related MCP Servers
zen
Selfhosted notes app. Single golang binary, notes stored as markdown within SQLite, full-text search, very low resource usage
MCP -Deepseek_R1
A Model Context Protocol (MCP) server implementation connecting Claude Desktop with DeepSeek's language models (R1/V3)
mcp-fhir
A Model Context Protocol implementation for FHIR
mcp
Inkdrop Model Context Protocol Server
mcp-appium-gestures
This is a Model Context Protocol (MCP) server providing resources and tools for Appium mobile gestures using Actions API..
dubco -npm
The (Unofficial) dubco-mcp-server enables AI assistants to manage Dub.co short links via the Model Context Protocol. It provides three MCP tools: create_link for generating new short URLs, update_link for modifying existing links, and delete_link for removing short links.