Skip to content

Commit 214eae2

Browse files
committed
docs: improve README with clearer MCP configuration guidance
1 parent 4ca8b85 commit 214eae2

File tree

1 file changed

+103
-78
lines changed

1 file changed

+103
-78
lines changed

README.md

Lines changed: 103 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
[![npm version](https://img.shields.io/npm/v/mysql-query-mcp-server.svg)](https://www.npmjs.com/package/mysql-query-mcp-server)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
55

6-
A Model Context Protocol (MCP) server that provides **read-only** MySQL database queries for AI assistants like Claude in Cursor IDE, Windsurf, or Claude Desktop. Execute queries, explore database structures, and investigate your data directly from your AI-powered tools.
6+
A Model Context Protocol (MCP) server that provides **read-only** MySQL database queries for AI assistants. Execute queries, explore database structures, and investigate your data directly from your AI-powered tools.
7+
8+
## Supported AI Tools
9+
10+
This MCP server works with any tool that supports the Model Context Protocol, including:
11+
12+
- **Cursor IDE**: Set up in `.cursor/mcp.json`
13+
- **Anthropic Claude**: Use with a compatible MCP client
14+
- **Other MCP-compatible AI assistants**: Follow the tool's MCP configuration instructions
715

816
## Features & Limitations
917

@@ -37,9 +45,88 @@ npx mysql-query-mcp-server
3745

3846
## Setup Instructions
3947

40-
### 1. Configure Your Database Connections
48+
### 1. Configure Your AI Tool to Use the MCP Server
49+
50+
1. Create or edit your MCP configuration file (e.g., `.cursor/mcp.json` for Cursor IDE):
51+
52+
```json
53+
{
54+
"mysql": {
55+
"name": "MySQL Query MCP",
56+
"description": "MySQL read-only query access through MCP",
57+
"type": "bin",
58+
"enabled": true,
59+
"bin": "mysql-query-mcp"
60+
}
61+
}
62+
```
63+
64+
For more advanced configuration with environment variables embedded in the MCP config:
65+
66+
```json
67+
{
68+
"mysql": {
69+
"command": "npx",
70+
"args": ["mysql-query-mcp-server@latest"],
71+
"env": {
72+
"LOCAL_DB_HOST": "localhost",
73+
"LOCAL_DB_USER": "root",
74+
"LOCAL_DB_PASS": "<YOUR_LOCAL_DB_PASSWORD>",
75+
"LOCAL_DB_NAME": "your_database",
76+
"LOCAL_DB_PORT": "3306",
77+
78+
"DEVELOPMENT_DB_HOST": "dev.example.com",
79+
"DEVELOPMENT_DB_USER": "<DEV_USER>",
80+
"DEVELOPMENT_DB_PASS": "<DEV_PASSWORD>",
81+
"DEVELOPMENT_DB_NAME": "your_database",
82+
"DEVELOPMENT_DB_PORT": "3306",
83+
84+
"STAGING_DB_HOST": "staging.example.com",
85+
"STAGING_DB_USER": "<STAGING_USER>",
86+
"STAGING_DB_PASS": "<STAGING_PASSWORD>",
87+
"STAGING_DB_NAME": "your_database",
88+
"STAGING_DB_PORT": "3306",
89+
90+
"PRODUCTION_DB_HOST": "prod.example.com",
91+
"PRODUCTION_DB_USER": "<PRODUCTION_USER>",
92+
"PRODUCTION_DB_PASS": "<PRODUCTION_PASSWORD>",
93+
"PRODUCTION_DB_NAME": "your_database",
94+
"PRODUCTION_DB_PORT": "3306",
95+
96+
"DEBUG": "false",
97+
"MCP_MYSQL_SSL": "true",
98+
"MCP_MYSQL_REJECT_UNAUTHORIZED": "false"
99+
}
100+
}
101+
}
102+
```
103+
104+
#### Choosing the Right Configuration Approach
105+
106+
There are two ways to configure the MySQL MCP server:
107+
108+
1. **Binary Configuration** (`type: "bin"`, `bin: "mysql-query-mcp"`)
109+
- **When to use**: When you've installed the package globally (`npm install -g mysql-query-mcp-server`)
110+
- **Pros**: Simpler configuration, cleaner MCP file
111+
- **Cons**: Requires global installation, uses a separate `.env` file for database credentials
112+
113+
2. **Command Configuration** (`command: "npx"`, `args: ["mysql-query-mcp-server@latest"]`)
114+
- **When to use**: When you want to use the latest version without installing it globally
115+
- **Pros**: No global installation required, all configuration in one file
116+
- **Cons**: More complex configuration, credentials in MCP file (which may be preferred in some cases)
117+
118+
Choose the approach that best fits your workflow. Both methods will work correctly with any AI assistant that supports MCP.
119+
120+
**Important Configuration Notes:**
121+
- You must use the full environment names: LOCAL_, DEVELOPMENT_, STAGING_, PRODUCTION_
122+
- Abbreviations like DEV_ or PROD_ will not work
123+
- Global settings like DEBUG, MCP_MYSQL_SSL apply to all environments
124+
- At least one environment (typically "local") must be configured
125+
- You only need to configure the environments you plan to use
126+
127+
### 2. Alternative: Using a .env File
41128

42-
You can configure the MySQL Query MCP server using environment variables in a `.env` file:
129+
If you prefer to keep your database credentials in a separate file, you can use a `.env` file:
43130

44131
```env
45132
# Local Database
@@ -78,30 +165,12 @@ PRODUCTION_DB_SSL=true
78165
DEBUG=false
79166
```
80167

81-
**Important Notes**:
82-
- You must configure at least one environment (typically "local")
83-
- Environment names are fixed (local, development, staging, production)
84-
- Additional environments can be configured but must use these exact names
85-
- Only configure the environments you actually need
86-
87168
You can copy the included `.env.example` file to get started:
88169
```bash
89170
cp .env.example .env
90171
```
91172

92-
### 2. Configure Cursor to Use the MCP Server
93-
94-
1. Create the `.cursor` directory in your home directory if it doesn't exist:
95-
```bash
96-
mkdir -p ~/.cursor
97-
```
98-
99-
2. If you don't have an MCP configuration file yet, create one:
100-
```bash
101-
touch ~/.cursor/mcp.json
102-
```
103-
104-
3. Add the MySQL Query MCP configuration to your `.cursor/mcp.json` file:
173+
When using a `.env` file, your MCP configuration can be simplified to:
105174

106175
```json
107176
{
@@ -115,8 +184,6 @@ touch ~/.cursor/mcp.json
115184
}
116185
```
117186

118-
This tells Cursor to use the `mysql-query-mcp` binary when accessing the MySQL Query MCP server.
119-
120187
## Configuration Options
121188

122189
| Environment Variable | Description | Default |
@@ -128,6 +195,8 @@ This tells Cursor to use the `mysql-query-mcp` binary when accessing the MySQL Q
128195
| [ENV]_DB_NAME | Database name | - |
129196
| [ENV]_DB_PORT | Database port | 3306 |
130197
| [ENV]_DB_SSL | Enable SSL connection | false |
198+
| MCP_MYSQL_SSL | Enable SSL for all connections | false |
199+
| MCP_MYSQL_REJECT_UNAUTHORIZED | Verify SSL certificates | true |
131200

132201
## Integration with AI Assistants
133202

@@ -175,56 +244,7 @@ Use the info tool to check the status of our production database.
175244

176245
#### 3. environments
177246

178-
List all configured database environments:
179-
180-
```
181-
Please use the environments tool to show me all available database environments.
182-
```
183-
184-
### MCP Configuration Example
185-
186-
Here's an example of a proper configuration for your MCP server:
187-
188-
```json
189-
"mysql": {
190-
"command": "npx",
191-
"args": ["mysql-query-mcp-server@latest"],
192-
"env": {
193-
"LOCAL_DB_HOST": "localhost",
194-
"LOCAL_DB_USER": "root",
195-
"LOCAL_DB_PASS": "<YOUR_LOCAL_DB_PASSWORD>",
196-
"LOCAL_DB_NAME": "your_database",
197-
"LOCAL_DB_PORT": "3306",
198-
199-
"DEVELOPMENT_DB_HOST": "dev.example.com",
200-
"DEVELOPMENT_DB_USER": "<DEV_USER>",
201-
"DEVELOPMENT_DB_PASS": "<DEV_PASSWORD>",
202-
"DEVELOPMENT_DB_NAME": "your_database",
203-
"DEVELOPMENT_DB_PORT": "3306",
204-
205-
"STAGING_DB_HOST": "staging.example.com",
206-
"STAGING_DB_USER": "<STAGING_USER>",
207-
"STAGING_DB_PASS": "<STAGING_PASSWORD>",
208-
"STAGING_DB_NAME": "your_database",
209-
"STAGING_DB_PORT": "3306",
210-
211-
"PRODUCTION_DB_HOST": "prod.example.com",
212-
"PRODUCTION_DB_USER": "<PRODUCTION_USER>",
213-
"PRODUCTION_DB_PASS": "<PRODUCTION_PASSWORD>",
214-
"PRODUCTION_DB_NAME": "your_database",
215-
"PRODUCTION_DB_PORT": "3306",
216-
217-
"DEBUG": "true",
218-
"MCP_MYSQL_SSL": "true",
219-
"MCP_MYSQL_REJECT_UNAUTHORIZED": "false"
220-
}
221-
}
222-
```
223-
224-
**Important Notes:**
225-
- You must use the full environment names: LOCAL_, DEVELOPMENT_, STAGING_, PRODUCTION_
226-
- Abbreviations like DEV_ or PROD_ will not work
227-
- Global settings like DEBUG, MCP_MYSQL_SSL apply to all environments
247+
List all configured environments from your `.env` file.
228248

229249
## Available Tools
230250

@@ -254,10 +274,6 @@ Get detailed information about your database:
254274
- Process list
255275
- Available databases
256276

257-
### 3. environments
258-
259-
List all configured environments from your `.env` file.
260-
261277
## Security Considerations
262278

263279
- ✅ Only read-only queries are allowed (SELECT, SHOW, DESCRIBE)
@@ -266,6 +282,15 @@ List all configured environments from your `.env` file.
266282
- ✅ Query timeouts prevent runaway operations
267283
- ⚠️ Keep your `.env` file secure and never commit it to source control
268284

285+
### 3. environments
286+
287+
List all configured environments available in your setup. This tool will show all environments that have been successfully configured, either through:
288+
- Environment variables in the MCP configuration
289+
- A `.env` file in the project directory
290+
- System environment variables
291+
292+
This is helpful for verifying which database environments are properly configured and available for querying.
293+
269294
## Troubleshooting
270295

271296
### Connection Issues

0 commit comments

Comments
 (0)