@berthojoris/mcp-mysql-server 1.9.0 β 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +102 -0
- package/DOCUMENTATIONS.md +222 -3
- package/README.md +418 -629
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -1,145 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
# MySQL MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
**A production-ready Model Context Protocol (MCP) server for MySQL database integration with AI agents**
|
|
4
6
|
|
|
5
7
|
[](https://www.npmjs.com/package/@berthojoris/mcp-mysql-server)
|
|
8
|
+
[](https://www.npmjs.com/package/@berthojoris/mcp-mysql-server)
|
|
6
9
|
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
[](https://www.typescriptlang.org/)
|
|
11
|
+
[](https://modelcontextprotocol.io/)
|
|
7
12
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
## π Features
|
|
13
|
+
[Installation](#-installation) Β· [Quick Start](#-quick-start) Β· [Configuration](#-ai-agent-configuration) Β· [Permissions](#-permission-system) Β· [Tools](#-available-tools) Β· [Documentation](DOCUMENTATIONS.md)
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
- π **Secure by Default** - Parameterized queries, SQL injection protection, permission-based access control
|
|
14
|
-
- π οΈ **100 Powerful Tools** - Complete database operations (CRUD, DDL, queries, schema inspection, transactions, stored procedures, bulk operations, backup/restore, import/export, data migration)
|
|
15
|
-
- ποΈ **Dynamic Per-Project Permissions** - Each AI agent can have different access levels
|
|
16
|
-
- ποΈ **DDL Support** - Create, alter, and drop tables (when explicitly enabled)
|
|
17
|
-
- π **Transaction Support** - Full ACID transaction management (BEGIN, COMMIT, ROLLBACK)
|
|
18
|
-
- π **Dual Mode** - Run as MCP server OR as REST API
|
|
19
|
-
- π **Rich Metadata** - Table schemas, relationships, connection info
|
|
20
|
-
- β‘ **TypeScript** - Fully typed with TypeScript definitions
|
|
15
|
+
</div>
|
|
21
16
|
|
|
22
17
|
---
|
|
23
18
|
|
|
24
|
-
##
|
|
25
|
-
|
|
26
|
-
This MySQL MCP is a **powerful intermediary layer** between AI assistants and MySQL databases. Here's how it compares to manual database access:
|
|
27
|
-
|
|
28
|
-
### Data Access & Querying
|
|
29
|
-
|
|
30
|
-
| Feature | MySQL MCP | Manual Database Access |
|
|
31
|
-
|---------|-----------|------------------------|
|
|
32
|
-
| **Query Execution** | AI can run SELECT/INSERT/UPDATE/DELETE via natural language | Requires manual SQL writing in terminal/client |
|
|
33
|
-
| **Parameterized Queries** | Automatic protection against SQL injection | Must manually parameterize |
|
|
34
|
-
| **Bulk Operations** | Up to 10,000 records per batch with auto-batching | Manual scripting required |
|
|
35
|
-
| **Query Caching** | Built-in LRU cache with TTL | Must implement yourself |
|
|
36
|
-
|
|
37
|
-
### Data Analysis
|
|
38
|
-
|
|
39
|
-
| Feature | MySQL MCP | Manual Database Access |
|
|
40
|
-
|---------|-----------|------------------------|
|
|
41
|
-
| **Query Analysis** | Auto-detects complexity, joins, bottlenecks | Run EXPLAIN manually, interpret yourself |
|
|
42
|
-
| **Optimization Hints** | Auto-generates MySQL 8.0+ optimizer hints | Must know hint syntax |
|
|
43
|
-
| **Execution Plans** | Get EXPLAIN in JSON/TREE/TRADITIONAL formats | Run EXPLAIN manually |
|
|
44
|
-
| **Server Diagnostics** | 9 tools for status, processes, replication | Multiple manual commands |
|
|
45
|
-
|
|
46
|
-
### Data Validation
|
|
47
|
-
|
|
48
|
-
| Feature | MySQL MCP | Manual Database Access |
|
|
49
|
-
|---------|-----------|------------------------|
|
|
50
|
-
| **Input Validation** | Automatic type/length/format validation | Manual validation code |
|
|
51
|
-
| **SQL Injection Prevention** | Multi-layer protection (identifiers, keywords, params) | Depends on your code |
|
|
52
|
-
| **Permission Enforcement** | 10 granular permission categories | Configure in MySQL grants |
|
|
53
|
-
| **Dangerous Query Blocking** | Blocks GRANT, DROP USER, system schema access | No automatic protection |
|
|
54
|
-
|
|
55
|
-
### Schema Inspection
|
|
56
|
-
|
|
57
|
-
| Feature | MySQL MCP | Manual Database Access |
|
|
58
|
-
|---------|-----------|------------------------|
|
|
59
|
-
| **Table Structure** | One command shows columns, keys, indexes | Multiple SHOW/DESCRIBE commands |
|
|
60
|
-
| **Foreign Key Discovery** | Auto-discovers relationships | Manual INFORMATION_SCHEMA queries |
|
|
61
|
-
| **Full Schema Export** | Get entire DB schema (tables, views, procs, triggers) | Multiple manual exports |
|
|
62
|
-
| **Object Comparison** | Compare table structures automatically | Manual diff work |
|
|
63
|
-
|
|
64
|
-
### Debugging & Diagnostics
|
|
65
|
-
|
|
66
|
-
| Feature | MySQL MCP | Manual Database Access |
|
|
67
|
-
|---------|-----------|------------------------|
|
|
68
|
-
| **Query Logging** | Automatic logging with timing, params, status | Enable general_log manually |
|
|
69
|
-
| **Formatted Output** | SQL formatted with highlighted keywords | Raw output |
|
|
70
|
-
| **Process Management** | View/kill processes via simple commands | SHOW PROCESSLIST + KILL manually |
|
|
71
|
-
| **Cache Monitoring** | Hit rate, memory usage, statistics | No built-in tracking |
|
|
72
|
-
|
|
73
|
-
### Advanced Operations
|
|
74
|
-
|
|
75
|
-
| Feature | MySQL MCP | Manual Database Access |
|
|
76
|
-
|---------|-----------|------------------------|
|
|
77
|
-
| **Transactions** | Begin/Commit/Rollback via commands | Manual SQL |
|
|
78
|
-
| **Stored Procedures** | Create, execute, manage with parameter handling | Write DDL manually |
|
|
79
|
-
| **Data Migration** | Copy, move, clone, sync tables with one command | Complex scripts required |
|
|
80
|
-
| **Backup/Restore** | Full DB or table backup/restore | mysqldump + manual restore |
|
|
81
|
-
| **Import/Export** | CSV, JSON, SQL formats supported | Manual scripting |
|
|
82
|
-
|
|
83
|
-
### Key Benefits of Using This MCP
|
|
84
|
-
|
|
85
|
-
1. **Natural Language Interface** - Ask Claude "show me all users with orders > $100" instead of writing SQL
|
|
86
|
-
|
|
87
|
-
2. **Built-in Security** - 5+ validation layers protect against:
|
|
88
|
-
- SQL injection
|
|
89
|
-
- Privilege escalation
|
|
90
|
-
- Cross-database access
|
|
91
|
-
- Dangerous operations
|
|
92
|
-
|
|
93
|
-
3. **Audit Trail** - Every query automatically logged with timing and parameters
|
|
94
|
-
|
|
95
|
-
4. **100 Tools in 16 Categories** - Covers virtually every database task
|
|
19
|
+
## TL;DR - Quick Setup
|
|
96
20
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
21
|
+
```bash
|
|
22
|
+
# Run directly with npx (no installation needed)
|
|
23
|
+
npx @berthojoris/mcp-mysql-server mysql://user:pass@localhost:3306/mydb "list,read,utility"
|
|
24
|
+
```
|
|
100
25
|
|
|
101
|
-
|
|
26
|
+
Add to your AI agent config (`.mcp.json`, `.cursor/mcp.json`, etc.):
|
|
102
27
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
mysql
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
-- Check if safe, then run
|
|
113
|
-
SELECT * FROM users WHERE email LIKE '%@gmail.com';
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"mcpServers": {
|
|
31
|
+
"mysql": {
|
|
32
|
+
"command": "npx",
|
|
33
|
+
"args": ["-y", "@berthojoris/mcp-mysql-server", "mysql://user:pass@localhost:3306/mydb", "list,read,utility"]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
114
37
|
```
|
|
115
38
|
|
|
116
|
-
|
|
117
|
-
> "Show me the users table structure and find all Gmail users"
|
|
118
|
-
- AI calls `read_table_schema`, `explain_query`, `read_records`
|
|
119
|
-
- Returns formatted results with execution time
|
|
120
|
-
- All queries logged, validated, parameterized automatically
|
|
39
|
+
---
|
|
121
40
|
|
|
122
|
-
|
|
41
|
+
## Table of Contents
|
|
42
|
+
|
|
43
|
+
- [Features](#-features)
|
|
44
|
+
- [Installation](#-installation)
|
|
45
|
+
- [Quick Start](#-quick-start)
|
|
46
|
+
- [AI Agent Configuration](#-ai-agent-configuration)
|
|
47
|
+
- [Standard JSON Config](#standard-json-configuration)
|
|
48
|
+
- [OpenAI Codex (TOML)](#openai-codex-cli--vs-code-extension)
|
|
49
|
+
- [Zed IDE](#zed-ide)
|
|
50
|
+
- [Environment Variables](#environment-variables-configuration)
|
|
51
|
+
- [Local Development](#local-path-configuration)
|
|
52
|
+
- [Permission System](#-permission-system)
|
|
53
|
+
- [Available Tools (98 total)](#-available-tools)
|
|
54
|
+
- [Documentation](#-detailed-documentation)
|
|
55
|
+
- [Comparison: MCP vs Manual Access](#-mysql-mcp-vs-manual-database-access)
|
|
56
|
+
- [License](#-license)
|
|
123
57
|
|
|
124
|
-
|
|
125
|
-
|----------|----------------|
|
|
126
|
-
| Quick data lookups | MCP - faster, safer |
|
|
127
|
-
| Complex analysis | MCP - AI can iterate and refine |
|
|
128
|
-
| Schema exploration | MCP - comprehensive tools |
|
|
129
|
-
| Production debugging | MCP with read-only permissions |
|
|
130
|
-
| Bulk data operations | MCP - auto-batching |
|
|
131
|
-
| Data migrations | MCP - 5 migration tools |
|
|
132
|
-
| Learning SQL | Both - MCP shows what it executes |
|
|
58
|
+
---
|
|
133
59
|
|
|
134
|
-
|
|
60
|
+
## Features
|
|
61
|
+
|
|
62
|
+
| Category | Description |
|
|
63
|
+
|----------|-------------|
|
|
64
|
+
| **Full MCP Support** | Works with Claude Code, Cursor, Windsurf, Zed, Cline, Kilo Code, Roo Code, Gemini CLI, OpenAI Codex, and any MCP-compatible AI agent |
|
|
65
|
+
| **Security First** | Parameterized queries, SQL injection protection, permission-based access control |
|
|
66
|
+
| **98 Powerful Tools** | Complete database operations including CRUD, DDL, transactions, stored procedures, backup/restore, migrations |
|
|
67
|
+
| **Granular Permissions** | 10 permission categories for fine-grained access control per project |
|
|
68
|
+
| **Transaction Support** | Full ACID transaction management (BEGIN, COMMIT, ROLLBACK) |
|
|
69
|
+
| **Schema Migrations** | Version control for database schema with up/down migrations |
|
|
70
|
+
| **Dual Mode** | Run as MCP server OR as REST API |
|
|
71
|
+
| **TypeScript** | Fully typed with TypeScript definitions |
|
|
135
72
|
|
|
136
73
|
---
|
|
137
74
|
|
|
138
|
-
##
|
|
75
|
+
## Installation
|
|
139
76
|
|
|
140
|
-
### Option 1: Quick Start (
|
|
77
|
+
### Option 1: Quick Start with npx (Recommended)
|
|
141
78
|
|
|
142
|
-
No installation
|
|
79
|
+
No installation required - run directly:
|
|
143
80
|
|
|
144
81
|
```bash
|
|
145
82
|
npx @berthojoris/mcp-mysql-server mysql://user:pass@localhost:3306/db "list,read,utility"
|
|
@@ -154,11 +91,11 @@ mcp-mysql mysql://user:pass@localhost:3306/db "list,read,utility"
|
|
|
154
91
|
|
|
155
92
|
---
|
|
156
93
|
|
|
157
|
-
##
|
|
94
|
+
## Quick Start
|
|
158
95
|
|
|
159
|
-
### 1. Set Up Environment
|
|
96
|
+
### 1. Set Up Environment (Optional)
|
|
160
97
|
|
|
161
|
-
Create `.env` file
|
|
98
|
+
Create `.env` file for local development:
|
|
162
99
|
|
|
163
100
|
```env
|
|
164
101
|
DB_HOST=localhost
|
|
@@ -166,66 +103,55 @@ DB_PORT=3306
|
|
|
166
103
|
DB_USER=root
|
|
167
104
|
DB_PASSWORD=yourpassword
|
|
168
105
|
DB_NAME=yourdatabase
|
|
169
|
-
|
|
170
|
-
# Optional: Default permissions (can be overridden per-project)
|
|
171
106
|
MCP_CONFIG=list,read,utility
|
|
172
107
|
```
|
|
173
108
|
|
|
174
|
-
### 2. Build Project (
|
|
109
|
+
### 2. Build Project (If Cloned Locally)
|
|
175
110
|
|
|
176
111
|
```bash
|
|
112
|
+
npm install
|
|
177
113
|
npm run build
|
|
178
114
|
```
|
|
179
115
|
|
|
180
|
-
### 3. Configure AI Agent
|
|
116
|
+
### 3. Configure Your AI Agent
|
|
181
117
|
|
|
182
|
-
|
|
118
|
+
See [AI Agent Configuration](#-ai-agent-configuration) section below.
|
|
183
119
|
|
|
184
|
-
|
|
120
|
+
### 4. Restart Your AI Agent
|
|
185
121
|
|
|
186
|
-
|
|
122
|
+
Completely restart your AI agent application to load the MCP server.
|
|
187
123
|
|
|
188
|
-
|
|
124
|
+
### 5. Test It!
|
|
189
125
|
|
|
190
|
-
|
|
191
|
-
{
|
|
192
|
-
"mcpServers": {
|
|
193
|
-
"mysql": {
|
|
194
|
-
"command": "npx",
|
|
195
|
-
"args": [
|
|
196
|
-
"-y",
|
|
197
|
-
"@berthojoris/mcp-mysql-server",
|
|
198
|
-
"mysql://user:password@localhost:3306/database",
|
|
199
|
-
"list,read,utility"
|
|
200
|
-
]
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
```
|
|
126
|
+
Try asking your AI:
|
|
205
127
|
|
|
206
|
-
|
|
128
|
+
> "What databases are available?"
|
|
129
|
+
> "Show me all tables in my database"
|
|
130
|
+
> "What's the structure of the users table?"
|
|
131
|
+
> "Show me the first 5 records from users"
|
|
207
132
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
"mysql": {
|
|
212
|
-
"command": "npx",
|
|
213
|
-
"args": [
|
|
214
|
-
"-y",
|
|
215
|
-
"@berthojoris/mcp-mysql-server",
|
|
216
|
-
"mysql://user:password@localhost:3306/database",
|
|
217
|
-
"list,read,create,update,delete,ddl"
|
|
218
|
-
]
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
```
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## AI Agent Configuration
|
|
223
136
|
|
|
224
|
-
|
|
137
|
+
### Standard JSON Configuration
|
|
225
138
|
|
|
226
|
-
|
|
139
|
+
Most AI agents use a similar JSON configuration format. Use the appropriate config file for your tool:
|
|
227
140
|
|
|
228
|
-
|
|
141
|
+
| AI Agent | Config File Location |
|
|
142
|
+
|----------|---------------------|
|
|
143
|
+
| **Claude Code** | `.mcp.json` (project root) or `~/.mcp.json` (global) |
|
|
144
|
+
| **Cursor** | `.cursor/mcp.json` |
|
|
145
|
+
| **Windsurf** | `~/.codeium/windsurf/mcp_config.json` |
|
|
146
|
+
| **Cline** | VS Code settings or Cline config file |
|
|
147
|
+
| **Gemini CLI** | `~/.gemini/settings.json` |
|
|
148
|
+
| **Kilo Code** | VS Code MCP settings |
|
|
149
|
+
| **Roo Code** | VS Code MCP settings |
|
|
150
|
+
| **Trae AI** | MCP configuration in settings |
|
|
151
|
+
| **Qwen Code** | MCP configuration in settings |
|
|
152
|
+
| **Droid CLI** | MCP configuration in settings |
|
|
153
|
+
|
|
154
|
+
**Universal Configuration Template:**
|
|
229
155
|
|
|
230
156
|
```json
|
|
231
157
|
{
|
|
@@ -243,143 +169,120 @@ Cursor uses `.cursor/mcp.json` in your project root.
|
|
|
243
169
|
}
|
|
244
170
|
```
|
|
245
171
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
Windsurf uses `~/.codeium/windsurf/mcp_config.json`.
|
|
249
|
-
|
|
250
|
-
**Configuration:**
|
|
172
|
+
<details>
|
|
173
|
+
<summary><strong>Multiple Database Configuration</strong></summary>
|
|
251
174
|
|
|
252
175
|
```json
|
|
253
176
|
{
|
|
254
177
|
"mcpServers": {
|
|
255
|
-
"mysql": {
|
|
178
|
+
"mysql-prod": {
|
|
256
179
|
"command": "npx",
|
|
257
180
|
"args": [
|
|
258
181
|
"-y",
|
|
259
182
|
"@berthojoris/mcp-mysql-server",
|
|
260
|
-
"mysql://
|
|
183
|
+
"mysql://reader:pass@prod-server:3306/prod_db",
|
|
261
184
|
"list,read,utility"
|
|
262
185
|
]
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
#### Cline (VS Code Extension)
|
|
269
|
-
|
|
270
|
-
Add to Cline MCP settings in VS Code settings or cline config file.
|
|
271
|
-
|
|
272
|
-
**Configuration:**
|
|
273
|
-
|
|
274
|
-
```json
|
|
275
|
-
{
|
|
276
|
-
"mcpServers": {
|
|
277
|
-
"mysql": {
|
|
186
|
+
},
|
|
187
|
+
"mysql-dev": {
|
|
278
188
|
"command": "npx",
|
|
279
189
|
"args": [
|
|
280
190
|
"-y",
|
|
281
191
|
"@berthojoris/mcp-mysql-server",
|
|
282
|
-
"mysql://
|
|
283
|
-
"list,read,utility"
|
|
192
|
+
"mysql://root:pass@localhost:3306/dev_db",
|
|
193
|
+
"list,read,create,update,delete,execute,ddl,utility"
|
|
284
194
|
]
|
|
285
195
|
}
|
|
286
196
|
}
|
|
287
197
|
}
|
|
288
198
|
```
|
|
289
199
|
|
|
290
|
-
|
|
200
|
+
</details>
|
|
291
201
|
|
|
292
|
-
|
|
202
|
+
---
|
|
293
203
|
|
|
294
|
-
|
|
204
|
+
### OpenAI Codex CLI & VS Code Extension
|
|
295
205
|
|
|
296
|
-
|
|
297
|
-
{
|
|
298
|
-
"mcpServers": {
|
|
299
|
-
"mysql": {
|
|
300
|
-
"command": "npx",
|
|
301
|
-
"args": [
|
|
302
|
-
"-y",
|
|
303
|
-
"@berthojoris/mcp-mysql-server",
|
|
304
|
-
"mysql://user:password@localhost:3306/database",
|
|
305
|
-
"list,read,utility"
|
|
306
|
-
]
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
```
|
|
206
|
+
OpenAI Codex uses TOML format in `~/.codex/config.toml`.
|
|
311
207
|
|
|
312
|
-
|
|
208
|
+
**Quick setup via CLI:**
|
|
313
209
|
|
|
314
|
-
|
|
210
|
+
```bash
|
|
211
|
+
codex mcp add mysql -- npx -y @berthojoris/mcp-mysql-server mysql://user:pass@localhost:3306/db list,read,utility
|
|
212
|
+
```
|
|
315
213
|
|
|
316
|
-
**
|
|
214
|
+
**Manual TOML configuration:**
|
|
317
215
|
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
"args": [
|
|
324
|
-
"-y",
|
|
325
|
-
"@berthojoris/mcp-mysql-server",
|
|
326
|
-
"mysql://user:password@localhost:3306/database",
|
|
327
|
-
"list,read,utility"
|
|
328
|
-
]
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
216
|
+
```toml
|
|
217
|
+
[mcp_servers.mysql]
|
|
218
|
+
command = "npx"
|
|
219
|
+
args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://user:pass@localhost:3306/db", "list,read,utility"]
|
|
220
|
+
startup_timeout_sec = 20
|
|
332
221
|
```
|
|
333
222
|
|
|
334
|
-
|
|
223
|
+
<details>
|
|
224
|
+
<summary><strong>Advanced Codex Configuration</strong></summary>
|
|
335
225
|
|
|
336
|
-
|
|
226
|
+
**With environment variables:**
|
|
337
227
|
|
|
338
|
-
|
|
228
|
+
```toml
|
|
229
|
+
[mcp_servers.mysql]
|
|
230
|
+
command = "npx"
|
|
231
|
+
args = ["-y", "@berthojoris/mcp-mysql-server"]
|
|
339
232
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
"@berthojoris/mcp-mysql-server",
|
|
348
|
-
"mysql://user:password@localhost:3306/database",
|
|
349
|
-
"list,read,utility"
|
|
350
|
-
]
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
233
|
+
[mcp_servers.mysql.env]
|
|
234
|
+
DB_HOST = "localhost"
|
|
235
|
+
DB_PORT = "3306"
|
|
236
|
+
DB_USER = "root"
|
|
237
|
+
DB_PASSWORD = "your_password"
|
|
238
|
+
DB_NAME = "your_database"
|
|
239
|
+
MCP_PERMISSIONS = "list,read,utility"
|
|
354
240
|
```
|
|
355
241
|
|
|
356
|
-
|
|
242
|
+
**Multiple databases:**
|
|
357
243
|
|
|
358
|
-
|
|
244
|
+
```toml
|
|
245
|
+
# Production - Read Only
|
|
246
|
+
[mcp_servers.mysql-prod]
|
|
247
|
+
command = "npx"
|
|
248
|
+
args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://reader:pass@prod:3306/prod_db", "list,read,utility"]
|
|
249
|
+
startup_timeout_sec = 30
|
|
359
250
|
|
|
360
|
-
|
|
251
|
+
# Development - Full Access
|
|
252
|
+
[mcp_servers.mysql-dev]
|
|
253
|
+
command = "npx"
|
|
254
|
+
args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://root:pass@localhost:3306/dev_db", "list,read,create,update,delete,execute,ddl,utility"]
|
|
255
|
+
```
|
|
361
256
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
257
|
+
**Advanced options:**
|
|
258
|
+
|
|
259
|
+
```toml
|
|
260
|
+
[mcp_servers.mysql]
|
|
261
|
+
command = "npx"
|
|
262
|
+
args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://user:pass@localhost:3306/db", "list,read,utility"]
|
|
263
|
+
startup_timeout_sec = 20 # Server startup timeout (default: 10)
|
|
264
|
+
tool_timeout_sec = 120 # Per-tool execution timeout (default: 60)
|
|
265
|
+
enabled = true # Set false to disable without deleting
|
|
266
|
+
# enabled_tools = ["list_tables", "read_records"] # Optional: limit exposed tools
|
|
267
|
+
# disabled_tools = ["drop_table", "delete_record"] # Optional: hide specific tools
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Codex management commands:**
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
codex mcp list # List all configured MCP servers
|
|
274
|
+
codex mcp list --json # List with JSON output
|
|
275
|
+
codex mcp remove mysql # Remove an MCP server
|
|
276
|
+
codex mcp get mysql # Get details about a specific server
|
|
376
277
|
```
|
|
377
278
|
|
|
378
|
-
|
|
279
|
+
</details>
|
|
280
|
+
|
|
281
|
+
---
|
|
379
282
|
|
|
380
|
-
Zed IDE
|
|
283
|
+
### Zed IDE
|
|
381
284
|
|
|
382
|
-
|
|
285
|
+
Zed IDE uses a different structure in `~/.config/zed/settings.json`:
|
|
383
286
|
|
|
384
287
|
```json
|
|
385
288
|
{
|
|
@@ -399,53 +302,36 @@ Zed IDE uses `~/.config/zed/settings.json` for MCP configuration.
|
|
|
399
302
|
}
|
|
400
303
|
```
|
|
401
304
|
|
|
402
|
-
|
|
305
|
+
---
|
|
403
306
|
|
|
404
|
-
|
|
307
|
+
### Environment Variables Configuration
|
|
405
308
|
|
|
406
|
-
|
|
309
|
+
Alternative approach using environment variables instead of connection string:
|
|
407
310
|
|
|
408
311
|
```json
|
|
409
312
|
{
|
|
410
313
|
"mcpServers": {
|
|
411
314
|
"mysql": {
|
|
412
315
|
"command": "npx",
|
|
413
|
-
"args": [
|
|
414
|
-
|
|
415
|
-
"
|
|
416
|
-
"
|
|
417
|
-
"
|
|
418
|
-
|
|
316
|
+
"args": ["-y", "@berthojoris/mcp-mysql-server"],
|
|
317
|
+
"env": {
|
|
318
|
+
"DB_HOST": "localhost",
|
|
319
|
+
"DB_PORT": "3306",
|
|
320
|
+
"DB_USER": "root",
|
|
321
|
+
"DB_PASSWORD": "your_password",
|
|
322
|
+
"DB_NAME": "your_database",
|
|
323
|
+
"MCP_PERMISSIONS": "list,read,utility"
|
|
324
|
+
}
|
|
419
325
|
}
|
|
420
326
|
}
|
|
421
327
|
}
|
|
422
328
|
```
|
|
423
329
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
Roo Code is a VS Code extension with MCP support.
|
|
427
|
-
|
|
428
|
-
**Configuration:**
|
|
429
|
-
|
|
430
|
-
```json
|
|
431
|
-
{
|
|
432
|
-
"mcpServers": {
|
|
433
|
-
"mysql": {
|
|
434
|
-
"command": "npx",
|
|
435
|
-
"args": [
|
|
436
|
-
"-y",
|
|
437
|
-
"@berthojoris/mcp-mysql-server",
|
|
438
|
-
"mysql://user:password@localhost:3306/database",
|
|
439
|
-
"list,read,utility"
|
|
440
|
-
]
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
```
|
|
330
|
+
---
|
|
445
331
|
|
|
446
|
-
|
|
332
|
+
### Local Path Configuration
|
|
447
333
|
|
|
448
|
-
|
|
334
|
+
For development or when you need full control over the source code:
|
|
449
335
|
|
|
450
336
|
```json
|
|
451
337
|
{
|
|
@@ -462,246 +348,128 @@ If you've cloned the repository locally:
|
|
|
462
348
|
}
|
|
463
349
|
```
|
|
464
350
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
Alternative approach using environment variables:
|
|
468
|
-
|
|
469
|
-
```json
|
|
470
|
-
{
|
|
471
|
-
"mcpServers": {
|
|
472
|
-
"mysql": {
|
|
473
|
-
"command": "node",
|
|
474
|
-
"args": [
|
|
475
|
-
"/path/to/mcp_mysql/dist/mcp-server.js"
|
|
476
|
-
],
|
|
477
|
-
"env": {
|
|
478
|
-
"DB_HOST": "localhost",
|
|
479
|
-
"DB_PORT": "3306",
|
|
480
|
-
"DB_USER": "root",
|
|
481
|
-
"DB_PASSWORD": "your_password",
|
|
482
|
-
"DB_NAME": "your_database",
|
|
483
|
-
"MCP_PERMISSIONS": "list,read,utility"
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
### 4. Restart AI Agent
|
|
491
|
-
|
|
492
|
-
Completely restart your AI agent application to load the MCP server.
|
|
493
|
-
|
|
494
|
-
### 5. Test It!
|
|
351
|
+
<details>
|
|
352
|
+
<summary><strong>When to Use Local Path</strong></summary>
|
|
495
353
|
|
|
496
|
-
|
|
497
|
-
- *"What databases are available?"*
|
|
498
|
-
- *"Show me all tables in my database"*
|
|
499
|
-
- *"What's the structure of the users table?"*
|
|
500
|
-
- *"Show me the first 5 records from users"*
|
|
501
|
-
|
|
502
|
-
---
|
|
354
|
+
Use local path configuration when you:
|
|
503
355
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
-
|
|
510
|
-
- **Need offline access** without internet dependency
|
|
511
|
-
- **Want to modify the source** for custom functionality
|
|
512
|
-
- **Need faster startup** without package download
|
|
513
|
-
- **Are developing/debugging** the MCP server
|
|
514
|
-
- **Have network restrictions** or security policies
|
|
515
|
-
|
|
516
|
-
### Local Configuration Benefits
|
|
356
|
+
- Want full control over the version and source code
|
|
357
|
+
- Need offline access without internet dependency
|
|
358
|
+
- Want to modify the source for custom functionality
|
|
359
|
+
- Need faster startup without package download
|
|
360
|
+
- Are developing/debugging the MCP server
|
|
361
|
+
- Have network restrictions or security policies
|
|
517
362
|
|
|
518
363
|
| Feature | Local Path | NPX |
|
|
519
364
|
|---------|------------|-----|
|
|
520
365
|
| **Control** | Full control over code | Depends on npm registry |
|
|
521
|
-
| **Offline** | Works completely offline | Requires internet
|
|
366
|
+
| **Offline** | Works completely offline | Requires internet |
|
|
522
367
|
| **Speed** | Instant startup | Download time |
|
|
523
|
-
| **Customization** | Can modify source
|
|
524
|
-
| **Debugging** | Full source access available | Limited debugging |
|
|
368
|
+
| **Customization** | Can modify source | Limited to published version |
|
|
525
369
|
| **Updates** | Manual updates | Automatic updates |
|
|
526
|
-
| **Setup** | Requires building
|
|
370
|
+
| **Setup** | Requires building | Zero setup |
|
|
527
371
|
|
|
528
|
-
|
|
372
|
+
**Setup requirements:**
|
|
529
373
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
2. **Ensure paths are absolute** - Use full paths to avoid ambiguity
|
|
537
|
-
3. **Use correct binaries:**
|
|
538
|
-
- `bin/mcp-mysql.js` - CLI wrapper with argument parsing
|
|
539
|
-
- `dist/mcp-server.js` - Direct server executable
|
|
374
|
+
```bash
|
|
375
|
+
cd /path/to/mcp_mysql
|
|
376
|
+
npm install
|
|
377
|
+
npm run build
|
|
378
|
+
```
|
|
540
379
|
|
|
541
|
-
|
|
380
|
+
**Available binaries:**
|
|
542
381
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
{
|
|
546
|
-
"command": "node",
|
|
547
|
-
"args": [
|
|
548
|
-
"C:\\DEKSTOP\\MCP\\mcp_mysql\\bin\\mcp-mysql.js",
|
|
549
|
-
"mysql://user:pass@localhost:3306/database",
|
|
550
|
-
"permissions"
|
|
551
|
-
]
|
|
552
|
-
}
|
|
553
|
-
```
|
|
382
|
+
- `bin/mcp-mysql.js` - CLI wrapper with argument parsing
|
|
383
|
+
- `dist/mcp-server.js` - Direct server executable
|
|
554
384
|
|
|
555
|
-
**
|
|
556
|
-
```json
|
|
557
|
-
{
|
|
558
|
-
"command": "node",
|
|
559
|
-
"args": ["C:\\DEKSTOP\\MCP\\mcp_mysql\\dist\\mcp-server.js"],
|
|
560
|
-
"env": {
|
|
561
|
-
"DB_HOST": "localhost",
|
|
562
|
-
"DB_PORT": "3306",
|
|
563
|
-
"DB_USER": "root",
|
|
564
|
-
"DB_PASSWORD": "",
|
|
565
|
-
"DB_NAME": "database",
|
|
566
|
-
"MCP_PERMISSIONS": "permissions"
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
```
|
|
385
|
+
**Path tips:**
|
|
570
386
|
|
|
571
|
-
|
|
387
|
+
- Windows: Use double backslashes `\\` in JSON
|
|
388
|
+
- Cross-platform: Use forward slashes `/` if supported
|
|
389
|
+
- Always use absolute paths for reliability
|
|
572
390
|
|
|
573
|
-
|
|
574
|
-
- **Cross-platform:** Use forward slashes `/` if supported by your AI agent
|
|
575
|
-
- **Environment variables:** Can use `%USERPROFILE%` or `$HOME` in some systems
|
|
576
|
-
- **Relative paths:** Not recommended - use absolute paths for reliability
|
|
391
|
+
</details>
|
|
577
392
|
|
|
578
393
|
---
|
|
579
394
|
|
|
580
|
-
##
|
|
395
|
+
## Permission System
|
|
396
|
+
|
|
397
|
+
Control database access with granular permission categories:
|
|
581
398
|
|
|
582
399
|
### Permission Categories
|
|
583
400
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
|
587
|
-
|
|
588
|
-
|
|
|
589
|
-
|
|
|
590
|
-
|
|
|
591
|
-
|
|
|
592
|
-
|
|
|
593
|
-
|
|
|
594
|
-
|
|
|
595
|
-
|
|
|
596
|
-
|
|
597
|
-
|
|
401
|
+
| Permission | Operations | Use Case |
|
|
402
|
+
|------------|------------|----------|
|
|
403
|
+
| `list` | List databases, tables, schemas | Database exploration |
|
|
404
|
+
| `read` | SELECT queries, read data | Analytics, reporting |
|
|
405
|
+
| `create` | INSERT new records | Data entry |
|
|
406
|
+
| `update` | UPDATE existing records | Data maintenance |
|
|
407
|
+
| `delete` | DELETE records | Data cleanup |
|
|
408
|
+
| `execute` | Execute custom SQL (DML) + Advanced SQL | Complex operations |
|
|
409
|
+
| `ddl` | CREATE/ALTER/DROP tables | Schema management |
|
|
410
|
+
| `procedure` | Stored procedures (CREATE/DROP/EXECUTE) | Procedure management |
|
|
411
|
+
| `transaction` | BEGIN, COMMIT, ROLLBACK | ACID operations |
|
|
412
|
+
| `utility` | Connection testing, diagnostics | Troubleshooting |
|
|
413
|
+
|
|
414
|
+
### Common Permission Sets
|
|
415
|
+
|
|
416
|
+
| Environment | Permissions | Description |
|
|
417
|
+
|-------------|-------------|-------------|
|
|
418
|
+
| **Production (Safe)** | `list,read,utility` | Read-only access |
|
|
419
|
+
| **Data Entry** | `list,read,create,utility` | Can add records |
|
|
420
|
+
| **Full Data Access** | `list,read,create,update,delete,utility` | All CRUD operations |
|
|
421
|
+
| **With Transactions** | `list,read,create,update,delete,transaction,utility` | CRUD + ACID |
|
|
422
|
+
| **Development** | `list,read,create,update,delete,execute,ddl,transaction,utility` | Full access |
|
|
423
|
+
| **DBA Tasks** | `list,ddl,utility` | Schema management only |
|
|
598
424
|
|
|
599
425
|
### Per-Project Configuration
|
|
600
426
|
|
|
601
|
-
|
|
427
|
+
Each project can have different permissions - specify as the second argument after the connection string:
|
|
602
428
|
|
|
603
429
|
```json
|
|
604
430
|
{
|
|
605
431
|
"args": [
|
|
606
432
|
"mysql://user:pass@localhost:3306/db",
|
|
607
|
-
"list,read,utility"
|
|
433
|
+
"list,read,utility"
|
|
608
434
|
]
|
|
609
435
|
}
|
|
610
436
|
```
|
|
611
437
|
|
|
612
|
-
### Common Permission Sets
|
|
613
|
-
|
|
614
|
-
**Production Read-Only:**
|
|
615
|
-
```
|
|
616
|
-
list,read,utility
|
|
617
|
-
```
|
|
618
|
-
|
|
619
|
-
**Data Entry:**
|
|
620
|
-
```
|
|
621
|
-
list,read,create,utility
|
|
622
|
-
```
|
|
623
|
-
|
|
624
|
-
**Full Data Access (No Schema Changes):**
|
|
625
|
-
```
|
|
626
|
-
list,read,create,update,delete,utility
|
|
627
|
-
```
|
|
628
|
-
|
|
629
|
-
**Full Data Access with Transactions:**
|
|
630
|
-
```
|
|
631
|
-
list,read,create,update,delete,transaction,utility
|
|
632
|
-
```
|
|
633
|
-
|
|
634
|
-
**Development (Full Access):**
|
|
635
|
-
```
|
|
636
|
-
list,read,create,update,delete,execute,ddl,transaction,utility
|
|
637
|
-
```
|
|
638
|
-
|
|
639
|
-
**DBA Tasks:**
|
|
640
|
-
```
|
|
641
|
-
list,ddl,utility
|
|
642
|
-
```
|
|
643
|
-
|
|
644
|
-
### Multiple Projects Example
|
|
645
|
-
|
|
646
|
-
You can have different databases with different permissions in the same AI agent:
|
|
647
|
-
|
|
648
|
-
**Using NPX:**
|
|
649
|
-
```json
|
|
650
|
-
{
|
|
651
|
-
"mcpServers": {
|
|
652
|
-
"mysql-prod": {
|
|
653
|
-
"command": "npx",
|
|
654
|
-
"args": [
|
|
655
|
-
"-y",
|
|
656
|
-
"@berthojoris/mcp-mysql-server",
|
|
657
|
-
"mysql://reader:pass@prod-server:3306/prod_db",
|
|
658
|
-
"list,read,utility"
|
|
659
|
-
]
|
|
660
|
-
},
|
|
661
|
-
"mysql-dev": {
|
|
662
|
-
"command": "npx",
|
|
663
|
-
"args": [
|
|
664
|
-
"-y",
|
|
665
|
-
"@berthojoris/mcp-mysql-server",
|
|
666
|
-
"mysql://root:pass@localhost:3306/dev_db",
|
|
667
|
-
"list,read,create,update,delete,execute,ddl,utility"
|
|
668
|
-
]
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
```
|
|
673
|
-
|
|
674
|
-
**Using Local Paths:**
|
|
675
|
-
```json
|
|
676
|
-
{
|
|
677
|
-
"mcpServers": {
|
|
678
|
-
"mysql-prod": {
|
|
679
|
-
"command": "node",
|
|
680
|
-
"args": [
|
|
681
|
-
"C:\\DEKSTOP\\MCP\\mcp_mysql\\bin\\mcp-mysql.js",
|
|
682
|
-
"mysql://reader:pass@prod-server:3306/prod_db",
|
|
683
|
-
"list,read,utility"
|
|
684
|
-
]
|
|
685
|
-
},
|
|
686
|
-
"mysql-dev": {
|
|
687
|
-
"command": "node",
|
|
688
|
-
"args": [
|
|
689
|
-
"C:\\DEKSTOP\\MCP\\mcp_mysql\\bin\\mcp-mysql.js",
|
|
690
|
-
"mysql://root:pass@localhost:3306/dev_db",
|
|
691
|
-
"list,read,create,update,delete,execute,ddl,utility"
|
|
692
|
-
]
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
```
|
|
697
|
-
|
|
698
438
|
---
|
|
699
439
|
|
|
700
|
-
##
|
|
440
|
+
## Available Tools
|
|
441
|
+
|
|
442
|
+
The MCP server provides **98 powerful tools** organized into categories:
|
|
443
|
+
|
|
444
|
+
### Quick Reference
|
|
445
|
+
|
|
446
|
+
| Category | Count | Key Tools |
|
|
447
|
+
|----------|-------|-----------|
|
|
448
|
+
| [Database Discovery](#database-discovery) | 4 | `list_databases`, `list_tables`, `read_table_schema` |
|
|
449
|
+
| [CRUD Operations](#data-operations---crud) | 4 | `create_record`, `read_records`, `update_record`, `delete_record` |
|
|
450
|
+
| [Bulk Operations](#bulk-operations) | 3 | `bulk_insert`, `bulk_update`, `bulk_delete` |
|
|
451
|
+
| [Custom Queries](#custom-queries) | 2 | `run_query`, `execute_sql` |
|
|
452
|
+
| [Schema Management](#schema-management---ddl) | 4 | `create_table`, `alter_table`, `drop_table`, `execute_ddl` |
|
|
453
|
+
| [Transactions](#transaction-management) | 5 | `begin_transaction`, `commit_transaction`, `rollback_transaction` |
|
|
454
|
+
| [Stored Procedures](#stored-procedures) | 6 | `create_stored_procedure`, `execute_stored_procedure` |
|
|
455
|
+
| [Views](#views-management) | 6 | `create_view`, `alter_view`, `drop_view` |
|
|
456
|
+
| [Triggers](#triggers-management) | 5 | `create_trigger`, `drop_trigger` |
|
|
457
|
+
| [Functions](#functions-management) | 6 | `create_function`, `execute_function` |
|
|
458
|
+
| [Indexes](#index-management) | 5 | `create_index`, `drop_index`, `analyze_index` |
|
|
459
|
+
| [Constraints](#constraint-management) | 7 | `add_foreign_key`, `add_unique_constraint` |
|
|
460
|
+
| [Table Maintenance](#table-maintenance) | 8 | `analyze_table`, `optimize_table`, `repair_table` |
|
|
461
|
+
| [Server Management](#process--server-management) | 9 | `show_process_list`, `explain_query` |
|
|
462
|
+
| [Cache](#cache-management) | 5 | `get_cache_stats`, `clear_cache` |
|
|
463
|
+
| [Query Optimization](#query-optimization) | 2 | `analyze_query`, `get_optimization_hints` |
|
|
464
|
+
| [Backup & Restore](#database-backup--restore) | 5 | `backup_database`, `restore_from_sql` |
|
|
465
|
+
| [Import/Export](#data-importexport) | 5 | `export_table_to_json`, `import_from_csv` |
|
|
466
|
+
| [Data Migration](#data-migration) | 5 | `copy_table_data`, `sync_table_data` |
|
|
467
|
+
| [Schema Migrations](#schema-versioning--migrations) | 9 | `create_migration`, `apply_migrations` |
|
|
468
|
+
| [Utilities](#utilities) | 4 | `test_connection`, `export_table_to_csv` |
|
|
701
469
|
|
|
702
|
-
|
|
470
|
+
---
|
|
703
471
|
|
|
704
|
-
### Database Discovery
|
|
472
|
+
### Database Discovery
|
|
705
473
|
|
|
706
474
|
| Tool | Description |
|
|
707
475
|
|------|-------------|
|
|
@@ -710,7 +478,7 @@ The MCP server provides **100 powerful tools**:
|
|
|
710
478
|
| `read_table_schema` | Gets detailed schema (columns, types, keys, indexes) |
|
|
711
479
|
| `get_table_relationships` | Discovers foreign key relationships |
|
|
712
480
|
|
|
713
|
-
### Data Operations - CRUD
|
|
481
|
+
### Data Operations - CRUD
|
|
714
482
|
|
|
715
483
|
| Tool | Description |
|
|
716
484
|
|------|-------------|
|
|
@@ -719,40 +487,40 @@ The MCP server provides **100 powerful tools**:
|
|
|
719
487
|
| `update_record` | Update records based on conditions |
|
|
720
488
|
| `delete_record` | Delete records with safety checks |
|
|
721
489
|
|
|
722
|
-
### Bulk Operations
|
|
490
|
+
### Bulk Operations
|
|
723
491
|
|
|
724
492
|
| Tool | Description | Performance |
|
|
725
493
|
|------|-------------|-------------|
|
|
726
|
-
| `bulk_insert` | Insert multiple records in batches
|
|
727
|
-
| `bulk_update` | Update multiple records with different conditions
|
|
728
|
-
| `bulk_delete` | Delete multiple record sets
|
|
494
|
+
| `bulk_insert` | Insert multiple records in batches | Up to 10,000 records/batch |
|
|
495
|
+
| `bulk_update` | Update multiple records with different conditions | Up to 1,000 ops/batch |
|
|
496
|
+
| `bulk_delete` | Delete multiple record sets | Up to 1,000 ops/batch |
|
|
729
497
|
|
|
730
|
-
### Custom Queries
|
|
498
|
+
### Custom Queries
|
|
731
499
|
|
|
732
500
|
| Tool | Description |
|
|
733
501
|
|------|-------------|
|
|
734
502
|
| `run_query` | Execute read-only SELECT queries |
|
|
735
|
-
| `execute_sql` | Execute write operations (INSERT, UPDATE, DELETE, or DDL
|
|
503
|
+
| `execute_sql` | Execute write operations (INSERT, UPDATE, DELETE, or DDL) |
|
|
736
504
|
|
|
737
|
-
### Schema Management - DDL
|
|
505
|
+
### Schema Management - DDL
|
|
738
506
|
|
|
739
507
|
| Tool | Description | Requires |
|
|
740
508
|
|------|-------------|----------|
|
|
741
|
-
| `create_table` | Create new tables with columns and indexes | `ddl`
|
|
742
|
-
| `alter_table` | Modify table structure
|
|
743
|
-
| `drop_table` | Delete tables | `ddl`
|
|
744
|
-
| `execute_ddl` | Execute raw DDL SQL
|
|
509
|
+
| `create_table` | Create new tables with columns and indexes | `ddl` |
|
|
510
|
+
| `alter_table` | Modify table structure | `ddl` |
|
|
511
|
+
| `drop_table` | Delete tables | `ddl` |
|
|
512
|
+
| `execute_ddl` | Execute raw DDL SQL | `ddl` |
|
|
745
513
|
|
|
746
|
-
### Utilities
|
|
514
|
+
### Utilities
|
|
747
515
|
|
|
748
516
|
| Tool | Description |
|
|
749
517
|
|------|-------------|
|
|
750
518
|
| `test_connection` | Test database connectivity and measure latency |
|
|
751
519
|
| `describe_connection` | Get current connection information |
|
|
752
|
-
| `export_table_to_csv` | Export table data to CSV format
|
|
753
|
-
| `export_query_to_csv` | Export
|
|
520
|
+
| `export_table_to_csv` | Export table data to CSV format |
|
|
521
|
+
| `export_query_to_csv` | Export query results to CSV format |
|
|
754
522
|
|
|
755
|
-
### Transaction Management
|
|
523
|
+
### Transaction Management
|
|
756
524
|
|
|
757
525
|
| Tool | Description |
|
|
758
526
|
|------|-------------|
|
|
@@ -762,189 +530,210 @@ The MCP server provides **100 powerful tools**:
|
|
|
762
530
|
| `get_transaction_status` | Check if a transaction is active |
|
|
763
531
|
| `execute_in_transaction` | Execute SQL within a transaction context |
|
|
764
532
|
|
|
765
|
-
### Stored Procedures
|
|
533
|
+
### Stored Procedures
|
|
766
534
|
|
|
767
535
|
| Tool | Description | Requires |
|
|
768
536
|
|------|-------------|----------|
|
|
769
|
-
| `list_stored_procedures` | List all stored procedures
|
|
770
|
-
| `create_stored_procedure` | Create new stored procedures
|
|
771
|
-
| `get_stored_procedure_info` | Get
|
|
772
|
-
| `execute_stored_procedure` | Execute
|
|
773
|
-
| `drop_stored_procedure` | Delete stored procedures | `procedure`
|
|
774
|
-
| `show_create_procedure` | Show CREATE statement
|
|
537
|
+
| `list_stored_procedures` | List all stored procedures | `procedure` |
|
|
538
|
+
| `create_stored_procedure` | Create new stored procedures | `procedure` |
|
|
539
|
+
| `get_stored_procedure_info` | Get procedure details | `procedure` |
|
|
540
|
+
| `execute_stored_procedure` | Execute with IN/OUT/INOUT params | `procedure` |
|
|
541
|
+
| `drop_stored_procedure` | Delete stored procedures | `procedure` |
|
|
542
|
+
| `show_create_procedure` | Show CREATE statement | `procedure` |
|
|
775
543
|
|
|
776
|
-
### Views Management
|
|
544
|
+
### Views Management
|
|
777
545
|
|
|
778
546
|
| Tool | Description | Requires |
|
|
779
547
|
|------|-------------|----------|
|
|
780
|
-
| `list_views` | List all views in the database | `list`
|
|
781
|
-
| `get_view_info` | Get detailed information
|
|
782
|
-
| `create_view` | Create a new view
|
|
783
|
-
| `alter_view` | Alter an existing view
|
|
784
|
-
| `drop_view` | Drop a view | `ddl`
|
|
785
|
-
| `show_create_view` | Show CREATE statement
|
|
548
|
+
| `list_views` | List all views in the database | `list` |
|
|
549
|
+
| `get_view_info` | Get detailed view information | `list` |
|
|
550
|
+
| `create_view` | Create a new view | `ddl` |
|
|
551
|
+
| `alter_view` | Alter an existing view | `ddl` |
|
|
552
|
+
| `drop_view` | Drop a view | `ddl` |
|
|
553
|
+
| `show_create_view` | Show CREATE statement | `list` |
|
|
786
554
|
|
|
787
|
-
### Triggers Management
|
|
555
|
+
### Triggers Management
|
|
788
556
|
|
|
789
557
|
| Tool | Description | Requires |
|
|
790
558
|
|------|-------------|----------|
|
|
791
|
-
| `list_triggers` | List all triggers
|
|
792
|
-
| `get_trigger_info` | Get
|
|
793
|
-
| `create_trigger` | Create a new trigger
|
|
794
|
-
| `drop_trigger` | Drop a trigger | `ddl`
|
|
795
|
-
| `show_create_trigger` | Show CREATE statement
|
|
559
|
+
| `list_triggers` | List all triggers | `list` |
|
|
560
|
+
| `get_trigger_info` | Get trigger details | `list` |
|
|
561
|
+
| `create_trigger` | Create a new trigger | `ddl` |
|
|
562
|
+
| `drop_trigger` | Drop a trigger | `ddl` |
|
|
563
|
+
| `show_create_trigger` | Show CREATE statement | `list` |
|
|
796
564
|
|
|
797
|
-
### Functions Management
|
|
565
|
+
### Functions Management
|
|
798
566
|
|
|
799
567
|
| Tool | Description | Requires |
|
|
800
568
|
|------|-------------|----------|
|
|
801
|
-
| `list_functions` | List all user-defined functions | `list`
|
|
802
|
-
| `get_function_info` | Get
|
|
803
|
-
| `create_function` | Create a new
|
|
804
|
-
| `drop_function` | Drop a function | `ddl`
|
|
805
|
-
| `show_create_function` | Show CREATE statement
|
|
806
|
-
| `execute_function` | Execute
|
|
569
|
+
| `list_functions` | List all user-defined functions | `list` |
|
|
570
|
+
| `get_function_info` | Get function details | `list` |
|
|
571
|
+
| `create_function` | Create a new function | `ddl` |
|
|
572
|
+
| `drop_function` | Drop a function | `ddl` |
|
|
573
|
+
| `show_create_function` | Show CREATE statement | `list` |
|
|
574
|
+
| `execute_function` | Execute and return result | `read` |
|
|
807
575
|
|
|
808
|
-
### Index Management
|
|
576
|
+
### Index Management
|
|
809
577
|
|
|
810
578
|
| Tool | Description | Requires |
|
|
811
579
|
|------|-------------|----------|
|
|
812
|
-
| `list_indexes` | List all indexes for a table | `list`
|
|
813
|
-
| `get_index_info` | Get
|
|
814
|
-
| `create_index` | Create
|
|
815
|
-
| `drop_index` | Drop an index
|
|
816
|
-
| `analyze_index` | Analyze index statistics | `utility`
|
|
580
|
+
| `list_indexes` | List all indexes for a table | `list` |
|
|
581
|
+
| `get_index_info` | Get index details | `list` |
|
|
582
|
+
| `create_index` | Create index (BTREE, HASH, FULLTEXT, SPATIAL) | `ddl` |
|
|
583
|
+
| `drop_index` | Drop an index | `ddl` |
|
|
584
|
+
| `analyze_index` | Analyze index statistics | `utility` |
|
|
817
585
|
|
|
818
|
-
### Constraint Management
|
|
586
|
+
### Constraint Management
|
|
819
587
|
|
|
820
588
|
| Tool | Description | Requires |
|
|
821
589
|
|------|-------------|----------|
|
|
822
|
-
| `list_foreign_keys` | List all foreign keys
|
|
823
|
-
| `list_constraints` | List all constraints (PK, FK, UNIQUE, CHECK) | `list`
|
|
824
|
-
| `add_foreign_key` | Add a foreign key constraint | `ddl`
|
|
825
|
-
| `drop_foreign_key` | Drop a foreign key
|
|
826
|
-
| `add_unique_constraint` | Add a unique constraint | `ddl`
|
|
827
|
-
| `drop_constraint` | Drop
|
|
828
|
-
| `add_check_constraint` | Add
|
|
590
|
+
| `list_foreign_keys` | List all foreign keys | `list` |
|
|
591
|
+
| `list_constraints` | List all constraints (PK, FK, UNIQUE, CHECK) | `list` |
|
|
592
|
+
| `add_foreign_key` | Add a foreign key constraint | `ddl` |
|
|
593
|
+
| `drop_foreign_key` | Drop a foreign key | `ddl` |
|
|
594
|
+
| `add_unique_constraint` | Add a unique constraint | `ddl` |
|
|
595
|
+
| `drop_constraint` | Drop UNIQUE or CHECK constraint | `ddl` |
|
|
596
|
+
| `add_check_constraint` | Add CHECK constraint (MySQL 8.0.16+) | `ddl` |
|
|
829
597
|
|
|
830
|
-
### Table Maintenance
|
|
598
|
+
### Table Maintenance
|
|
831
599
|
|
|
832
600
|
| Tool | Description | Requires |
|
|
833
601
|
|------|-------------|----------|
|
|
834
|
-
| `analyze_table` | Update index statistics
|
|
835
|
-
| `optimize_table` | Reclaim
|
|
836
|
-
| `check_table` | Check table for errors | `utility`
|
|
837
|
-
| `repair_table` | Repair corrupted table
|
|
838
|
-
| `truncate_table` | Remove all rows quickly | `ddl`
|
|
839
|
-
| `get_table_status` | Get
|
|
840
|
-
| `flush_table` | Close and reopen table(s) | `utility`
|
|
841
|
-
| `get_table_size` | Get size information
|
|
602
|
+
| `analyze_table` | Update index statistics | `utility` |
|
|
603
|
+
| `optimize_table` | Reclaim space and defragment | `utility` |
|
|
604
|
+
| `check_table` | Check table for errors | `utility` |
|
|
605
|
+
| `repair_table` | Repair corrupted table | `utility` |
|
|
606
|
+
| `truncate_table` | Remove all rows quickly | `ddl` |
|
|
607
|
+
| `get_table_status` | Get table status and statistics | `list` |
|
|
608
|
+
| `flush_table` | Close and reopen table(s) | `utility` |
|
|
609
|
+
| `get_table_size` | Get size information | `list` |
|
|
842
610
|
|
|
843
|
-
### Process & Server Management
|
|
611
|
+
### Process & Server Management
|
|
844
612
|
|
|
845
613
|
| Tool | Description | Requires |
|
|
846
614
|
|------|-------------|----------|
|
|
847
|
-
| `show_process_list` | Show
|
|
848
|
-
| `kill_process` | Kill a MySQL process/connection | `utility`
|
|
849
|
-
| `show_status` | Show
|
|
850
|
-
| `show_variables` | Show
|
|
851
|
-
| `explain_query` | Show query execution plan
|
|
852
|
-
| `show_engine_status` | Show storage engine status
|
|
853
|
-
| `get_server_info` | Get comprehensive server
|
|
854
|
-
| `show_binary_logs` | Show binary log files | `utility`
|
|
855
|
-
| `show_replication_status` | Show replication status | `utility`
|
|
856
|
-
|
|
857
|
-
### Cache Management
|
|
615
|
+
| `show_process_list` | Show running MySQL processes | `utility` |
|
|
616
|
+
| `kill_process` | Kill a MySQL process/connection | `utility` |
|
|
617
|
+
| `show_status` | Show server status variables | `utility` |
|
|
618
|
+
| `show_variables` | Show server configuration | `utility` |
|
|
619
|
+
| `explain_query` | Show query execution plan | `utility` |
|
|
620
|
+
| `show_engine_status` | Show storage engine status | `utility` |
|
|
621
|
+
| `get_server_info` | Get comprehensive server info | `utility` |
|
|
622
|
+
| `show_binary_logs` | Show binary log files | `utility` |
|
|
623
|
+
| `show_replication_status` | Show replication status | `utility` |
|
|
624
|
+
|
|
625
|
+
### Cache Management
|
|
858
626
|
|
|
859
627
|
| Tool | Description |
|
|
860
628
|
|------|-------------|
|
|
861
629
|
| `get_cache_stats` | Get query cache statistics |
|
|
862
630
|
| `get_cache_config` | Get current cache configuration |
|
|
863
|
-
| `configure_cache` | Configure cache settings
|
|
864
|
-
| `clear_cache` | Clear all cached
|
|
865
|
-
| `invalidate_table_cache` | Invalidate cache for
|
|
631
|
+
| `configure_cache` | Configure cache settings |
|
|
632
|
+
| `clear_cache` | Clear all cached results |
|
|
633
|
+
| `invalidate_table_cache` | Invalidate cache for specific table |
|
|
866
634
|
|
|
867
|
-
### Query Optimization
|
|
635
|
+
### Query Optimization
|
|
868
636
|
|
|
869
637
|
| Tool | Description |
|
|
870
638
|
|------|-------------|
|
|
871
639
|
| `analyze_query` | Analyze query and get optimization suggestions |
|
|
872
|
-
| `get_optimization_hints` | Get optimizer hints for SPEED, MEMORY, or STABILITY
|
|
640
|
+
| `get_optimization_hints` | Get optimizer hints for SPEED, MEMORY, or STABILITY |
|
|
873
641
|
|
|
874
|
-
### Database Backup & Restore
|
|
642
|
+
### Database Backup & Restore
|
|
875
643
|
|
|
876
644
|
| Tool | Description | Requires |
|
|
877
645
|
|------|-------------|----------|
|
|
878
|
-
| `backup_table` | Backup single table to SQL dump
|
|
879
|
-
| `backup_database` | Backup entire database to SQL dump | `utility`
|
|
880
|
-
| `restore_from_sql` | Restore
|
|
881
|
-
| `get_create_table_statement` | Get CREATE TABLE statement
|
|
882
|
-
| `get_database_schema` | Get complete database schema
|
|
646
|
+
| `backup_table` | Backup single table to SQL dump | `utility` |
|
|
647
|
+
| `backup_database` | Backup entire database to SQL dump | `utility` |
|
|
648
|
+
| `restore_from_sql` | Restore from SQL dump content | `ddl` |
|
|
649
|
+
| `get_create_table_statement` | Get CREATE TABLE statement | `list` |
|
|
650
|
+
| `get_database_schema` | Get complete database schema | `list` |
|
|
883
651
|
|
|
884
|
-
### Data Import/Export
|
|
652
|
+
### Data Import/Export
|
|
885
653
|
|
|
886
654
|
| Tool | Description | Requires |
|
|
887
655
|
|------|-------------|----------|
|
|
888
|
-
| `export_table_to_json` | Export table
|
|
889
|
-
| `export_query_to_json` | Export query results to JSON
|
|
890
|
-
| `export_table_to_sql` | Export
|
|
891
|
-
| `import_from_csv` | Import
|
|
892
|
-
| `import_from_json` | Import
|
|
656
|
+
| `export_table_to_json` | Export table to JSON format | `utility` |
|
|
657
|
+
| `export_query_to_json` | Export query results to JSON | `utility` |
|
|
658
|
+
| `export_table_to_sql` | Export to SQL INSERT statements | `utility` |
|
|
659
|
+
| `import_from_csv` | Import from CSV string | `create` |
|
|
660
|
+
| `import_from_json` | Import from JSON array | `create` |
|
|
893
661
|
|
|
894
|
-
### Data Migration
|
|
662
|
+
### Data Migration
|
|
895
663
|
|
|
896
664
|
| Tool | Description | Requires |
|
|
897
665
|
|------|-------------|----------|
|
|
898
|
-
| `copy_table_data` | Copy data
|
|
899
|
-
| `move_table_data` | Move data (copy + delete
|
|
900
|
-
| `clone_table` | Clone table structure with optional data | `ddl`
|
|
901
|
-
| `compare_table_structure` | Compare
|
|
902
|
-
| `sync_table_data` |
|
|
666
|
+
| `copy_table_data` | Copy data with optional column mapping | `create` |
|
|
667
|
+
| `move_table_data` | Move data (copy + delete source) | `create`, `delete` |
|
|
668
|
+
| `clone_table` | Clone table structure with optional data | `ddl` |
|
|
669
|
+
| `compare_table_structure` | Compare two table structures | `list` |
|
|
670
|
+
| `sync_table_data` | Sync data between tables | `update` |
|
|
903
671
|
|
|
904
|
-
### Schema Versioning & Migrations
|
|
672
|
+
### Schema Versioning & Migrations
|
|
905
673
|
|
|
906
674
|
| Tool | Description | Requires |
|
|
907
675
|
|------|-------------|----------|
|
|
908
|
-
| `init_migrations_table` | Initialize
|
|
909
|
-
| `create_migration` | Create
|
|
910
|
-
| `apply_migrations` | Apply pending migrations (
|
|
911
|
-
| `rollback_migration` | Rollback
|
|
912
|
-
| `get_migration_status` | Get migration history and status | `list`
|
|
913
|
-
| `get_schema_version` | Get current schema version | `list`
|
|
914
|
-
| `validate_migrations` | Validate migrations for issues | `list`
|
|
915
|
-
| `reset_failed_migration` | Reset failed migration to pending | `ddl`
|
|
916
|
-
| `generate_migration_from_diff` | Generate migration from table
|
|
676
|
+
| `init_migrations_table` | Initialize migrations tracking table | `ddl` |
|
|
677
|
+
| `create_migration` | Create migration with up/down SQL | `ddl` |
|
|
678
|
+
| `apply_migrations` | Apply pending migrations (dry-run support) | `ddl` |
|
|
679
|
+
| `rollback_migration` | Rollback by steps or version | `ddl` |
|
|
680
|
+
| `get_migration_status` | Get migration history and status | `list` |
|
|
681
|
+
| `get_schema_version` | Get current schema version | `list` |
|
|
682
|
+
| `validate_migrations` | Validate migrations for issues | `list` |
|
|
683
|
+
| `reset_failed_migration` | Reset failed migration to pending | `ddl` |
|
|
684
|
+
| `generate_migration_from_diff` | Generate migration from table diff | `ddl` |
|
|
917
685
|
|
|
918
686
|
---
|
|
919
687
|
|
|
920
|
-
##
|
|
921
|
-
|
|
922
|
-
For comprehensive documentation
|
|
923
|
-
|
|
924
|
-
-
|
|
925
|
-
-
|
|
926
|
-
-
|
|
927
|
-
-
|
|
928
|
-
-
|
|
929
|
-
-
|
|
930
|
-
-
|
|
931
|
-
-
|
|
932
|
-
-
|
|
933
|
-
-
|
|
934
|
-
-
|
|
935
|
-
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
688
|
+
## Detailed Documentation
|
|
689
|
+
|
|
690
|
+
For comprehensive documentation, see **[DOCUMENTATIONS.md](DOCUMENTATIONS.md)**:
|
|
691
|
+
|
|
692
|
+
- **DDL Operations** - Create, alter, and drop tables
|
|
693
|
+
- **Data Export Tools** - Export to CSV, JSON, and SQL formats
|
|
694
|
+
- **Data Import Tools** - Import from CSV and JSON sources
|
|
695
|
+
- **Database Backup & Restore** - Full backup/restore with SQL dumps
|
|
696
|
+
- **Data Migration Tools** - Copy, move, clone, compare, and sync data
|
|
697
|
+
- **Schema Versioning** - Version control for database schema changes
|
|
698
|
+
- **Transaction Management** - ACID transactions
|
|
699
|
+
- **Stored Procedures** - Create and execute with IN/OUT/INOUT parameters
|
|
700
|
+
- **Query Logging** - See all SQL queries executed automatically
|
|
701
|
+
- **Security Features** - Built-in security and best practices
|
|
702
|
+
- **Bulk Operations** - High-performance batch processing
|
|
703
|
+
- **Troubleshooting** - Common issues and solutions
|
|
704
|
+
|
|
705
|
+
---
|
|
706
|
+
|
|
707
|
+
## MySQL MCP vs Manual Database Access
|
|
708
|
+
|
|
709
|
+
This MySQL MCP is a **powerful intermediary layer** between AI assistants and MySQL databases.
|
|
710
|
+
|
|
711
|
+
| Comparison Topic | Documentation |
|
|
712
|
+
|------------------|---------------|
|
|
713
|
+
| Data Access & Querying | [docs/comparison/data-access-querying.md](docs/comparison/data-access-querying.md) |
|
|
714
|
+
| Data Analysis | [docs/comparison/data-analysis.md](docs/comparison/data-analysis.md) |
|
|
715
|
+
| Data Validation | [docs/comparison/data-validation.md](docs/comparison/data-validation.md) |
|
|
716
|
+
| Schema Inspection | [docs/comparison/schema-inspection.md](docs/comparison/schema-inspection.md) |
|
|
717
|
+
| Debugging & Diagnostics | [docs/comparison/debugging-diagnostics.md](docs/comparison/debugging-diagnostics.md) |
|
|
718
|
+
| Advanced Operations | [docs/comparison/advanced-operations.md](docs/comparison/advanced-operations.md) |
|
|
719
|
+
| Key Benefits | [docs/comparison/key-benefits.md](docs/comparison/key-benefits.md) |
|
|
720
|
+
| Example Workflows | [docs/comparison/example-workflows.md](docs/comparison/example-workflows.md) |
|
|
721
|
+
| When to Use | [docs/comparison/when-to-use.md](docs/comparison/when-to-use.md) |
|
|
939
722
|
|
|
940
723
|
---
|
|
941
724
|
|
|
942
|
-
##
|
|
725
|
+
## License
|
|
943
726
|
|
|
944
727
|
MIT License - see [LICENSE](LICENSE) file for details.
|
|
945
728
|
|
|
946
729
|
---
|
|
947
730
|
|
|
948
|
-
|
|
731
|
+
<div align="center">
|
|
732
|
+
|
|
733
|
+
**Made with care for the AI development community**
|
|
734
|
+
|
|
735
|
+
*Enabling AI agents to interact with MySQL databases safely and efficiently*
|
|
736
|
+
|
|
737
|
+
[Report Bug](https://github.com/berthojoris/mcp-mysql-server/issues) Β· [Request Feature](https://github.com/berthojoris/mcp-mysql-server/issues) Β· [Documentation](DOCUMENTATIONS.md)
|
|
949
738
|
|
|
950
|
-
|
|
739
|
+
</div>
|