open-index/open-npm huggingface dataset:
npm package: @jarhed/server-mysql
Description: MCP server for interacting with MySQL databases
Author: Anthropic, PBC
Latest version: 0.6.2

# MySQL

A Model Context Protocol server that provides read-only access to MySQL databases. This server enables LLMs to inspect database schemas and execute read-only queries.

## Installation

```bash
npm install -g @modelcontextprotocol/server-mysql
```

## Usage

The server can be started by running the following command:

```bash
mcp-server-mysql <database-url>
```

The database URL should be a valid MySQL connection URL, such as:

```
mysql://user:password@host:port/database
```

## Supported Resources

- **Table Schemas** (`mysql://<host>/<table>/schema`)
  - Lists column names and data types for the specified table.

## Supported Tools

- **query**: Run a read-only SQL query against the connected MySQL database.

## Configuration Examples

### Using with curl

```bash
# Start the server
mcp-server-mysql "mysql://user:password@localhost:3306/mydb" > server.log 2>&1 &
SERVER_PID=$!

# List available tables
curl -s http://localhost:3000/list-resources | jq

# View schema for a table
curl -s -X POST http://localhost:3000/read-resource \
  -H "Content-Type: application/json" \
  -d '{"uri":"mysql://localhost/users/schema"}' | jq

# Execute a read-only query
curl -s -X POST http://localhost:3000/call-tool \
  -H "Content-Type: application/json" \
  -d '{"name":"query","arguments":{"sql":"SELECT * FROM users LIMIT 5"}}' | jq

# Kill the server
kill $SERVER_PID
```

### Using with Claude

```
"mysql": {
  "type": "docker",
  "args": [
    "-y",
    "mcp/mysql",
    "mysql://host.docker.internal:3306/mydb"
  ]
}
```

Or locally:

```
"mysql": {
  "type": "npm",
  "args": [
    "-y",
    "@modelcontextprotocol/server-mysql",
    "mysql://localhost:3306/mydb"
  ]
}
```

## Building from Source

```bash
# Clone the repository
git clone https://github.com/modelcontextprotocol/servers.git
cd servers

# Install dependencies
npm install

# Build the server
npm run build

# Build the Docker image
docker build -t mcp/mysql -f src/mysql/Dockerfile .
```