Skip to main content
Glama
rlembo06

mysql-mcp

by rlembo06

mysql-mcp

一个轻量级的 MCP 服务器,提供对 MySQL 数据库的安全、只读访问。

功能特性

  • 多数据库 — 连接到多个 MySQL 实例,并可随时切换

  • 只读 — 阻止写入操作(INSERTUPDATEDELETEDROP 等)

  • 延迟连接 — 连接池在首次使用时创建,而非启动时创建

  • 原生 MCP — 基于 @modelcontextprotocol/sdk 构建,适用于任何 MCP 客户端

设置

  1. 创建一个包含数据库连接的 JSON 配置文件:

{
  "my-db": {
    "host": "db.example.com",
    "port": 3306,
    "user": "readonly",
    "password": "secret",
    "database": "mydb",
    "environment": "production",
    "ssl": false
  }
}
  1. 设置指向该文件的 MYSQL_DATABASES_CONFIG 环境变量。

  2. 运行服务器:

npx tsx index.ts

工具

工具

描述

list_connections

列出所有已配置的数据库及当前活跃的数据库

use_connection

切换当前活跃的数据库连接

query

执行只读 SQL 查询

MCP 客户端配置

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["tsx", "/path/to/mysql-mcp/index.ts"],
      "env": {
        "MYSQL_DATABASES_CONFIG": "/path/to/databases.json"
      }
    }
  }
}

许可证

MIT

-
security - not tested
A
license - permissive license
-
quality - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rlembo06/mysql-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server