Skip to main content
Glama
yuki777

MySQL MCP Server

by yuki777

MySQL MCP Server

The MySQL Model Context Protocol (MCP) Server is a tool that allows you to connect to a local MySQL database and allow large language models (LLMs) to execute SQL queries against it.

Requirements

  • Node.js : 20.0.0 or later

  • MySQL : MySQL or MariaDB server version 5.7 or later

Related MCP server: MCP MySQL Server

function

  • Run MySQL queries : Run SQL queries directly from LLM

  • Obtaining database information : List of databases, list of tables, confirm table structure

  • MCP Compliant : Supports Model Context Protocol and can be integrated with LLM

  • stdio communication : communicate with LLM using standard input/output, no port binding

  • Save connection information : Save database connection information locally and reuse it

Installation and Usage

Temporary execution in NPX

 npx -y https://github.com/yuki777/mysql-mcp-server --host 127.0.0.1 --port 13306 --user root

option

option

explanation

Default value

-h, --host <host>

MySQL Host

localhost

-p, --port <port>

MySQL Port

13306

-u, --user <user>

MySQL User

root

--password <password>

MySQL Password

(empty string)

-d, --database <database>

Default Database

(option)

-c, --config <path>

Configuration File Path

(option)

--auto-connect

Automatically connect to database at server startup

false

--server-port <port>

MCP server port (not used in stdio mode)

3000

--server-host <host>

MCP server host (not used in stdio mode)

localhost

--query-timeout <ms>

Query Timeout (ms)

30000

--max-results <count>

Maximum Result Rows

1000

--debug

Debug Mode

false

Save and reuse connection information

MySQL MCP Server locally saves information about databases that it has successfully connected to, so that it can automatically reuse the connection information the next time it starts. Saved connection information is stored in .mysql-mcp-connections.json file in the user's home directory.

Connection information includes:

  • Hostname

  • Port number

  • Username

  • password

  • Database name (if set)

Using configuration files

You can also configure the connection information using a configuration file (in JSON format):

{
  "server": {
    "port": 3000,
    "host": "localhost"
  },
  "mysql": {
    "host": "localhost",
    "port": 13306,
    "user": "root",
    "password": "yourpassword",
    "database": "mydb"
  },
  "debug": false,
  "queryTimeout": 30000,
  "maxResultSize": 1000
}

If you use a configuration file:

npx -y https://github.com/yuki777/mysql-mcp-server -c ./mysql-mcp-config.json

Communication method

MySQL MCP Server operates in "stdio" mode according to the MCP (Model Context Protocol), which means it does not bind to a specific port but communicates via standard input and output. This has the following advantages:

  1. Avoid port conflicts : No specific ports are used, so no port conflict issues occur

  2. Improved security : No network communication is used, reducing the risk of network-level attacks

  3. Simple Inter-Process Communication : Simplified communication with LLM

Important points to note

  • In stdio mode, messages are sent in JSON format.

  • You must send one JSON message per line

  • Error information and connection logs are output to standard error (stderr).

MCP Tools Provided

Database Connection Management

Tool Name

explanation

Required parameters

connect_database

Connect to the database

host, port, user

disconnect_database

Disconnects the current database connection

none

get_connection_status

Gets the status of the database connection

none

SQL Query Operations

Tool Name

explanation

Required parameters

execute_query

Run a MySQL query

query: SQL statement

get_databases

Get a list of available databases

none

get_tables

Gets a list of tables in a specified database.

database (optional)

describe_table

Gets the structure of the specified table.

table

Connection Management Function

MySQL MCP Server allows you to separate server startup and database connections. This approach provides the following benefits:

  1. Start without connection information : The server can be started without database connection information.

  2. Multiple database connections : You can switch connections to different databases after the server is started.

  3. Simple installation : just run npx -y https://github.com/yuki777/mysql-mcp-server

How to use Connection Management

  1. Start the server without auto-connect :

    npx -y https://github.com/yuki777/mysql-mcp-server
  2. Connect to the database using the connection tool :

    {
      "type": "tool_call",
      "request_id": "req_1",
      "tool": "connect_database",
      "arguments": {
        "host": "localhost",
        "port": 3306,
        "user": "root",
        "password": "your_password",
        "database": "your_db"
      }
    }
  3. Check your connection status :

    {
      "type": "tool_call",
      "request_id": "req_2",
      "tool": "get_connection_status",
      "arguments": {}
    }
  4. Loss of connection :

    {
      "type": "tool_call",
      "request_id": "req_3",
      "tool": "disconnect_database",
      "arguments": {}
    }

Test script

The repository contains a test script called test-connection-management.js , which you can use to test the connection management functionality:

node test-connection-management.js

Developer Information

Setting up your development environment

# リポジトリのクローン
git clone [repository-url]
cd mysql-mcp-server

# 依存関係のインストール
npm install

# 開発モードでの実行
npm run dev

Build

npm run build

license

ISC

contribution

Bug reports, feature requests and pull requests are welcome.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Connectors

  • The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.

  • The BigQuery remote MCP server is a fully managed service that uses the Model Context Protocol to connect AI applications and LLMs to BigQuery data sources. It provides secure, standardized tools for AI agents to list datasets and tables, retrieve schemas, generate and execute SQL queries through natural language, and analyze data—enabling direct access to enterprise analytics data without requiring manual SQL coding.

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…

  • The Remote MCP server acts as a standardized bridge between LLM applications (like Claude, ChatGPT, and Cursor) and external services, enabling AI agents to access external tools and resources. Its primary capability is providing a centralized search tool to discover other MCP servers and their respective tools. Unlike local implementations, it runs remotely with OAuth authentication and permission controls for security.

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    A Model Context Protocol server that enables AI models to interact with MySQL databases, providing tools for querying, executing statements, listing tables, and describing table structures.
    5
    342
    MIT
  • F
    license
    B
    quality
    D
    maintenance
    A Model Context Protocol server that enables AI models to interact with MySQL databases through a standardized interface, providing tools for querying, executing commands, and managing database schemas.
    7
  • F
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that enables AI models to interact with MySQL databases through natural language, supporting SQL queries, table creation, and schema exploration.
    3
  • A
    license
    B
    quality
    D
    maintenance
    A server based on Model Context Protocol that enables AI models to interact with MySQL databases through a standardized interface, supporting features like query execution, table listing, and automated connection management.
    4
    12
    10
    MIT

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/yuki777/mysql-mcp-server'

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