MySQL ReadOnly

Provides read-only MySQL access via MCP to query data, list tables, describe schemas, and enumerate databases.
  • typescript

0

GitHub Stars

typescript

Language

7 months ago

First Indexed

3 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "zhaojw-php-mysql-readonly-mcp": {
      "command": "node",
      "args": [
        "完整路径/mysql-readonly-mcp/dist/index.js"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_SSL_CA": "/path/to/ca.pem",
        "MYSQL_SSL_KEY": "/path/to/key.pem",
        "MYSQL_DATABASE": "your_database",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_SSL_CERT": "/path/to/cert.pem",
        "MYSQL_SSL_REJECT_UNAUTHORIZED": "true"
      }
    }
  }
}

You run a dedicated, read-only MCP (Model Context Protocol) server that safely handles MySQL queries. It enforces read-only access, optimizes performance, and provides strong security so your AI clients can query databases without risking data integrity or exposure.

How to use

You integrate the MCP server with your preferred MCP client (Claude Desktop, Claude Code, or Gemini CLI) to issue read-only SQL queries against your MySQL databases. The server exposes a small, well-defined surface of actions: execute read-only queries, list tables, describe table structures, and enumerate databases. Use these tools to fetch data and schema information without altering anything on the database.

To perform actions, you connect your client to the MCP server configuration you’ve created. Each client will invoke the MCP tools by name and supply the required parameters. You can supply environment variables to point the MCP server at your MySQL instance, including host, port, user, password, and database. If you are using SSL, you can enable SSL related variables as well.

How to install

Prerequisites you need before installing: a node runtime and npm. You will clone the MCP server repository, install dependencies, and build the project before running it.

Step-by-step commands you should run in your terminal:

git clone https://github.com/jway8975/mysql-readonly-mcp.git
cd mysql-readonly-mcp
npm install

Additional configuration and usage notes

Configuration is provided via environment variables. Populate the values to point the MCP server at your MySQL instance. Optional SSL settings are available if you need encrypted connections.

To build the project, run the build script. This prepares the JavaScript bundle that your MCP clients will load.

Configure your MCP client with one of the supported paths (Claude Desktop, Claude Code, or Gemini CLI) so it can start the local MCP process and route queries to the MySQL database.

Environment variable references

The following environment variables are used to configure the MySQL connection and security features.

VariableDescription
MYSQL_HOSTMySQL server address
MYSQL_PORTMySQL server port
MYSQL_USERMySQL user name
MYSQL_PASSWORDMySQL password
MYSQL_DATABASEDefault database to connect to
MYSQL_SSL_CASSL CA certificate path
MYSQL_SSL_CERTSSL client certificate path
MYSQL_SSL_KEYSSL client key path
MYSQL_SSL_REJECT_UNAUTHORIZEDWhether to reject unauthorized SSL certificates

Tools and capabilities

You can perform the following read-only operations through the MCP server tools.

  • mysql_query: Execute read-only SQL queries. Only SELECT statements are allowed.

  • mysql_list_tables: List all tables in the selected database.

  • mysql_describe_table: Retrieve the structure and column information for a specific table.

  • mysql_list_databases: List all available databases, excluding system databases.

Security and reliability notes

This MCP server enforces strict read-only behavior and includes safeguards such as automatic LIMIT application, SQL injection protections, and SSL support where configured.

Startup validation checks ensure required configuration is present before your server becomes active.

Troubleshooting

If you encounter connection issues, verify that the MySQL service is running, the credentials are correct, and the user has SELECT permissions on the database. Check network settings and firewalls if you cannot reach the database.

If a configuration problem arises, ensure you are using absolute paths for the MCP entry points and that environment variables are set correctly. Review SSL settings if you are using SSL.

Development and testing

To run tests, use the following commands.

npm test
npm run test:coverage
npm run test:watch

Available tools

mysql_query

Execute read-only SQL queries. Only SELECT statements are allowed.

mysql_list_tables

List all tables in the selected database.

mysql_describe_table

Retrieve the structure and column information for a specific table.

mysql_list_databases

List all available databases, excluding system databases.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational