Skip to main content
Glama
ByteTora

mysql-mcp-server-all

by ByteTora

mysql-mcp-server-all

A read-only MySQL MCP server that speaks stdio, SSE, and Streamable HTTP — one binary, three transports.

Why this project exists

We needed to expose a MySQL database as an MCP server to Dify, whose "MCP (HTTP)" integration form only supports the Streamable HTTP protocol.

We evaluated the existing ecosystem:

Project

Transport

Dify "HTTP" form

benborla/mcp-server-mysql

stdio; remote HTTP mode is stateless & incomplete

dpflucas/mysql-mcp-server

stdio only

designcomputer/mysql_mcp_server

stdio + SSE

mysql-mcp-server-all (this project)

stdio + SSE + Streamable HTTP

This project is a derived / enhanced work of designcomputer/mysql_mcp_server (MIT). It keeps the same familiar toolset and adds the missing transport — so the same server can serve Claude Code / opencode over stdio, Cherry Studio over SSE, and Dify over Streamable HTTP.

Related MCP server: mysql-mcp

Features

  • Three transports via MCP_TRANSPORT: stdio (default) / sse / streamable-http

  • Read-only by design: only SELECT / SHOW / DESCRIBE / EXPLAIN / WITH

  • Single & multi database mode: omit MYSQL_DATABASE to query any schema via db.table

  • Identifier whitelist against SQL injection in schema/sample tools

  • Optional Bearer-token auth for Streamable HTTP (recommended when binding beyond loopback)

  • Works from Dify, Cherry Studio, Claude Code, opencode and any MCP client

Install

Requires Python 3.10+.

# via uv (recommended)
uvx --from mysql-mcp-server-all mysql-mcp-server-all

# or pip
pip install mysql-mcp-server-all

Note: this repository is GitHub-only for now. The PyPI name mysql-mcp-server-all is reserved for future publishing.

Quick start

# stdio (Claude Code / opencode / Cherry Studio local)
MYSQL_HOST=127.0.0.1 MYSQL_USER=root MYSQL_PASSWORD=secret \
  MYSQL_DATABASE=my_db mysql-mcp-server-all

# Streamable HTTP (Dify) with token auth
MYSQL_HOST=127.0.0.1 MYSQL_USER=root MYSQL_PASSWORD=secret \
  MYSQL_DATABASE=my_db MCP_TRANSPORT=streamable-http \
  MCP_HTTP_HOST=127.0.0.1 MCP_HTTP_PORT=8000 MCP_HTTP_TOKEN=my-token \
  mysql-mcp-server-all
# -> http://127.0.0.1:8000/mcp

Environment variables

Variable

Default

Description

MYSQL_HOST

(required)

Database host

MYSQL_PORT

3306

Database port

MYSQL_USER

(required)

Database user

MYSQL_PASSWORD

``

Database password

MYSQL_DATABASE

(none)

Default database. Omit → multi-database mode

MYSQL_CONNECT_TIMEOUT

10

Connection timeout (seconds)

MCP_TRANSPORT

stdio

stdio | sse | streamable-http

MCP_HTTP_HOST

127.0.0.1

Listen host for sse / streamable-http

MCP_HTTP_PORT

8000

Listen port for sse / streamable-http

MCP_HTTP_TOKEN

(none)

Bearer token for streamable-http

Transports

Transport

Endpoint

Clients

stdio

Claude Code, opencode, Cursor

sse

http://host:port/sse

Cherry Studio (SSE), Claude Desktop

streamable-http

http://host:port/mcp

Dify (HTTP), Cherry Studio (HTTP)

Client configuration

MCP type:          HTTP
Endpoint URL:      http://127.0.0.1:8000/mcp
Auth header:       Authorization: Bearer <MCP_HTTP_TOKEN>   (if set)
Dynamic client registration: leave disabled

Dify self-hosted in Docker: use http://host.docker.internal:8000/mcp, bind MCP_HTTP_HOST=0.0.0.0, and add the target to Dify's SSRF proxy allowlist (SSRF_PROXY_ALLOW_PRIVATE_IPS / SSRF_PROXY_ALLOW_PRIVATE_DOMAINS in Dify's docker/.env) — Dify blocks private networks by default.

Cherry Studio

Type:  SSE   → URL http://127.0.0.1:8000/sse
   or  HTTP  → URL http://127.0.0.1:8000/mcp  (streamable-http)

Claude Code / opencode (stdio)

{
  "mcpServers": {
    "mysql": {
      "command": "mysql-mcp-server-all",
      "env": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_USER": "root",
        "MYSQL_PASSWORD": "secret",
        "MYSQL_DATABASE": "my_db"
      }
    }
  }
}

opencode: use "environment" (not "env") in opencode.json.

Tools

Tool

Arguments

Description

execute_sql

query

Run a read-only SQL query (SELECT/SHOW/DESCRIBE/EXPLAIN/WITH). Single statement. Returns JSON rows

get_schema_info

table_name

Column metadata (SHOW FULL COLUMNS). Accepts db.table

get_table_sample

table_name, limit (≤20)

Sample rows from a table. Accepts db.table

Security

  • Read-only enforced in execute_sql — write/DDL queries are rejected

  • Identifier whitelist — only alphanumeric, _, $, and one . separator

  • Bind loopback by default (127.0.0.1)

  • Use a least-privilege MySQL user — never root with full grants

  • Add token auth (MCP_HTTP_TOKEN) whenever you bind 0.0.0.0

  • SSE transport has no built-in auth — keep it behind a loopback or a reverse proxy with auth (nginx / Caddy)

Credits & License

Available Tools

3 tools
execute_sqlA

Execute a read-only SQL query (SELECT / SHOW / DESCRIBE / EXPLAIN / WITH).

