# MySQL MCP Server
A Model Context Protocol (MCP) server that provides MySQL database connectivity and tools.
## Installation
```bash
npm install
npm run build
```
## Usage
### Command-Line Arguments
The server accepts the following command-line arguments:
- `-h, --host`: MySQL host (default: localhost)
- `-p, --port`: MySQL port (default: 3306)
- `-u, --user`: MySQL user (default: root)
- `-P, --password`: MySQL password (default: empty)
- `-d, --database`: MySQL database (default: test)
### Examples
Basic usage with default settings:
```bash
mysql-mcp
```
Specify custom host and database:
```bash
mysql-mcp --host db.example.com --database myapp
```
Using short flags:
```bash
mysql-mcp -h 192.168.1.100 -u myuser -P mypass -d production
```
### Claude Desktop Configuration
#### Using npx (recommended after publishing to npm):
```json
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": [
"-y",
"mysql-mcp@1.0.0",
"--host",
"your-mysql-host",
"--port",
"3306",
"--user",
"your-username",
"--password",
"your-password",
"--database",
"your-database"
]
}
}
}
```
Or using short flags:
```json
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": [
"-y",
"mysql-mcp@1.0.0",
"-h",
"your-mysql-host",
"-p",
"3306",
"-u",
"your-username",
"-P",
"your-password",
"-d",
"your-database"
]
}
}
}
```
#### For local development:
```json
{
"mcpServers": {
"mysql": {
"command": "node",
"args": [
"/path/to/your/mysql-mcp/build/index.js",
"-h",
"localhost",
"-u",
"root",
"-d",
"test"
]
}
}
}
```
### Available Tools
- **get-schema**: Get the schema/structure of a MySQL table
- Parameters: `schemaName` (string) - The name of the table to describe
## Development
```bash
# Install dependencies
npm install
# Run in development mode
npm run server:dev
# Build the project
npm run build
# Watch and rebuild on changes
npm run server:build:watch
# Run with MCP Inspector (for debugging)
npm run server:inspect
```
## Publishing to npm
To make this package available via npx:
1. Update the package.json with your npm account details
2. Run:
```bash
npm publish
```
## License
ISC