mysql
MCP server from shreyansh-ghl/mysql-mcp-server
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:
- Clone the repository:
git clone https://github.com/yourusername/mysql-mcp-server.git
cd mysql-mcp-server
- Prepare and install dependencies:
npm run prepare
npm install
- Build or set up for local development (if applicable):
npm run build # if the project defines a build step
- Link the CLI globally (optional but recommended for easy usage):
npm link
- Run the MCP server with a MySQL connection string:
mysql-mcp-server mysql://user:password@localhost:3306/mydb
- 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
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.