Returns rows as JSON. Single statements only.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the safety disclosure burden. It clearly states 'read-only', which is a critical behavioral trait, and also discloses the return format (rows as JSON) and the single-statement limitation. This is strong transparency, though it does not cover potential edge cases like query timeouts or result size limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three concise sentences, each adding essential information: what it does, the return format, and a key constraint. No filler or repetition. It is well-structured and front-loaded with the primary purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one parameter and an output schema present, the description covers the core behavior: allowed query types, read-only nature, return format, and single-statement restriction. It does not explicitly contrast with sibling tools, but the allowed statement list provides sufficient context for an agent to select it appropriately.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must compensate. The description implies the 'query' parameter contains the SQL text and constrains it to the allowed statement types. However, it does not provide examples or elaborate on parameter syntax, leaving some room for interpretation. The parameter name itself is self-explanatory, but the description adds only partial value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool executes SQL queries with a specific set of read-only statement types (SELECT / SHOW / DESCRIBE / EXPLAIN / WITH). This distinguishes it from sibling tools like get_schema_info and get_table_sample, which likely provide metadata and sample data rather than arbitrary SQL.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit allowed statement types and the 'single statements only' constraint, which helps the agent decide when to use this tool. While it does not mention alternatives by name, the listing of allowed query types implies when it is appropriate and excludes mutations and multi-statement queries.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_schema_infoB

Return column metadata (name, type, nullability, key, default) for a table.

Accepts database.table notation for cross-database lookups.

ParametersJSON Schema
NameRequiredDescriptionDefault
table_nameYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behavioral traits. It does state that the tool returns column metadata and accepts database.table notation, which is a useful behavioral detail. However, it does not explicitly confirm the tool is read-only, nor does it explain error behavior for nonexistent tables or other limitations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, with the first sentence delivering the core purpose and the second adding a specific syntax detail. There is no fluff or redundancy; every sentence contributes value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple with one parameter and an existing output schema, so the description need not enumerate return values. It covers the basic purpose and a key syntax detail, but lacks explicit usage guidance to distinguish from sibling tools and does not address error handling or assumptions. This is adequate but minimal for a complete picture.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema only defines table_name as a string with no description, and schema coverage is 0%. The description adds meaningful context by specifying that database.table notation is accepted for cross-database lookups, which goes beyond the bare schema parameter. This compensates well for the lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states that the tool returns column metadata for a table, listing specific attributes (name, type, nullability, key, default). It uses a specific verb ('Return') and identifies the resource ('column metadata' for a table), but does not explicitly differentiate it from sibling tools like execute_sql or get_table_sample.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides a usage tip about database.table notation for cross-database lookups, but it gives no guidance on when to use this tool compared to alternatives. There is no mention of execute_sql or get_table_sample, nor any scenarios that would prefer schema inspection over those siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_table_sampleA

Fetch a representative sample of rows (max 20) from a table.

Accepts database.table notation for cross-database lookups.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo
table_nameYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden of behavioral disclosure. It adds the useful constraint of max 20 rows and cross-database notation, but does not state whether the operation is read-only, how the sample is selected (e.g., random vs first rows), or any error behavior. This is adequate for a simple fetch but leaves gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, with the main purpose front-loaded and no filler. Every phrase adds value, and it remains concise while conveying the essential behavior.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity and the presence of an output schema, the description covers the core functionality. It misses key context such as usage guidance vs siblings, the read-only nature, and semantics of the limit parameter. Completeness is adequate but not thorough.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning to table_name by noting database.table notation, and implies a limit parameter by stating max 20. However, it does not explicitly explain the limit parameter's role or default, so the compensation is partial.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool fetches a representative sample of rows with a max of 20 from a table, distinguishing it from the sibling tools execute_sql and get_schema_info. The verb 'fetch' and resource 'sample from a table' are specific and unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus the siblings. It does not mention that execute_sql is for arbitrary queries or that get_schema_info is for metadata. The only usage hint is the database.table notation, which is a parameter detail, not a when-to-use instruction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 3 tool updatesv0.1.0
    • First observedexecute_sql
    • First observedget_schema_info
    • First observedget_table_sample

TDQS

A3.8/5.0
Disambiguation4/5

The tools are largely distinct: execute_sql runs arbitrary read-only queries, get_schema_info returns column metadata, and get_table_sample fetches sample rows. However, execute_sql can also perform SELECT queries that return sample data, creating some overlap with get_table_sample.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in snake_case: execute_sql, get_schema_info, get_table_sample. This makes the toolset predictable and easy to navigate.

Tool Count4/5

Three tools is a reasonable count for a focused read-only MySQL exploration server. While on the smaller side, each tool serves a clear purpose and the set does not feel overly thin.

Completeness4/5

The domain is well-covered for read-only database exploration: arbitrary SQL queries, schema metadata, and sample rows cover the core needs. Missing functionality like listing all tables can be achieved via execute_sql, so there are no major gaps.

Maintenance

ActivityMaintained
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

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A production-ready MCP server for MySQL database operations, providing secure HTTP endpoints for read-only queries, performance analysis, and server monitoring.
    121
    16
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    A MySQL MCP server for local stdio clients, enabling database queries and management with read-only/write modes, audit logging, and configurable security.
    1,081
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A secure, read-only MySQL database proxy using MCP protocol, enabling SQL queries and table inspections via HTTP.
    18
    1
    MIT
  • F
    license
    A
    quality
    A
    maintenance
    Security-hardened, read-only MySQL MCP server that enables safe, read-only access to MySQL databases for running SELECT queries, exploring schemas, and sampling data via MCP clients.
    9
    -

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

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