Skip to content

Commit b0cc71e

Browse files
Merge pull request #5 from executeautomation/Added-Support-for-MySql-Database
Add MySQL support to MCP Database Server
2 parents 67cb325 + 2d29108 commit b0cc71e

File tree

9 files changed

+367
-5
lines changed

9 files changed

+367
-5
lines changed

docs/docs/connection-reference.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,25 @@ node dist/src/index.js --postgresql --host localhost --database sample_db --user
6868
node dist/src/index.js --postgresql --host dbserver.example.com --database sample_db --user appuser --password Secure123! --port 5433 --ssl true
6969
```
7070

71+
## MySQL Connection Options
72+
73+
| Option | Description | Default | Required |
74+
|--------|-------------|---------|----------|
75+
| `--mysql` | Specifies MySQL mode | - | Yes |
76+
| `--host` | MySQL hostname or IP | - | Yes |
77+
| `--database` | Database name | - | Yes |
78+
| `--user` | MySQL username | - | No |
79+
| `--password` | MySQL password | - | No |
80+
| `--port` | MySQL port | 3306 | No |
81+
| `--ssl` | Use SSL connection (true/false or object) | false | No |
82+
| `--connection-timeout` | Connection timeout in ms | 30000 | No |
83+
84+
### Example
85+
86+
```bash
87+
node dist/src/index.js --mysql --host localhost --database sample_db --port 3306 --user root --password secret
88+
```
89+
7190
## Environment Variables
7291

7392
Instead of specifying sensitive credentials on the command line, you can use environment variables:

docs/docs/release-notes.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,12 @@
5353
- Table management (CREATE, ALTER, DROP)
5454
- Schema introspection
5555
- MCP integration for Claude Desktop
56-
- Node.js-based implementation for cross-platform support
56+
- Node.js-based implementation for cross-platform support
57+
58+
## 1.1.0 (2024-05-30)
59+
60+
### Features
61+
- Added MySQL database support (read/write/query, schema, etc.)
62+
- Support for passing MySQL port via CLI and config
63+
- Improved port validation and debug logging for MySQL
64+
- Updated documentation and examples for MySQL and port usage

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import sqlite3 from "sqlite3";
1414
const server = new Server(
1515
{
1616
name: "executeautomation/database-server",
17-
version: "1.0.0",
17+
version: "1.1.0",
1818
},
1919
{
2020
capabilities: {

package-lock.json

Lines changed: 100 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@executeautomation/database-server",
3-
"version": "1.0.2",
3+
"version": "1.1.0",
44
"description": "MCP server for interacting with SQLite and SQL Server databases by ExecuteAutomation",
55
"license": "MIT",
66
"author": "ExecuteAutomation, Ltd (https://executeautomation.com)",
@@ -25,6 +25,7 @@
2525
"dependencies": {
2626
"@modelcontextprotocol/sdk": "1.9.0",
2727
"mssql": "11.0.1",
28+
"mysql2": "^3.14.1",
2829
"pg": "^8.11.3",
2930
"sqlite3": "5.1.7"
3031
},

readme.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# MCP Database Server
44

5-
This MCP (Model Context Protocol) server provides database access capabilities to Claude, supporting SQLite, SQL Server, and PostgreSQL databases.
5+
This MCP (Model Context Protocol) server provides database access capabilities to Claude, supporting SQLite, SQL Server, PostgreSQL, and MySQL databases.
66

77
## Installation
88

@@ -92,6 +92,25 @@ Optional parameters:
9292
- `--ssl`: Enable SSL connection (true/false)
9393
- `--connection-timeout`: Connection timeout in milliseconds (default: 30000)
9494

95+
### MySQL Database
96+
97+
To use with a MySQL database:
98+
99+
```
100+
node dist/src/index.js --mysql --host <host-name> --database <database-name> --port <port> [--user <username> --password <password>]
101+
```
102+
103+
Required parameters:
104+
- `--host`: MySQL host name or IP address
105+
- `--database`: Name of the database
106+
- `--port`: Port number (default: 3306)
107+
108+
Optional parameters:
109+
- `--user`: Username for MySQL authentication
110+
- `--password`: Password for MySQL authentication
111+
- `--ssl`: Enable SSL connection (true/false or object)
112+
- `--connection-timeout`: Connection timeout in milliseconds (default: 30000)
113+
95114
## Configuring Claude Desktop
96115

97116
### Direct Usage Configuration
@@ -132,6 +151,19 @@ If you installed the package globally, configure Claude Desktop with:
132151
"--user", "your-username",
133152
"--password", "your-password"
134153
]
154+
},
155+
"mysql": {
156+
"command": "npx",
157+
"args": [
158+
"-y",
159+
"@executeautomation/database-server",
160+
"--mysql",
161+
"--host", "your-host-name",
162+
"--database", "your-database-name",
163+
"--port", "3306",
164+
"--user", "your-username",
165+
"--password", "your-password"
166+
]
135167
}
136168
}
137169
}
@@ -172,6 +204,18 @@ For local development, configure Claude Desktop to use your locally built versio
172204
"--user", "your-username",
173205
"--password", "your-password"
174206
]
207+
},
208+
"mysql": {
209+
"command": "node",
210+
"args": [
211+
"/absolute/path/to/mcp-database-server/dist/src/index.js",
212+
"--mysql",
213+
"--host", "your-host-name",
214+
"--database", "your-database-name",
215+
"--port", "3306",
216+
"--user", "your-username",
217+
"--password", "your-password"
218+
]
175219
}
176220
}
177221
}

src/db/adapter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface DbAdapter {
5454
import { SqliteAdapter } from './sqlite-adapter.js';
5555
import { SqlServerAdapter } from './sqlserver-adapter.js';
5656
import { PostgresqlAdapter } from './postgresql-adapter.js';
57+
import { MysqlAdapter } from './mysql-adapter.js';
5758

5859
/**
5960
* Factory function to create the appropriate database adapter
@@ -72,6 +73,8 @@ export function createDbAdapter(type: string, connectionInfo: any): DbAdapter {
7273
case 'postgresql':
7374
case 'postgres':
7475
return new PostgresqlAdapter(connectionInfo);
76+
case 'mysql':
77+
return new MysqlAdapter(connectionInfo);
7578
default:
7679
throw new Error(`Unsupported database type: ${type}`);
7780
}

0 commit comments

Comments
 (0)