MCPcopy
hub / github.com/benborla/mcp-server-mysql

github.com/benborla/mcp-server-mysql @v2.0.9 sqlite

repository ↗ · DeepWiki ↗ · release v2.0.9 ↗
69 symbols 237 edges 27 files 13 documented · 19%
README

MCP Server for MySQL

Trust Score

Sponsor — Bloome

Bloome

Using mcp-server-mysql to let your AI query MySQL? Bloome brings that to your whole team — an AI-agent IM platform where AI agents are members of the chat. Connect your MCP tools and have agents inspect schemas, run queries, and answer data questions for everyone in one thread. Zero local setup, runs in the cloud, on web and mobile.


MCP server that gives Claude and other LLMs access to MySQL — inspect schemas, run queries, and optionally write data, all through the Model Context Protocol.

Key Features

  • Read-only by default — write operations opt-in via env flags
  • Claude Code integration — optimized for Anthropic's Claude Code CLI
  • SSH tunnel support — built-in support for remote databases
  • Multi-DB mode — query across multiple databases without reconnecting
  • Schema-specific permissions — per-database read/write control
  • PII redaction — automatic masking of sensitive data in results
  • Remote mode — HTTP transport with bearer token auth
  • SSL/TLS support — encrypted connections with mTLS option

Requirements

  • Node.js v20+
  • MySQL 5.7+ (8.0+ recommended)
  • MySQL user with appropriate privileges

Quick Install

Claude Code (simplest):

claude mcp add mcp_server_mysql \
  -e MYSQL_HOST="127.0.0.1" \
  -e MYSQL_PORT="3306" \
  -e MYSQL_USER="root" \
  -e MYSQL_PASS="your_password" \
  -e MYSQL_DB="your_database" \
  -- npx @benborla29/mcp-server-mysql

Claude Desktop / other clients:

{
  "mcpServers": {
    "mcp_server_mysql": {
      "command": "npx",
      "args": ["-y", "@benborla29/mcp-server-mysql"],
      "env": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASS": "your_password",
        "MYSQL_DB": "your_database"
      }
    }
  }
}

All write operations are disabled by default. Enable with ALLOW_INSERT_OPERATION=true, ALLOW_UPDATE_OPERATION=true, ALLOW_DELETE_OPERATION=true.

Documentation

Tools & Resources

Tool: mysql_query Execute SQL queries. Read-only by default. Write operations enabled per flag.

Resources: mysql://tables Lists all tables and column metadata for the connected database.

Contributing

PRs welcome at github.com/benborla/mcp-server-mysql.

git clone https://github.com/benborla/mcp-server-mysql.git
pnpm install
pnpm run build
pnpm test

Contributors

License

MIT — see LICENSE for details.

Extension points exported contracts — how you extend this code

SchemaPermissions (Interface)
(no doc)
src/types/index.ts
RedactOptions (Interface)
(no doc)
src/security/redact.ts
MySQLConnectionConfig (Interface)
(no doc)
src/utils/index.ts
PIIColumnReference (Interface)
(no doc)
src/db/utils.ts
MysqlQueryResult (Interface)
(no doc)
tests/e2e/pii-redaction.test.ts
TableRow (Interface)
(no doc)
src/types/index.ts
IntrospectionResult (Interface)
(no doc)
src/db/utils.ts
ColumnRow (Interface)
(no doc)
src/types/index.ts

Core symbols most depended-on inside this repo

log
called by 58
src/utils/index.ts
isIntrospectionQuery
called by 38
src/db/utils.ts
redactPII
called by 31
src/security/redact.ts
isPIIColumn
called by 25
src/security/redact.ts
executeReadOnlyQuery
called by 14
src/db/index.ts
filterIntrospectionRows
called by 13
src/security/redact.ts
readSSLFile
called by 13
src/config/index.ts
executeWriteQuery
called by 12
src/db/index.ts

Shape

Function 58
Interface 8
Class 2
Method 1

Languages

TypeScript100%

Modules by API surface

src/security/redact.ts16 symbols
src/db/utils.ts10 symbols
tests/e2e/server.test.ts6 symbols
src/db/index.ts5 symbols
tests/e2e/pii-redaction.test.ts4 symbols
src/utils/index.ts4 symbols
src/db/permissions.ts4 symbols
tests/unit/query.test.ts3 symbols
src/types/index.ts3 symbols
src/config/index.ts3 symbols
index.ts3 symbols
tests/integration/remote-mcp-parallel.test.ts2 symbols

Dependencies from manifests, versioned

@ai-sdk/openai1.3.22 · 1×
@modelcontextprotocol/sdk1.15.1 · 1×
@types/express5.0.3 · 1×
@types/jest29.5.14 · 1×
@types/node20.17.50 · 1×
@typescript-eslint/eslint-plugin8.35.0 · 1×
@typescript-eslint/parser8.35.0 · 1×
dotenv16.5.0 · 1×
eslint9.27.0 · 1×
express5.1.0 · 1×
markdownlint-cli0.45.0 · 1×
mcp-evals1.0.18 · 1×

Datastores touched

(mysql)Database · 1 repos

For agents

$ claude mcp add mcp-server-mysql \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact