@f4ww4z/mcp-mysql-server

@f4ww4z/mcp-mysql-server

Standardized MySQL operations server for Model Context Protocol environments.

130
Stars
27
Forks
130
Watchers
13
Issues
Provides a Model Context Protocol server that allows AI models to interact with MySQL databases through a standardized interface. Supports secure connection, prepared statements, and robust error handling. Enables models to connect, query, execute statements, list tables, and describe schema with simple commands. Designed for seamless integration with tools like Smithery and evaluation frameworks.

Key Features

Standardized MySQL database operations over Model Context Protocol
Secure connection management and credential handling
Support for prepared statements to prevent SQL injection
Commands for connecting, querying, modifying, and describing database tables
Automatic resource and connection cleanup
Comprehensive error reporting and validation
TypeScript support for integration and development
Environment variable configuration options
Easy installation via Smithery CLI
Integration with evaluation tools for seamless testing

Use Cases

Allowing AI models to securely interact with MySQL databases
Automating database queries and operations from intelligent agents
Providing safe and reliable database tooling in model-driven applications
Running evaluations and tests on model-database interactions
Simplifying database schema management for automated workflows
Enabling programmatic data access for custom machine learning pipelines
Replacing manual SQL scripting with standardized commands
Integrating MySQL backend functionality into AI assistant platforms
Supporting developers in rapid prototyping of data-driven ML apps
Facilitating secure credential handling in automated deploys

README

@f4ww4z/mcp-mysql-server

smithery badge

A Model Context Protocol server that provides MySQL database operations. This server enables AI models to interact with MySQL databases through a standardized interface.

Installation

Installing via Smithery

To install MySQL Server for Claude Desktop automatically via Smithery:

bash
npx -y @smithery/cli install @f4ww4z/mcp-mysql-server --client claude

Manual Installation

bash
npx @f4ww4z/mcp-mysql-server

Configuration

The server requires the following environment variables to be set in your MCP settings configuration file:

recommended use

json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@f4ww4z/mcp-mysql-server", "mysql://user:password@localhost:port/database"],
    }
  }
}
json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@f4ww4z/mcp-mysql-server"],
      "env": {
        "MYSQL_HOST": "your_host",
        "MYSQL_USER": "your_user",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Running evals

The evals package loads an mcp client that then runs the index.ts file, so there is no need to rebuild between tests. You can load environment variables by prefixing the npx command. Full documentation can be found here.

bash
OPENAI_API_KEY=your-key  npx mcp-eval src/evals/evals.ts src/index.ts

Available Tools

1. connect_db

Establish connection to MySQL database using provided credentials.

typescript
use_mcp_tool({
  server_name: "mysql",
  tool_name: "connect_db",
  arguments: {
    host: "localhost",
    user: "your_user",
    password: "your_password",
    database: "your_database"
  }
});

2. query

Execute SELECT queries with optional prepared statement parameters.

typescript
use_mcp_tool({
  server_name: "mysql",
  tool_name: "query",
  arguments: {
    sql: "SELECT * FROM users WHERE id = ?",
    params: [1]
  }
});

3. execute

Execute INSERT, UPDATE, or DELETE queries with optional prepared statement parameters.

typescript
use_mcp_tool({
  server_name: "mysql",
  tool_name: "execute",
  arguments: {
    sql: "INSERT INTO users (name, email) VALUES (?, ?)",
    params: ["John Doe", "john@example.com"]
  }
});

4. list_tables

List all tables in the connected database.

typescript
use_mcp_tool({
  server_name: "mysql",
  tool_name: "list_tables",
  arguments: {}
});

5. describe_table

Get the structure of a specific table.

typescript
use_mcp_tool({
  server_name: "mysql",
  tool_name: "describe_table",
  arguments: {
    table: "users"
  }
});

Features

  • Secure connection handling with automatic cleanup
  • Prepared statement support for query parameters
  • Comprehensive error handling and validation
  • TypeScript support
  • Automatic connection management

Security

  • Uses prepared statements to prevent SQL injection
  • Supports secure password handling through environment variables
  • Validates queries before execution
  • Automatically closes connections when done

Error Handling

The server provides detailed error messages for common issues:

  • Connection failures
  • Invalid queries
  • Missing parameters
  • Database errors

Contributing

Contributions are welcome! Please feel free to submit a Pull Request to https://github.com/f4ww4z/mcp-mysql-server

License

MIT

Star History

Star History Chart

Repository Owner

f4ww4z
f4ww4z

User

Repository Details

Language JavaScript
Default Branch main
Size 49 KB
Contributors 6
License MIT License
MCP Verified Nov 12, 2025

Programming Languages

JavaScript
80.28%
TypeScript
16.16%
Dockerfile
3.56%

Tags

Join Our Newsletter

Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.

We respect your privacy. Unsubscribe at any time.

Related MCPs

Discover similar Model Context Protocol servers

  • SkySQL MCP Server

    SkySQL MCP Server

    Serverless MariaDB database management with AI-powered agents via Model Context Protocol.

    SkySQL MCP Server implements the Model Context Protocol to provide a robust interface for launching and managing serverless MariaDB and MySQL database instances. It offers capabilities to interact with AI-powered agents for intelligent database operations, execute SQL queries, and manage credentials and security settings. Integration with tools like MCP CLI, Smithery.ai, and Cursor.sh is supported for interactive usage. Designed for efficiency and scalability, it enables streamlined database workflows with advanced AI assistance.

    • 2
    • MCP
    • skysqlinc/skysql-mcp
  • go-mcp-mysql

    go-mcp-mysql

    Zero-burden Model Context Protocol (MCP) server for MySQL automation.

    go-mcp-mysql is a ready-to-use server that implements the Model Context Protocol (MCP) for seamless interaction and automation with MySQL databases. Written in Go, it enables users to perform CRUD operations and check query plans without requiring a Node.js or Python environment. The server supports both command-line and DSN configurations, includes a read-only mode, and features a set of tools for managing schema and data. It is designed for low-overhead deployment and flexible MySQL automation workflows.

    • 46
    • MCP
    • Zhwt/go-mcp-mysql
  • mcp_mysql_server_pro

    mcp_mysql_server_pro

    Advanced MySQL server tool with Model Context Protocol support and database health analysis.

    mcp_mysql_server_pro enables seamless MySQL database operations and analysis, supporting all Model Context Protocol (MCP) transfer modes including STDIO, SSE, and Streamable HTTP. It provides flexible permission control, advanced anomaly detection, and health status monitoring, with easy extensibility via custom tools. OAuth2.0 authentication is supported, and users can execute multi-statement SQL queries, perform index and lock analysis, and leverage prompt template invocation.

    • 273
    • MCP
    • wenb1n-dev/mysql_mcp_server_pro
  • Multi Database MCP Server

    Multi Database MCP Server

    A unified server for structured, multi-database access via the Model Context Protocol.

    Multi Database MCP Server provides a standardized interface for AI assistants to access and manage multiple databases concurrently through the Model Context Protocol. It supports automatic tool generation for SQL queries, transactions, schema exploration, and performance analysis for each connected database. Built using Clean Architecture, it is fully compatible with OpenAI Agents SDK, enabling seamless integration. The platform simplifies configuration and interaction with MySQL and PostgreSQL databases in a robust, modular environment.

    • 304
    • MCP
    • FreePeak/db-mcp-server
  • Multi-Database MCP Server (by Legion AI)

    Multi-Database MCP Server (by Legion AI)

    Unified multi-database access and AI interaction server with MCP integration.

    Multi-Database MCP Server enables seamless access and querying of diverse databases via a unified API, with native support for the Model Context Protocol (MCP). It supports popular databases such as PostgreSQL, MySQL, SQL Server, and more, and is built for integration with AI assistants and agents. Leveraging the MCP Python SDK, it exposes databases as resources, tools, and prompts for intelligent, context-aware interactions, while delivering zero-configuration schema discovery and secure credential management.

    • 76
    • MCP
    • TheRaLabs/legion-mcp
  • MCP 数据库工具 (MCP Database Utilities)

    MCP 数据库工具 (MCP Database Utilities)

    A secure bridge enabling AI systems safe, read-only access to multiple databases via unified configuration.

    MCP Database Utilities provides a secure, standardized service for AI systems to access and analyze databases like SQLite, MySQL, and PostgreSQL using a unified YAML-based configuration. It enforces strict read-only operations, local processing, and credential protection to ensure data privacy and integrity. The tool is suitable for entities focused on data privacy and minimizes risks by isolating database connections and masking sensitive data. Designed for easy integration, it supports multiple installation options and advanced capabilities such as schema analysis and table browsing.

    • 85
    • MCP
    • donghao1393/mcp-dbutils
  • Didn't find tool you were looking for?

    Be as detailed as possible for better results