Skip to content

Add MySQL support to MCP Database Server #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/docs/connection-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ node dist/src/index.js --postgresql --host localhost --database sample_db --user
node dist/src/index.js --postgresql --host dbserver.example.com --database sample_db --user appuser --password Secure123! --port 5433 --ssl true
```

## MySQL Connection Options

| Option | Description | Default | Required |
|--------|-------------|---------|----------|
| `--mysql` | Specifies MySQL mode | - | Yes |
| `--host` | MySQL hostname or IP | - | Yes |
| `--database` | Database name | - | Yes |
| `--user` | MySQL username | - | No |
| `--password` | MySQL password | - | No |
| `--port` | MySQL port | 3306 | No |
| `--ssl` | Use SSL connection (true/false or object) | false | No |
| `--connection-timeout` | Connection timeout in ms | 30000 | No |

### Example

```bash
node dist/src/index.js --mysql --host localhost --database sample_db --port 3306 --user root --password secret
```

## Environment Variables

Instead of specifying sensitive credentials on the command line, you can use environment variables:
Expand Down
10 changes: 9 additions & 1 deletion docs/docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,12 @@
- Table management (CREATE, ALTER, DROP)
- Schema introspection
- MCP integration for Claude Desktop
- Node.js-based implementation for cross-platform support
- Node.js-based implementation for cross-platform support

## 1.1.0 (2024-05-30)

### Features
- Added MySQL database support (read/write/query, schema, etc.)
- Support for passing MySQL port via CLI and config
- Improved port validation and debug logging for MySQL
- Updated documentation and examples for MySQL and port usage
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import sqlite3 from "sqlite3";
const server = new Server(
{
name: "executeautomation/database-server",
version: "1.0.0",
version: "1.1.0",
},
{
capabilities: {
Expand Down
100 changes: 100 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@executeautomation/database-server",
"version": "1.0.2",
"version": "1.1.0",
"description": "MCP server for interacting with SQLite and SQL Server databases by ExecuteAutomation",
"license": "MIT",
"author": "ExecuteAutomation, Ltd (https://executeautomation.com)",
Expand All @@ -25,6 +25,7 @@
"dependencies": {
"@modelcontextprotocol/sdk": "1.9.0",
"mssql": "11.0.1",
"mysql2": "^3.14.1",
"pg": "^8.11.3",
"sqlite3": "5.1.7"
},
Expand Down
46 changes: 45 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# MCP Database Server

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

## Installation

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

### MySQL Database

To use with a MySQL database:

```
node dist/src/index.js --mysql --host <host-name> --database <database-name> --port <port> [--user <username> --password <password>]
```

Required parameters:
- `--host`: MySQL host name or IP address
- `--database`: Name of the database
- `--port`: Port number (default: 3306)

Optional parameters:
- `--user`: Username for MySQL authentication
- `--password`: Password for MySQL authentication
- `--ssl`: Enable SSL connection (true/false or object)
- `--connection-timeout`: Connection timeout in milliseconds (default: 30000)

## Configuring Claude Desktop

### Direct Usage Configuration
Expand Down Expand Up @@ -132,6 +151,19 @@ If you installed the package globally, configure Claude Desktop with:
"--user", "your-username",
"--password", "your-password"
]
},
"mysql": {
"command": "npx",
"args": [
"-y",
"@executeautomation/database-server",
"--mysql",
"--host", "your-host-name",
"--database", "your-database-name",
"--port", "3306",
"--user", "your-username",
"--password", "your-password"
]
}
}
}
Expand Down Expand Up @@ -172,6 +204,18 @@ For local development, configure Claude Desktop to use your locally built versio
"--user", "your-username",
"--password", "your-password"
]
},
"mysql": {
"command": "node",
"args": [
"/absolute/path/to/mcp-database-server/dist/src/index.js",
"--mysql",
"--host", "your-host-name",
"--database", "your-database-name",
"--port", "3306",
"--user", "your-username",
"--password", "your-password"
]
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/db/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface DbAdapter {
import { SqliteAdapter } from './sqlite-adapter.js';
import { SqlServerAdapter } from './sqlserver-adapter.js';
import { PostgresqlAdapter } from './postgresql-adapter.js';
import { MysqlAdapter } from './mysql-adapter.js';

/**
* Factory function to create the appropriate database adapter
Expand All @@ -72,6 +73,8 @@ export function createDbAdapter(type: string, connectionInfo: any): DbAdapter {
case 'postgresql':
case 'postgres':
return new PostgresqlAdapter(connectionInfo);
case 'mysql':
return new MysqlAdapter(connectionInfo);
default:
throw new Error(`Unsupported database type: ${type}`);
}
Expand Down
Loading
Loading