Skip to main content

mcp-mysql

A small, dependency-light Model Context Protocol server that gives MCP clients (Trae, Cursor, Claude Desktop, ...) read-only access to one or more MySQL databases through a single db_profiles.json file.

  • Multiple connections in one server (production / test / reporting ...), each with its own credentials
  • Per-database notes and usage rules returned to the model before it writes SQL
  • Two tools only: list_connections and execute_sql
  • Any SQL client can be used, but the server is designed for read-only accounts

Install

pipx install jj-mcp-mysql
# or
pip install jj-mcp-mysql

The distribution is named jj-mcp-mysql; the installed command is mcp-mysql.

Configure

Copy the sample profile file and fill in your connections:

cp db_profiles.sample db_profiles.json
{
  "default_connection": "my_conn",
  "connections": {
    "my_conn": {
      "description": "Test database",
      "usage": "Read-only account. Only SELECT is allowed.",
      "host": "127.0.0.1",
      "port": 3306,
      "user": "readonly",
      "password": "change-me",
      "charset": "utf8mb4",
      "databases": ["your_database"],
      "default_database": "your_database"
    }
  }
}

Keys starting with _ are treated as samples and are skipped.

Run

export MCP_DB_PROFILES_FILE=/absolute/path/to/db_profiles.json
mcp-mysql

If MCP_DB_PROFILES_FILE is not set, the server looks for db_profiles.json in the current working directory.

MCP client configuration

{
  "mcpServers": {
    "mcp-mysql": {
      "command": "mcp-mysql",
      "env": {
        "MCP_DB_PROFILES_FILE": "/absolute/path/to/db_profiles.json"
      }
    }
  }
}

Tools

Tool Purpose
list_connections List connections, their usage notes and available databases
execute_sql Run SQL on a chosen connection and database; omit connection / database to use the defaults

The server injects usage notes into the MCP instructions, so the model knows which connection and database to pick. SELECT statements are expected to carry an explicit LIMIT (100 rows by default in prompts).

Security notes

  • Use a read-only MySQL account; the server does not block writes on its own.
  • db_profiles.json contains credentials and is git-ignored. Never commit it.
  • Prefer environment variables or a file outside the repository for production credentials.

Development

python -m venv .venv
.venv/Scripts/pip install -e .
python -m mcp_mysql

Release

python -m build
twine upload dist/*
mcp-publisher validate
mcp-publisher publish

mcp-publisher publishes server.json to the official MCP Registry. Update name, repository and version fields before publishing.

Metadata

Release files for jj-mcp-mysql 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jj-mcp-mysql 0.1.0
File Size Uploaded Provenance Actions
jj_mcp_mysql-0.1.0.tar.gz 7.4 kB Without provenance Details for jj_mcp_mysql-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jj-mcp-mysql 0.1.0
File Interpreter ABI Platform Actions
jj_mcp_mysql-0.1.0-py3-none-any.whl Python 3 none any Details for jj_mcp_mysql-0.1.0-py3-none-any.whl

Total release size: 15.2 kB

Release files / jj_mcp_mysql-0.1.0.tar.gz

Download URL jj_mcp_mysql-0.1.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8f543605f5d1354951829de053bf3177b518d513dbaf58be2ab608df4c84139e
BLAKE2b-256 checksum
How to use checksums
fba56727b89d118184b0bc3b0939c34e2227fec4f759244ffdb2190b0ef23a58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Release files / jj_mcp_mysql-0.1.0-py3-none-any.whl

Download URL jj_mcp_mysql-0.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bdea4d8ae1b76a33153d63dc7e8edb631d671e0d86f043e71fdb174922794a41
BLAKE2b-256 checksum
How to use checksums
244cb84f735fd5f4a3fbaa7aa761e59f91122e003158dd179e4de1c9028e14b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Security for jj-mcp-mysql 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page