MySQL MCP Server

Integrations

  • Uses .ENV files for configuration of MySQL connection details including host, username, password, and database name

  • Provides direct access to MySQL databases, allowing execution of SQL queries, table management, and storage of notes with title and content in a MySQL database

  • Runs on Node.js runtime (version 18 or higher) as the execution environment for the MCP server

MySQL MCP 服务器

功能强大的 MCP 服务器,可直接访问 MySQL 数据库。该服务器使 AI 代理能够通过简单的界面与 MySQL 数据库交互、执行 SQL 查询并管理数据库内容。

特征

资源

  • 通过note:///{id} URI 访问存储在数据库中的笔记
  • 每个笔记都有标题和内容
  • 用于简单内容访问的纯文本 MIME 类型

工具

  • create_note - 在数据库中创建新的文本注释
    • 将标题和内容作为必需参数
    • 将注释存储在 MySQL 数据库中
  • list_tables - 列出所连接数据库中的所有表
  • count_tables获取数据库中表的总数
  • search_tables - 使用 LIKE 模式搜索表
  • describe_table - 获取特定表的结构
  • execute_sql自定义 SQL 查询

先决条件

  • Node.js 18 或更高版本
  • MySQL 服务器已安装并正在运行
  • 具有适当权限的数据库

设置

  1. 克隆此存储库:
    git clone git@github.com:LeonMelamud/mysql-mcp.git cd mysql-mcp
  2. 安装依赖项:
    npm install
  3. 使用您的 MySQL 连接详细信息在根目录中创建一个.env文件:
    MYSQL_HOST=localhost MYSQL_USER=your_username MYSQL_PASSWORD=your_password MYSQL_DATABASE=your_database
  4. 构建服务器:
    npm run build

安装

对于克劳德桌面

将服务器配置添加到您的 Claude Desktop 配置文件:

在 MacOS 上: ~/Library/Application Support/Claude/claude_desktop_config.json在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json

{ "mcpServers": { "mysql": { "command": "node", "args": ["/path/to/mysql-server/build/index.js"], "env": { "MYSQL_HOST": "localhost", "MYSQL_USER": "your_username", "MYSQL_PASSWORD": "your_password", "MYSQL_DATABASE": "your_database" } } } }

对于克莱恩

将服务器配置添加到您的 Cline MCP 设置文件:

在 MacOS 上: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json在 Windows 上: %APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json

{ "mcpServers": { "mysql": { "command": "node", "args": ["/path/to/mysql-server/build/index.js"], "env": { "MYSQL_HOST": "localhost", "MYSQL_USER": "your_username", "MYSQL_PASSWORD": "your_password", "MYSQL_DATABASE": "your_database" }, "disabled": false, "autoApprove": [] } } }

使用示例

安装完成后,您可以在与 Claude 的对话中使用 MySQL MCP 服务器:

列出数据库中的所有表

Please list all the tables in my MySQL database.

执行 SQL 查询

Run this SQL query: SELECT * FROM users LIMIT 5

创建笔记

Create a note titled "Meeting Notes" with the content "Discussed project timeline and assigned tasks."

发展

对于使用自动重建的开发:

npm run watch

调试

使用 MCP Inspector 调试服务器:

npm run inspector

检查器将提供一个 URL 来访问浏览器中的调试工具。

执照

麻省理工学院

-
security - not tested
F
license - not found
-
quality - not tested

一个强大的服务器,使 AI 代理能够与 MySQL 数据库交互、执行 SQL 查询并通过简单的界面管理数据库内容。

  1. Features
    1. Resources
    2. Tools
  2. Prerequisites
    1. Setup
      1. Installation
        1. For Claude Desktop
        2. For Cline
      2. Usage Examples
        1. List all tables in the database
        2. Execute a SQL query
        3. Create a note
      3. Development
        1. Debugging
      4. License
        ID: cp6c716buh