designcomputer/mysql_mcp_server

View on GitHub ↗

A Model Context Protocol (MCP) server that enables secure interaction with MySQL databases

1,360 ★257 forksPythonUpdated 1mo ago

What you need to know

MCP server for secure, structured interaction with MySQL databases — explore schema, sample table data, and execute SQL with error handling, over STDIO or SSE/Streamable HTTP. Supports multi-database mode, SSH tunneling, and SSL/TLS.

Install

pip install mysql-mcp-server
Smithery: npx -y @smithery/cli install designcomputer/mysql-mcp-server --client claude
Claude Code CLI: claude mcp add --transport stdio designcomputer-mysql_mcp_server uvx mysql_mcp_server
Hosted option via Fronteir AI or local via Smithery

Usage

  • •Set env vars MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, and optionally MYSQL_PORT, MYSQL_DATABASE (omit DATABASE for multi-database mode); a .env file is auto-loaded from the process working directory
  • •Tools: execute_sql (SELECT/SHOW/DESCRIBE/DML), get_schema_info (columns/types/nullability/defaults/comments), get_table_sample (max limit 20)
  • •Prompts: explore_database (systematic DB tour) and analyze_table (schema + sample + suggested queries) — available as slash commands in Claude Code
  • •For SSE transport set MCP_TRANSPORT=sse, MCP_SSE_HOST, PORT

Key features

  • ✓Multi-database mode when MYSQL_DATABASE is unset — list_resources returns all user DBs; cross-database queries via database.table notation
  • ✓SSE/HTTP transport (MCP_TRANSPORT=sse), SSH tunneling (MYSQL_SSH_*), SSL modes (DISABLED/REQUIRED/VERIFY_CA/VERIFY_IDENTITY)
  • ✓Two guided MCP prompts: explore_database and analyze_table
  • ✓Security: strict identifier whitelist against SQL injection, passwords/SSH keys masked in logs, destructive hint on DML operations
  • ✓Comprehensive schema info and table data sampling without large result sets

Caveats

  • ⚠Only single SQL statements are supported — multi-statement queries (e.g. 'USE db; SELECT ...') are not
  • ⚠SSE transport has no built-in authentication and binds to 0.0.0.0 by default — put it behind an authenticating reverse proxy (nginx/Caddy/Traefik) if exposed beyond localhost; DNS rebinding noted for HTTP mode
  • ⚠Claude Code / Claude Desktop launch from their own working directory, so the project's .env will not be found — put MYSQL_* values in the env block of the MCP config
  • ⚠Not intended to be run standalone; debug with the MCP Inspector instead
  • ⚠Always use a dedicated MySQL user with least-privilege permissions
Platforms: macOS · Linux · WindowsClients: Claude Desktop · Claude Code · VS Code · Autohand Code · Smithery
Documentation ↗

Reviewed 2026-08-07

Topics

aiclaudeclaude-codedatabasellmmcpmcp-servermodel-context-protocolmysql
Stars
1,360★
Forks
257
Language
Python
License
MIT
Created
2024-12-03
Last push
2026-08-02