Get the FREE Ultimate OpenClaw Setup Guide →

mysql

MCP server from shreyansh-ghl/mysql-mcp-server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio shreyansh-ghl-mysql-mcp-server mysql-mcp-server mysql://user:password@localhost:3306/mydb \
  --env MYSQL_HOST="database host" \
  --env MYSQL_PORT="database port (default 3306)" \
  --env MYSQL_USER="database username" \
  --env MYSQL_DATABASE="database name" \
  --env MYSQL_PASSWORD="database password"

How to use

This MCP server provides read-only access to a MySQL database for LLMs. It exposes two main capabilities: a query tool that executes read-only SQL against the connected database and a schema explorer that returns JSON schemas for each table. To use it, connect to the server via the provided MCP endpoint (for example, using Cursor) and supply a MySQL connection string in the form mysql://username:password@host:port/database. The query tool accepts a single SQL string input and runs it inside a READ ONLY transaction, ensuring that no data-modifying operations are executed. The schema resource endpoints automatically discover and return table schemas, including column names and data types, based on the live database metadata. Authentication is handled through the database URL credentials you provide when starting the server.

How to install

Prerequisites:

  • Node.js and npm installed
  • Git installed
  • Access to a MySQL database

Installation steps:

  1. Clone the repository:
git clone https://github.com/yourusername/mysql-mcp-server.git
cd mysql-mcp-server
  1. Prepare and install dependencies:
npm run prepare
npm install
  1. Build or set up for local development (if applicable):
npm run build  # if the project defines a build step
  1. Link the CLI globally (optional but recommended for easy usage):
npm link
  1. Run the MCP server with a MySQL connection string:
mysql-mcp-server mysql://user:password@localhost:3306/mydb
  1. Validate by querying the server endpoints (e.g., the cursor config example in the README).

Additional notes

Tips and common considerations:

  • Use a dedicated MySQL user with only READ permissions to enforce read-only access.
  • Avoid committing credentials in config files; consider using environment variables and a robust secret management solution.
  • If running in production, ensure TLS/SSL is enabled for the database connection and secure the MCP server endpoints.
  • When using Cursor, you can configure an MCP server entry with env-var substitutions to avoid embedding credentials in plain text.
  • The schema endpoints automatically reflect current database metadata; if the database schema changes, the MCP server will surface updated schemas.

Related MCP Servers

Sponsor this space

Reach thousands of developers