Skip to main content
Glama
irwantocrimson

MySQL MCP Server

README.md
# MySQL MCP Server

A Model Context Protocol (MCP) server that provides MySQL database connectivity and tools.

## Installation

```bash
npm install
npm run build
```

## Usage

### Configuration

The server can be configured using either environment variables or command-line arguments. Environment variables take precedence over command-line arguments.

#### Environment Variables

- `MYSQL_HOST`: MySQL host (default: localhost)
- `MYSQL_PORT`: MySQL port (default: 3306)
- `MYSQL_USER`: MySQL user (default: root)
- `MYSQL_PASSWORD`: MySQL password (default: empty)
- `MYSQL_DATABASE`: MySQL database (default: test)

#### 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
crimson-mysql-mcp
```

Specify custom host and database:
```bash
crimson-mysql-mcp --host db.example.com --database myapp
```

Using short flags:
```bash
crimson-mysql-mcp -h 192.168.1.100 -u myuser -P mypass -d production
```

### Claude Desktop Configuration

#### Using environment variables (recommended):

```json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "crimson-mysql-mcp@1.0.2"
      ],
      "env": {
        "MYSQL_HOST": "your-mysql-host",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your-username",
        "MYSQL_PASSWORD": "your-password",
        "MYSQL_DATABASE": "your-database"
      }
    }
  }
}
```

#### For local development:

```json
{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": [
        "/path/to/your/crimson-mysql-mcp/build/index.js"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_USER": "root",
        "MYSQL_DATABASE": "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

TDQS

B3.4/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool has a clear, distinct purpose focused on retrieving table schema information.

Naming Consistency5/5

A single tool inherently has perfect naming consistency, as there are no other tools to compare against. The tool name 'get-schema' follows a clear verb-noun pattern and uses kebab-case consistently (though this is trivial with one tool).

Tool Count2/5

A MySQL server with only one tool is severely under-scoped for its domain. MySQL involves operations like querying, inserting, updating, deleting, managing connections, and handling transactions, so a single schema retrieval tool represents an extreme mismatch with the expected functionality.

Completeness1/5

The tool surface is severely incomplete for a MySQL server. It lacks basic CRUD operations (create, read, update, delete), query execution, connection management, and other essential database functions, making it impossible for agents to perform meaningful database interactions.

Maintenance

ActivityInactive
ResponsivenessNo issues