mcp-server-mysql

tonguyenducmanh/mcp-server-mysql

3.2

If you are the rightful owner of mcp-server-mysql and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This is a custom MCP server designed for interacting with MySQL databases using the Model Context Protocol (MCP).

Tools
  1. execute_query

    Executes an SQL query with optional parameters and a customizable connection string.

  2. list_tables

    Retrieves a list of tables from a specified database.

MySQL Custom MCP Server

MCP server tùy chỉnh để thao tác với MySQL database từ Cline AI. Server này cho phép thực hiện các truy vấn SQL và tương tác với MySQL databases thông qua giao thức Model Context Protocol (MCP).

Tính năng

  • Thực thi các câu truy vấn SQL
  • Lấy danh sách các bảng trong database
  • Hỗ trợ connection string tùy chỉnh

Cài đặt

  1. Clone repository
  2. Cài đặt dependencies:
npm install
  1. Build project:
npm run build

Sử dụng

Chạy server

npm start

Hoặc chạy trong chế độ development:

npm run dev

Cấu hình

Bạn có thể cấu hình kết nối MySQL thông qua biến môi trường:

  • MYSQL_HOST: Hostname của MySQL server (mặc định: "localhost")
  • MYSQL_PORT: Port của MySQL server (mặc định: 3306)
  • MYSQL_DB: Database mặc định (mặc định: "mysql")
  • MYSQL_USER: Username (mặc định: "root")
  • MYSQL_PASSWORD: Password (mặc định: "")

Hoặc cấu hình trong file cline_mcp_settings.json.

Tools

execute_query

Thực thi một câu truy vấn SQL.

Tham số:

  • query: Câu lệnh SQL cần thực thi (bắt buộc)
  • params: Mảng các tham số cho câu query (tùy chọn)
  • connectionString: Connection string tùy chỉnh (tùy chọn)

Ví dụ:

{
  "query": "SELECT * FROM users WHERE id = ?",
  "params": ["1"]
}

list_tables

Lấy danh sách các bảng trong database.

Tham số:

  • database: Tên database (tùy chọn, mặc định lấy từ connection)
  • connectionString: Connection string tùy chỉnh (tùy chọn)

Ví dụ:

{
  "database": "my_database"
}

Connection String

Server hỗ trợ connection string với định dạng:

Host=localhost;Port=3306;Database=my_database;User=root;Password=your_password

Các key hỗ trợ:

  • Host, Server, DataSource: Địa chỉ máy chủ
  • Port: Cổng kết nối
  • Database, DB, Initial Catalog: Tên database
  • User, Username, UID: Tên đăng nhập
  • Password, PWD: Mật khẩu

Lưu ý

MCP server này cần được chạy như một process riêng biệt và Cline AI sẽ giao tiếp với nó thông qua giao thức MCP. Thông tin cấu hình cần được đặt trong file cline_mcp_settings.json của Cline.