Skip to main content
Glama
mysql-mcp-ddz

mysql-mcp-ddz

by fanzhenddz
README.md
# mysql-mcp-ddz

MySQL MCP 服务器 - 用于 MySQL 数据库操作的 Model Context Protocol 服务器。

## 安装

```bash
npm install mysql-mcp-ddz
```

或直接使用 npx:

```bash
npx -y mysql-mcp-ddz
```

## 配置

添加到 MCP 设置(例如 Claude Desktop 配置):

```json
{
  "mcpServers": {
    "mysql-mcp-ddz": {
      "command": "npx",
      "args": ["-y", "mysql-mcp-ddz"],
      "env": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DB": "your_database"
      }
    }
  }
}
```

## 环境变量

| 变量 | 描述 | 默认值 |
|------|------|--------|
| `MYSQL_HOST` | 数据库主机 | `127.0.0.1` |
| `MYSQL_PORT` | 数据库端口 | `3306` |
| `MYSQL_USER` | 数据库用户 | `root` |
| `MYSQL_PASSWORD` | 数据库密码 | (空) |
| `MYSQL_DB` | 数据库名称 | (必填) |

## 可用工具

### `connect_db`
连接到 MySQL 数据库并验证连接。

### `query`
执行 SELECT 查询。
```json
{
  "sql": "SELECT * FROM users WHERE id = ?",
  "params": [1]
}
```

### `execute`
执行 INSERT、UPDATE 或 DELETE 查询。
```json
{
  "sql": "INSERT INTO users (name, email) VALUES (?, ?)",
  "params": ["John", "john@example.com"]
}
```

### `list_tables`
列出数据库中的所有表。

### `describe_table`
获取表结构。
```json
{
  "table": "users"
}
```

TDQS

B3.2/5.0

Scored across 5 tools

Disambiguation4/5

query and execute are the closest pair, but their descriptions clearly split read (SELECT) from write (INSERT/UPDATE/DELETE) operations, making selection straightforward. list_tables and describe_table both introspect schema but target different granularity (table inventory vs column structure). connect_db is distinct as a session setup step.

Naming Consistency3/5

Three tools follow a verb_noun pattern (connect_db, list_tables, describe_table) while query and execute are bare verbs with no object, creating a mixed convention. The names are still readable and guessable, but not a predictable pattern throughout.

Tool Count4/5

Five tools is a tight, well-scoped surface for a database access server — each tool maps to a real distinct operation with no filler. It is on the lean side (no schema/DDL or transaction tooling), but nothing is redundant.

Completeness3/5

Core DML is covered (SELECT via query, writes via execute) plus basic schema discovery, but there are notable gaps: no DDL (create/alter/drop table), no index or SHOW/EXPLAIN inspection, no transaction control, and no explicit disconnect/connection management. Agents needing schema changes or multi-statement transactions will hit dead ends.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues