f4ww4z/mcp-mysql-server logo

f4ww4z/mcp-mysql-server

Free

基于 Node.js 的 MySQL 数据库集成,提供安全的数据库操作。

FreeFree tier
Type
Open Source

About f4ww4z/mcp-mysql-server

f4ww4z/mcp-mysql-server is an open-source Model Context Protocol (MCP) server that enables AI models to interact with MySQL databases through a standardized interface. It provides tools for establishing connections, executing SELECT/INSERT/UPDATE/DELETE queries with prepared statement support, listing tables, and describing table structures. The server emphasizes security with prepared statements to prevent SQL injection, secure password handling via environment variables, and automatic connection cleanup. It supports TypeScript and offers easy installation via Smithery or npm.

Key Features

Secure connection handling with automatic cleanup
Prepared statement support for query parameters
Comprehensive error handling and validation
TypeScript support
Automatic connection management
Supports SELECT, INSERT, UPDATE, DELETE queries
List and describe tables
Installable via Smithery or npx

Pros & Cons

Pros
  • Uses prepared statements to prevent SQL injection
  • Supports secure password handling through environment variables
  • Automatic connection cleanup to avoid resource leaks
  • Easy one-line installation via npx or Smithery
  • Open source and free to use
Cons
  • Requires manual setup of database credentials in environment variables or connection URI
  • Limited to MySQL databases only (no PostgreSQL, SQLite, etc.)
  • No built-in GUI or visual query builder

Best For

Enabling AI assistants to query and modify MySQL databasesAutomating database operations through natural language interfacesIntegrating database access into MCP-compatible clients like Claude Desktop and CodexRunning database evals and tests via MCP protocol

FAQ

How do I install @f4ww4z/mcp-mysql-server?
You can install it via Smithery with 'npx -y @smithery/cli install @f4ww4z/mcp-mysql-server --client claude' or manually with 'npx @f4ww4z/mcp-mysql-server'. Configure the MySQL connection using either a connection URI or environment variables (MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE).
What tools does the server provide?
The server provides five tools: connect_db (establish a connection), query (execute SELECT queries), execute (run INSERT/UPDATE/DELETE), list_tables (list all tables), and describe_table (get table structure). All support optional prepared statement parameters.
How does the server handle security?
The server uses prepared statements to prevent SQL injection and supports secure password handling through environment variables rather than hardcoded values. Connections are automatically cleaned up to avoid resource leaks.