{"id":22889299,"url":"https://github.com/designcomputer/mysql_mcp_server","last_synced_at":"2026-08-27T23:55:52.790Z","repository":{"id":266358042,"uuid":"898128804","full_name":"designcomputer/mysql_mcp_server","owner":"designcomputer","description":"A Model Context Protocol (MCP) server that enables secure interaction with MySQL databases","archived":false,"fork":false,"pushed_at":"2026-08-02T13:36:20.000Z","size":287,"stargazers_count":1363,"open_issues_count":1,"forks_count":257,"subscribers_count":8,"default_branch":"main","last_synced_at":"2026-08-22T15:09:28.885Z","etag":null,"topics":["ai","claude","claude-code","database","llm","mcp","mcp-server","model-context-protocol","mysql"],"latest_commit_sha":null,"homepage":"https://designcomputer.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/designcomputer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-03T20:53:52.000Z","updated_at":"2026-08-21T08:17:14.000Z","dependencies_parsed_at":"2025-05-15T15:19:10.001Z","dependency_job_id":null,"html_url":"https://github.com/designcomputer/mysql_mcp_server","commit_stats":null,"previous_names":["designcomputer/mysql_mcp_server"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/designcomputer/mysql_mcp_server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designcomputer%2Fmysql_mcp_server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designcomputer%2Fmysql_mcp_server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designcomputer%2Fmysql_mcp_server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designcomputer%2Fmysql_mcp_server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/designcomputer","download_url":"https://codeload.github.com/designcomputer/mysql_mcp_server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designcomputer%2Fmysql_mcp_server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":36947771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-08-22T15:14:58.755Z","status":"online","status_checked_at":"2026-08-27T02:00:07.166Z","response_time":96,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","claude","claude-code","database","llm","mcp","mcp-server","model-context-protocol","mysql"],"created_at":"2024-12-13T21:28:08.546Z","updated_at":"2026-08-27T23:55:52.776Z","avatar_url":"https://github.com/designcomputer.png","language":"Python","funding_links":[],"categories":["👥 Community Contributions","Databases","Database \u0026 Messaging MCP Servers","Datenbanken und Data Warehouses","サーバー実装","MCP 服务器精选列表","📚 Projects (1974 total)","Community Servers","Legend","🗄️ Database","🗄️ \u003ca name=\"databases\"\u003e\u003c/a\u003eDatabases","MCP Servers","APIs and HTTP Requests","Containerised MCP Servers","Contributing","🗂️ Extensions by Category","Data \u0026 Analytics","Table of Contents","📂 By Category","🗄️ Databases (68 servers)","Server Implementations","Agent Communication Protocols","Python"],"sub_categories":["Database Integrations","SQL Databases","Claude API","Dieselbe Konfiguration, CLI und IDE","🗄️ \u003ca name=\"databases\"\u003e\u003c/a\u003eデータベース","🗄️ 数据库交互","MCP Servers","🗄️ \u003ca name=\"databases\"\u003e\u003c/a\u003eDatabases","🗄️ Databases","💾 Databases","Database \u0026 Storage","Databases","Model Context Protocol (MCP)"],"readme":"[![Tests](https://github.com/designcomputer/mysql_mcp_server/actions/workflows/test.yml/badge.svg)](https://github.com/designcomputer/mysql_mcp_server/actions)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/mysql-mcp-server)](https://pypi.org/project/mysql-mcp-server/)\n[![AgentAudit Safe](https://img.shields.io/badge/AgentAudit-safe-brightgreen)](https://www.agentaudit.dev/packages/mysql-mcp-server)\n# MySQL MCP Server\nA Model Context Protocol (MCP) implementation that enables secure interaction with MySQL databases. This server component facilitates communication between AI applications (hosts/clients) and MySQL databases, making database exploration and analysis safer and more structured through a controlled interface.\n\n\u003e **Note**: MySQL MCP Server supports both standard input/output (STDIO) and Streamable HTTP (SSE) transport modes. The SSE mode is recommended for remote/self-hosted deployments.\n\n## Deployment options\n- **Hosted** — [Fronteir AI](https://fronteir.ai/mcp/designcomputer-mysql-mcp-server) runs the server for you; no local setup required.\n- **Local** — [Smithery](https://smithery.ai/server/designcomputer/mysql-mcp-server) installs and runs the server on your own machine.\n\n## Features\n- List available MySQL tables as resources\n- Read table contents\n- Execute SQL queries with proper error handling\n- **Multi-database mode** (Optional `MYSQL_DATABASE`)\n- **SSE/HTTP transport support** (`MCP_TRANSPORT=sse`)\n- **SSH Tunneling support**\n- **Comprehensive schema information**\n- **Table data sampling**\n- Secure database access through environment variables\n- Comprehensive logging\n\n## Installation\n### Manual Installation\n```bash\npip install mysql-mcp-server\n```\n\n### Installing via Smithery\nTo install MySQL MCP Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/designcomputer/mysql-mcp-server):\n```bash\nnpx -y @smithery/cli install designcomputer/mysql-mcp-server --client claude\n```\n\n### Installing via Claude Code CLI\n```bash\nclaude mcp add --transport stdio designcomputer-mysql_mcp_server uvx mysql_mcp_server\n```\n\n### Installing via Autohand Code CLI\n```bash\nautohand mcp add mysql env MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_USER=your_username MYSQL_PASSWORD=your_password MYSQL_DATABASE=your_database uvx mysql_mcp_server\n```\n\nAdd `--scope project` after `mcp add` to keep the registration in the current workspace. See [Autohand Code](https://github.com/autohandai/code-cli/) for current CLI details.\n\n## Configuration\nSet the following environment variables:\n```bash\nMYSQL_HOST=localhost     # Database host\nMYSQL_PORT=3306         # Optional: Database port (defaults to 3306 if not specified)\nMYSQL_USER=your_username\nMYSQL_PASSWORD=your_password\nMYSQL_DATABASE=your_database # Optional: Omit for multi-database mode\n\n# Advanced Configuration\nMYSQL_SSL_MODE=DISABLED  # DISABLED, REQUIRED, VERIFY_CA, VERIFY_IDENTITY\nMYSQL_CONNECT_TIMEOUT=10 # Timeout in seconds\n\n# Connection behaviour (Optional)\nMYSQL_SQL_MODE=TRADITIONAL           # SQL mode applied to the connection (default: TRADITIONAL)\n\n# Compatibility (Optional)\nMYSQL_CHARSET=utf8mb4\nMYSQL_COLLATION=utf8mb4_unicode_ci\nMYSQL_AUTH_PLUGIN=       # e.g., mysql_native_password for older MySQL versions\nMYSQL_USE_PURE=false     # Force the pure-Python connector (default: false)\nMYSQL_RAISE_ON_WARNINGS=false        # Raise on SQL warnings (default: false)\n\n# SSE Transport (Optional)\nMCP_TRANSPORT=stdio      # stdio or sse\nMCP_SSE_HOST=0.0.0.0     # Listen on all interfaces (required for Docker/hosting)\nPORT=8000                # HTTP port (fallback for MCP_SSE_PORT)\nMCP_SSE_ALLOWED_HOSTS=   # Comma-separated allowed Host headers (default: localhost:{port},127.0.0.1:{port})\n\n# SSH Tunneling (Optional)\nMYSQL_SSH_ENABLE=false   # Set to true to enable\nMYSQL_SSH_HOST=          # SSH jump host\nMYSQL_SSH_PORT=22        # SSH port\nMYSQL_SSH_USER=          # SSH username\nMYSQL_SSH_KEY_PATH=      # Path to SSH private key\nMYSQL_SSH_REMOTE_HOST=localhost # Host from the perspective of the jump host\nMYSQL_SSH_REMOTE_PORT=3306\nMYSQL_LOCAL_PORT=3330\n```\n\n### `.env` file loading\n\nOn startup the server automatically loads a `.env` file via `python-dotenv`, so for local use you can simply:\n\n```bash\ncp .env.example .env   # then edit with your credentials\n```\n\nThe file is read from the **process working directory** (and parent directories), which works when you run the server yourself from the project folder.\n\n\u003e ⚠️ **Claude Code / Claude Desktop:** these hosts launch the server from their own working directory, so the project's `.env` will **not** be found and you'll see `Missing required database configuration`. Put your `MYSQL_*` values in the `env` block of the MCP config (shown in the Usage section below) rather than relying on `.env`.\n\n### Multi-Database Mode\nWhen `MYSQL_DATABASE` is not set, the server operates in multi-database mode:\n- `list_resources` returns all user databases (system databases are filtered out)\n- Use fully qualified table names like `mydb.mytable` in SQL queries\n- **Note:** Only single SQL statements are supported. Multi-statement queries (e.g., `USE db; SELECT ...`) are not supported.\n\n## Available Tools\n\n### `execute_sql`\nExecutes any standard SQL query.\n- **Arguments:** `query` (string)\n- **Features:** Supports `SELECT`, `SHOW`, `DESCRIBE`, and DML (`INSERT`, `UPDATE`, `DELETE`). DML operations are marked with a destructive hint.\n- **Limitation:** Single statements only. Multi-statement queries are not supported.\n- **Cross-database:** Use `database.table` notation to query any database regardless of the `MYSQL_DATABASE` setting.\n\n### `get_schema_info`\nProvides detailed metadata about database structures.\n- **Arguments:** `table_name` (optional string)\n- **Output:** Column names, types, nullability, default values, and comments.\n- **Cross-database:** Pass `database.table` to query a table outside `MYSQL_DATABASE`; bare names use the configured database.\n- **Identifier rules:** Names must contain only alphanumeric characters, underscores, and `$` (dots are allowed as a separator between database and table names).\n\n### `get_table_sample`\nFetches a representative sample of data.\n- **Arguments:** `table_name` (string), `limit` (optional integer, max 20)\n- **Use Case:** Quickly understand data formats and content without fetching large result sets.\n- **Cross-database:** Pass `database.table` to sample a table outside `MYSQL_DATABASE`; bare names use the configured database.\n- **Identifier rules:** Names must contain only alphanumeric characters, underscores, and `$` (dots are allowed as a separator between database and table names).\n\n## Available Prompts\n\nIn addition to tools, the server exposes **MCP prompts** — guided, multi-step workflows that a client can launch on demand. In Claude Code they appear as slash commands (`/mcp__\u003cserver\u003e__\u003cprompt\u003e`); in Claude Desktop they appear in the prompts (`+`) menu.\n\n| Prompt | Arguments | Description |\n| --- | --- | --- |\n| `explore_database` | *(none)* | Systematically explore the database: discover available tables, inspect their schemas, sample the data, and summarize what's there. |\n| `analyze_table` | `table_name` *(required)* | Deep-dive into a specific table: retrieve its schema, sample its data, and suggest useful queries. Accepts `database.table` notation for cross-database lookups. |\n\n**Example (Claude Code):**\n```\n/mcp__mysql__explore_database\n/mcp__mysql__analyze_table customers\n```\n\nBoth prompts orchestrate the existing `get_schema_info` and `get_table_sample` tools; `explore_database` also uses resource listing to enumerate tables.\n\n## Usage\n### With Claude Desktop\nAdd this to your `claude_desktop_config.json`:\n```json\n{\n  \"mcpServers\": {\n    \"mysql\": {\n      \"command\": \"uv\",\n      \"args\": [\n        \"--directory\",\n        \"path/to/mysql_mcp_server\",\n        \"run\",\n        \"mysql_mcp_server\"\n      ],\n      \"env\": {\n        \"MYSQL_HOST\": \"localhost\",\n        \"MYSQL_PORT\": \"3306\",\n        \"MYSQL_USER\": \"your_username\",\n        \"MYSQL_PASSWORD\": \"your_password\",\n        \"MYSQL_DATABASE\": \"your_database\"\n      }\n    }\n  }\n}\n```\n\nFor more detailed examples and agent-specific guidance, see [MCP_USECASES.md](MCP_USECASES.md).\n\n### With Visual Studio Code\nAdd this to your `mcp.json`:\n```json\n{\n  \"mcpServers\": {\n    \"mysql\": {\n      \"type\": \"stdio\",\n      \"command\": \"uvx\",\n      \"args\": [\n        \"--from\",\n        \"mysql-mcp-server\",\n        \"mysql_mcp_server\"\n      ],\n      \"env\": {\n        \"MYSQL_HOST\": \"localhost\",\n        \"MYSQL_PORT\": \"3306\",\n        \"MYSQL_USER\": \"your_username\",\n        \"MYSQL_PASSWORD\": \"your_password\",\n        \"MYSQL_DATABASE\": \"your_database\"\n      }\n    }\n  }\n}\n```\nNote: Will need to install uv for this to work\n\n### Debugging with MCP Inspector\nWhile MySQL MCP Server isn't intended to be run standalone or directly from the command line with Python, you can use the MCP Inspector to debug it.\n\nThe MCP Inspector provides a convenient way to test and debug your MCP implementation:\n\n```bash\n# Install dependencies\npip install -r requirements.txt\n# Use the MCP Inspector for debugging (do not run directly with Python)\n```\n\nThe MySQL MCP Server is designed to be integrated with AI applications like Claude Desktop and should not be run directly as a standalone Python program.\n\n## Development\n```bash\n# Clone the repository\ngit clone https://github.com/designcomputer/mysql_mcp_server.git\ncd mysql_mcp_server\n# Create virtual environment\npython -m venv venv\nsource venv/bin/activate  # or `venv\\Scripts\\activate` on Windows\n# Install development dependencies\npip install -r requirements-dev.txt\n# Copy the example config and edit with your credentials\ncp .env.example .env\n# Edit .env with your MySQL connection details\n# Run tests\npytest\n```\n\n## Security Considerations\n- **Identifier Validation:** Table and database names passed to `get_schema_info` and `get_table_sample` are validated against a strict whitelist (alphanumeric, underscore, and `$` only; a single dot is allowed as a `database.table` separator). Other special characters are rejected to prevent SQL injection.\n- **Encrypted Access:** Full support for SSL/TLS and SSH Tunneling for secure remote connections.\n- **Log Privacy:** Passwords and SSH private keys are automatically masked in server logs.\n- **Least Privilege:** Always use a dedicated MySQL user with minimal required permissions.\n- **SSE transport has no built-in authentication.** The SSE server binds to `0.0.0.0` by default and accepts connections without credentials. If you expose it beyond localhost, place it behind a reverse proxy (nginx, Caddy, Traefik) that enforces authentication. Example with nginx and HTTP Basic Auth:\n\n  ```nginx\n  location /sse {\n      auth_basic \"MCP\";\n      auth_basic_user_file /etc/nginx/.htpasswd;\n      proxy_pass http://127.0.0.1:8000;\n      proxy_set_header Host $host;\n      proxy_buffering off;\n  }\n  location /messages/ {\n      auth_basic \"MCP\";\n      auth_basic_user_file /etc/nginx/.htpasswd;\n      proxy_pass http://127.0.0.1:8000;\n      proxy_set_header Host $host;\n  }\n  ```\n\n  Set `MCP_SSE_HOST=127.0.0.1` so the server only listens on loopback and the proxy is the sole public entry point. Set `MCP_SSE_ALLOWED_HOSTS` to the public hostname your proxy forwards (e.g. `MCP_SSE_ALLOWED_HOSTS=myserver.example.com:443`).\n\nSee [SECURITY.md](SECURITY.md) for a comprehensive guide on securing your deployment.\n\n## Security Best Practices\nThis MCP implementation requires database access to function. For security:\n1. **Create a dedicated MySQL user** with minimal permissions\n2. **Never use root credentials** or administrative accounts\n3. **Restrict database access** to only necessary operations\n4. **Enable logging** for audit purposes\n5. **Regular security reviews** of database access\n\nSee [MySQL Security Configuration Guide](https://github.com/designcomputer/mysql_mcp_server/blob/main/SECURITY.md) for detailed instructions on:\n- Creating a restricted MySQL user\n- Setting appropriate permissions\n- Monitoring database access\n- Security best practices\n\n⚠️ IMPORTANT: Always follow the principle of least privilege when configuring database access.\n\n## License\nMIT License - see LICENSE file for details.\n\n## Contributing\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesigncomputer%2Fmysql_mcp_server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdesigncomputer%2Fmysql_mcp_server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesigncomputer%2Fmysql_mcp_server/lists"}