{"_id":"@ahmedmustafamalik/mysql-mcp","_rev":"6-8ac4ce08367bc81ee5c30482c9ad7380","name":"@ahmedmustafamalik/mysql-mcp","dist-tags":{"latest":"1.2.3"},"versions":{"1.0.0":{"name":"@ahmedmustafamalik/mysql-mcp","version":"1.0.0","keywords":["mcp","mysql","database","llm"],"author":{"name":"Ahmed Mustufa Malik"},"license":"Apache-2.0","_id":"@ahmedmustafamalik/mysql-mcp@1.0.0","maintainers":[{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"}],"bin":{"mysql-mcp":"build/index.js"},"dist":{"shasum":"4a62fbb79b77774603624a74aae26d2e47d9407d","tarball":"https://registry.npmjs.org/@ahmedmustafamalik/mysql-mcp/-/mysql-mcp-1.0.0.tgz","fileCount":42,"integrity":"sha512-xo4s7ZcEu06tzgJXTIbcmFOqdTt38SjrmPezVViYizTzjtSREtOX3Axjn2AOHwZmLiTJdCNa1keC48XeFTmm5A==","signatures":[{"sig":"MEUCIBtS3bDrlri7R0pId2xaIkIoYKfSX1IZvkBZFPQ0Q1fjAiEA00mbDORFU5bE1/S6pFtaa0UFYLMAqu9XlwrXjD1Ptb0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":139121},"main":"build/index.js","types":"./build/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"a58748831ee550959c34c6e2ec23e18aac653a2c","scripts":{"dev":"tsx watch src/index.ts","build":"tsc","clean":"rm -rf build","start":"node build/index.js","watch":"tsc --watch"},"_npmUser":{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"},"_npmVersion":"10.9.2","description":"MCP server for MySQL database interactions","directories":{},"_nodeVersion":"22.14.0","dependencies":{"dotenv":"^17.2.0","mysql2":"^3.15.2","express":"^5.1.0","@modelcontextprotocol/sdk":"^1.19.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.0","typescript":"^5.3.0","@types/node":"^20.10.0","@types/mssql":"^9.1.5","@types/express":"^5.0.3"},"_npmOperationalInternal":{"tmp":"tmp/mysql-mcp_1.0.0_1760098138535_0.8456457847195296","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@ahmedmustafamalik/mysql-mcp","version":"1.0.1","keywords":["mcp","mysql","database","llm"],"author":{"name":"Ahmed Mustufa Malik"},"license":"Apache-2.0","_id":"@ahmedmustafamalik/mysql-mcp@1.0.1","maintainers":[{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"}],"bin":{"mysql-mcp":"build/index.js"},"dist":{"shasum":"dc7fdaad5dceb3281c0761586b5e9bab824d07a9","tarball":"https://registry.npmjs.org/@ahmedmustafamalik/mysql-mcp/-/mysql-mcp-1.0.1.tgz","fileCount":45,"integrity":"sha512-VA3EUW4NHK00jlk275cYLM5w9cX1I0afhEnDiUrTxUvOsoPewMix9YLe7tVWCv/qa64mk3z3tMEZOohfgl673A==","signatures":[{"sig":"MEQCICGv77EbVX6FJHiW2WpsFYJ32A2WtScnvxS4c7lhf5tVAiA6aUMCZNs15UG0NKzhitPfULo0kCEN6GlWmR6nJfCi1A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":159286},"main":"build/index.js","types":"./build/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"e196237f98cc98b9583ae60d13e864c3553390c1","scripts":{"dev":"tsx watch src/index.ts","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","clean":"rm -rf build","start":"node build/index.js","watch":"tsc --watch","docker:run":"docker run --env-file .env mysql-mcp","docker:logs":"docker-compose logs -f mysql-mcp","docker:stop":"docker-compose down","docker:build":"docker build -t mysql-mcp .","docker:clean":"docker-compose down -v","docker:compose":"docker-compose up -d"},"_npmUser":{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"},"_npmVersion":"10.9.2","description":"MCP server for MySQL database interactions","directories":{},"_nodeVersion":"22.14.0","dependencies":{"zod":"^3.22.0","dotenv":"^17.2.0","mysql2":"^3.15.2","@modelcontextprotocol/sdk":"^1.19.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.6.0","typescript":"^5.3.0","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mysql-mcp_1.0.1_1760532446522_0.9261564727098892","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@ahmedmustafamalik/mysql-mcp","version":"1.1.1","keywords":["mcp","mysql","database","llm"],"author":{"name":"Ahmed Mustufa Malik"},"license":"Apache-2.0","_id":"@ahmedmustafamalik/mysql-mcp@1.1.1","maintainers":[{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"}],"bin":{"mysql-mcp":"build/index.js"},"dist":{"shasum":"f2483376b7620bbd9867b6fb18de84a6cb735ca3","tarball":"https://registry.npmjs.org/@ahmedmustafamalik/mysql-mcp/-/mysql-mcp-1.1.1.tgz","fileCount":45,"integrity":"sha512-DlDsTZ1hkfwXF3BJSGhoNxD42JGjY1TxSBYEgC9LIn4cFlvnyniNg4ZK2CpRlHOVXEkluWBwUXTeqVfm4ZLqmw==","signatures":[{"sig":"MEQCIBeSm4sCARn5sDtU4JiCu4tbOcA05V30shzb6c4yV7XhAiB6TUc8bZH6WXqzMkp/jbeRgZGPCk4vHbWhMKekVcmDgA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":164025},"main":"build/index.js","types":"./build/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"92225f210f76dcc174177808cd4bda44cbbaf398","scripts":{"dev":"tsx watch src/index.ts","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","clean":"rm -rf build","start":"node build/index.js","watch":"tsc --watch","docker:run":"docker run --env-file .env mysql-mcp","docker:logs":"docker-compose logs -f mysql-mcp","docker:stop":"docker-compose down","docker:build":"docker build -t mysql-mcp .","docker:clean":"docker-compose down -v","docker:compose":"docker-compose up -d"},"_npmUser":{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"},"_npmVersion":"10.9.2","description":"MCP server for MySQL database interactions","directories":{},"_nodeVersion":"22.14.0","dependencies":{"zod":"^3.22.0","dotenv":"^17.2.0","mysql2":"^3.15.2","@modelcontextprotocol/sdk":"^1.19.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.6.0","typescript":"^5.3.0","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mysql-mcp_1.1.1_1760718270215_0.9447796132725261","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@ahmedmustafamalik/mysql-mcp","version":"1.1.2","keywords":["mcp","mysql","database","llm"],"author":{"name":"Ahmed Mustufa Malik"},"license":"Apache-2.0","_id":"@ahmedmustafamalik/mysql-mcp@1.1.2","maintainers":[{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"}],"homepage":"https://github.com/Ahmustufa/mysql-mcp#readme","bugs":{"url":"https://github.com/Ahmustufa/mysql-mcp/issues"},"bin":{"mysql-mcp":"build/index.js"},"dist":{"shasum":"34bdf51708d19340bebd17bece8e9b26719c0db8","tarball":"https://registry.npmjs.org/@ahmedmustafamalik/mysql-mcp/-/mysql-mcp-1.1.2.tgz","fileCount":17,"integrity":"sha512-ZCvLu6bO3TWkRNPFtZkI8v2f+orexZNn2dNithI+w84OMPOzhjUi50Dkd9ZySsXw4L14glJVnLNR7Mp0YThLMA==","signatures":[{"sig":"MEQCIFCly8/1yGWasL0NB/pglM10i5MuTFzCcaP9cSaP4Vw5AiBAcWWSV5y6M+RhHYRpGKPalxc1cwlYLJtpFTdaQWdtDw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":86045},"main":"build/index.js","engines":{"node":">=18.0.0"},"gitHead":"b5cc0c0745a394469ccd4b034d88168e9cff7710","scripts":{"dev":"tsx watch src/index.ts","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","clean":"rm -rf build","start":"node build/index.js","watch":"tsc --watch","docker:run":"docker run --env-file .env mysql-mcp","docker:logs":"docker-compose logs -f mysql-mcp","docker:stop":"docker-compose down","docker:build":"docker build -t mysql-mcp .","docker:clean":"docker-compose down -v","docker:compose":"docker-compose up -d"},"_npmUser":{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"},"repository":{"url":"git+https://github.com/Ahmustufa/mysql-mcp.git","type":"git"},"_npmVersion":"10.9.3","description":"MCP server for MySQL database interactions","directories":{},"_nodeVersion":"22.20.0","dependencies":{"zod":"^3.22.0","dotenv":"^17.2.0","mysql2":"^3.15.2","@modelcontextprotocol/sdk":"^1.19.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.6.0","typescript":"^5.3.0","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mysql-mcp_1.1.2_1760868478261_0.6728306714223391","host":"s3://npm-registry-packages-npm-production"}},"1.2.2":{"name":"@ahmedmustafamalik/mysql-mcp","version":"1.2.2","keywords":["mcp","mysql","database","llm"],"author":{"name":"Ahmed Mustufa Malik"},"license":"Apache-2.0","_id":"@ahmedmustafamalik/mysql-mcp@1.2.2","maintainers":[{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"}],"homepage":"https://github.com/Ahmustufa/mysql-mcp#readme","bugs":{"url":"https://github.com/Ahmustufa/mysql-mcp/issues"},"bin":{"mysql-mcp":"build/index.js"},"dist":{"shasum":"8ff0fcfaf00c9b0a8f7802ba52cc458a2979fd58","tarball":"https://registry.npmjs.org/@ahmedmustafamalik/mysql-mcp/-/mysql-mcp-1.2.2.tgz","fileCount":39,"integrity":"sha512-CJInsIsflcNygzffb1kYaEeYDXxMe48oEApZMBASYpe813yOBxPrIKFSLRl3+qab61ay6AZ1lKtYZwLILqB+RQ==","signatures":[{"sig":"MEUCIHyan3luK+iAuB81uOOnc78Ef7R/vZIkLQh+hrUoB3XtAiEA9BmhlEl+v16p2WHUAV1JHXDM5yb93bEiGnM02RSows0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":129075},"main":"build/index.js","types":"./build/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"0da0a1929ea33c69142606b02c0c17ae334ac8c3","scripts":{"dev":"tsx watch src/index.ts","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","clean":"rm -rf build","start":"node build/index.js","watch":"tsc --watch","docker:run":"docker run --env-file .env mysql-mcp","docker:logs":"docker-compose logs -f mysql-mcp","docker:stop":"docker-compose down","docker:build":"docker build -t mysql-mcp .","docker:clean":"docker-compose down -v","docker:compose":"docker-compose up -d"},"_npmUser":{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"},"repository":{"url":"git+https://github.com/Ahmustufa/mysql-mcp.git","type":"git"},"_npmVersion":"10.9.2","description":"MCP server for MySQL database interactions","directories":{},"_nodeVersion":"22.14.0","dependencies":{"zod":"^3.22.0","dotenv":"^17.2.0","mysql2":"^3.15.2","@modelcontextprotocol/sdk":"^1.19.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.6.0","typescript":"^5.3.0","@types/node":"^20.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mysql-mcp_1.2.2_1760952287744_0.48340982116738673","host":"s3://npm-registry-packages-npm-production"}},"1.2.3":{"name":"@ahmedmustafamalik/mysql-mcp","version":"1.2.3","description":"MCP server for MySQL database interactions","main":"build/index.js","bin":{"mysql-mcp":"build/index.js"},"repository":{"url":"git+https://github.com/Ahmustufa/mysql-mcp.git","type":"git"},"scripts":{"build":"tsc","start":"node build/index.js","dev":"tsx watch src/index.ts","watch":"tsc --watch","clean":"rm -rf build","docker:build":"docker build -t mysql-mcp .","docker:run":"docker run --env-file .env mysql-mcp","docker:compose":"docker-compose up -d","docker:logs":"docker-compose logs -f mysql-mcp","docker:stop":"docker-compose down","docker:clean":"docker-compose down -v","test":"echo \"Error: no test specified\" && exit 1","test:connection":"node -e \"console.log('Connection test not implemented yet')\"","test:integration":"echo \"Integration tests not implemented yet\"","test:load":"echo \"Load tests not implemented yet\""},"publishConfig":{"access":"public"},"keywords":["mcp","mysql","database","llm"],"author":{"name":"Ahmed Mustufa Malik"},"license":"Apache-2.0","dependencies":{"@modelcontextprotocol/sdk":"^1.19.1","dotenv":"^17.2.0","mysql2":"^3.15.2","zod":"^3.22.0"},"devDependencies":{"@types/node":"^20.10.0","tsx":"^4.6.0","typescript":"^5.3.0"},"engines":{"node":">=18.0.0"},"_id":"@ahmedmustafamalik/mysql-mcp@1.2.3","gitHead":"63a9123912c3a808f2d1c038da476109da9a11b1","types":"./build/index.d.ts","bugs":{"url":"https://github.com/Ahmustufa/mysql-mcp/issues"},"homepage":"https://github.com/Ahmustufa/mysql-mcp#readme","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-bZCssa+OrnlUKVgxvqKfpmpOIiUZNlc0uD03RhwdCnNLaW/swTbZ7m7Ru1pq5uqe73iEpxXMavYfurJQH8fw2Q==","shasum":"5088f52faf379e99a6d5bf94cac7c12120c9c367","tarball":"https://registry.npmjs.org/@ahmedmustafamalik/mysql-mcp/-/mysql-mcp-1.2.3.tgz","fileCount":40,"unpackedSize":133164,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDE2kl9fPeX+PoGcJTp+R1Qis/h4gE3tI7iZZgzN1Fg8wIgSlRZrPPU8y4c249Thh9D6lzCbQz/1uZuGLG0Jdz14yk="}]},"_npmUser":{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"},"directories":{},"maintainers":[{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mysql-mcp_1.2.3_1760953821377_0.6050308572370102"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-10T12:08:58.476Z","modified":"2025-10-20T09:50:21.784Z","1.0.0":"2025-10-10T12:08:58.726Z","1.0.1":"2025-10-15T12:47:26.695Z","1.1.1":"2025-10-17T16:24:30.442Z","1.1.2":"2025-10-19T10:07:58.443Z","1.2.2":"2025-10-20T09:24:47.939Z","1.2.3":"2025-10-20T09:50:21.606Z"},"bugs":{"url":"https://github.com/Ahmustufa/mysql-mcp/issues"},"author":{"name":"Ahmed Mustufa Malik"},"license":"Apache-2.0","homepage":"https://github.com/Ahmustufa/mysql-mcp#readme","keywords":["mcp","mysql","database","llm"],"repository":{"url":"git+https://github.com/Ahmustufa/mysql-mcp.git","type":"git"},"description":"MCP server for MySQL database interactions","maintainers":[{"name":"ahmedmustafamalik","email":"ahmed.mustufa@thefertilitypartners.com"}],"readme":"# MySQL MCP Server\r\n\r\nA Model Context Protocol (MCP) server for MySQL database interactions. This server allows LLMs to understand database schemas and execute safe SQL queries with built-in security features and scalability support.\r\n\r\n> 🚀 **Quick Start**: New to this project? Check out our [Getting Started Guide](GETTING_STARTED.md) for the fastest way to get up and running!\r\n\r\n## Features\r\n\r\n- **Schema Analysis**: Comprehensive database schema exploration including tables, views, and stored procedures\r\n- **Safe Query Execution**: Built-in SQL injection protection and read-only query validation\r\n- **Connection Pooling**: Efficient connection management with configurable pool settings\r\n- **Docker Support**: Ready-to-deploy Docker container with multi-stage builds\r\n- **TypeScript Support**: Full TypeScript implementation with type safety\r\n- **AWS RDS Compatible**: Optimized for AWS RDS MySQL instances with SSL support\r\n- **Scalable Architecture**: Designed for high-performance database interactions\r\n\r\n## Installation\r\n\r\n### Local Development\r\n\r\n```bash\r\n# Clone the repository\r\ngit clone https://github.com/Ahmustufa/mysql-mcp.git\r\ncd mysql-mcp\r\n\r\n# Install dependencies\r\nnpm install\r\n\r\n# Install development dependencies (if not automatically installed)\r\nnpm install --save-dev tsx @types/node\r\n```\r\n\r\n### Docker Installation\r\n\r\n```bash\r\n# Build the Docker image\r\ndocker build -t mysql-mcp .\r\n\r\n# Or pull from registry (if published)\r\ndocker pull ahmustufa/mysql-mcp:latest\r\n```\r\n\r\n## Configuration\r\n\r\n### Environment Variables\r\n\r\nCreate a `.env` file in the project root:\r\n\r\n```bash\r\n# Required Database Configuration\r\nDB_SERVER=localhost\r\nDB_DATABASE=your_database_name\r\nDB_USER=your_username\r\nDB_PASSWORD=your_password\r\n\r\n# Optional Configuration\r\nDB_PORT=3306\r\nDB_SSL=false  # Set to 'false' to disable SSL, or leave undefined for AWS RDS SSL\r\n\r\n# For AWS RDS MySQL\r\n# DB_SERVER=your-rds-endpoint.region.rds.amazonaws.com\r\n# DB_SSL=Amazon RDS  # Enables SSL for RDS\r\n```\r\n\r\n### Docker Environment\r\n\r\nFor Docker deployments, you can use environment variables or a `.env` file:\r\n\r\n```bash\r\n# Docker with environment variables\r\ndocker run -e DB_SERVER=localhost \\\r\n           -e DB_DATABASE=mydb \\\r\n           -e DB_USER=user \\\r\n           -e DB_PASSWORD=password \\\r\n           mysql-mcp\r\n\r\n# Docker with .env file\r\ndocker run --env-file .env mysql-mcp\r\n```\r\n\r\n## Usage\r\n\r\n### Development Mode\r\n\r\n```bash\r\nnpm run dev\r\n```\r\n\r\n### Production Mode\r\n\r\n```bash\r\nnpm run build\r\nnpm start\r\n```\r\n\r\n### Docker Usage\r\n\r\n```bash\r\n# Basic Docker run\r\ndocker run --env-file .env mysql-mcp\r\n\r\n# Docker with port mapping (if extending with HTTP endpoints)\r\ndocker run -p 3000:3000 --env-file .env mysql-mcp\r\n\r\n# Docker Compose (see docker-compose.yml section below)\r\ndocker-compose up -d\r\n```\r\n\r\n## Available Tools\r\n\r\n### 1. execute_query\r\n\r\nExecute SQL queries with built-in safety validation.\r\n\r\n**Parameters:**\r\n\r\n- `query` (string): SQL query to execute\r\n\r\n**Safety Features:**\r\n\r\n- Blocks destructive operations (DROP, DELETE, TRUNCATE)\r\n- Prevents SQL injection attacks\r\n- Read-focused operations\r\n\r\n**Example:**\r\n\r\n```json\r\n{\r\n  \"query\": \"SELECT * FROM users WHERE id = 1\"\r\n}\r\n```\r\n\r\n### 2. list_tables\r\n\r\nList all base tables in the current database.\r\n\r\n**Parameters:** None\r\n\r\n**Returns:** Array of table information including schema, name, and type.\r\n\r\n**Example Usage:**\r\n\r\n```json\r\n{\r\n  \"tool\": \"list_tables\"\r\n}\r\n```\r\n\r\n### 3. describe_table\r\n\r\nGet detailed schema information for a specific table.\r\n\r\n**Parameters:**\r\n\r\n- `table_name` (string): Name of the table to describe\r\n\r\n**Returns:** Column information including data types, nullability, defaults, and constraints.\r\n\r\n**Example:**\r\n\r\n```json\r\n{\r\n  \"table_name\": \"users\"\r\n}\r\n```\r\n\r\n### 4. get_table_data\r\n\r\nRetrieve sample data from a table.\r\n\r\n**Parameters:**\r\n\r\n- `table_name` (string): Name of the table\r\n- `limit` (number, optional): Number of rows to return (1-100, default: 10)\r\n\r\n**Example:**\r\n\r\n```json\r\n{\r\n  \"table_name\": \"users\",\r\n  \"limit\": 5\r\n}\r\n```\r\n\r\n### 5. primary_keys\r\n\r\nGet primary key column(s) for a specific table.\r\n\r\n**Parameters:**\r\n\r\n- `table_name` (string): Name of the table\r\n\r\n**Returns:** List of primary key columns for the specified table.\r\n\r\n**Example:**\r\n\r\n```json\r\n{\r\n  \"table_name\": \"users\"\r\n}\r\n```\r\n\r\n### 6. search_columns\r\n\r\nFind columns whose names match a pattern (case-insensitive).\r\n\r\n**Parameters:**\r\n\r\n- `like` (string): Pattern to search for in column names\r\n\r\n**Returns:** List of matching columns across all tables with their data types.\r\n\r\n**Example:**\r\n\r\n```json\r\n{\r\n  \"like\": \"email\"\r\n}\r\n```\r\n\r\n### 7. foreign_keys\r\n\r\nList foreign key relationships for a table.\r\n\r\n**Parameters:**\r\n\r\n- `table_name` (string): Name of the table\r\n\r\n**Returns:** Foreign key relationships both referencing and referenced by the table.\r\n\r\n**Example:**\r\n\r\n```json\r\n{\r\n  \"table_name\": \"posts\"\r\n}\r\n```\r\n\r\n### 8. introspect_schema\r\n\r\nGet a complete schema overview of the database.\r\n\r\n**Parameters:** None\r\n\r\n**Returns:** Comprehensive JSON map of all tables with their columns, primary keys, and foreign key relationships.\r\n\r\n**Example:**\r\n\r\n```json\r\n{\r\n  \"tool\": \"introspect_schema\"\r\n}\r\n```\r\n\r\n## Security Features\r\n\r\n- **SQL Injection Protection**: Advanced pattern detection and query validation\r\n- **Read-Only Default**: Destructive operations are blocked by default\r\n- **Connection Pooling**: Secure and efficient database connections\r\n- **SSL Support**: Built-in SSL support for secure database connections\r\n- **Parameter Validation**: All inputs are validated before execution\r\n- **Query Length Limits**: Protection against DoS attacks\r\n\r\n## Docker Support\r\n\r\n### Basic Docker Commands\r\n\r\n```bash\r\n# Build the image\r\ndocker build -t mysql-mcp .\r\n\r\n# Run with environment variables\r\ndocker run --rm \\\r\n  -e DB_SERVER=your-mysql-server \\\r\n  -e DB_DATABASE=your_database \\\r\n  -e DB_USER=your_user \\\r\n  -e DB_PASSWORD=your_password \\\r\n  mysql-mcp\r\n\r\n# Run with .env file\r\ndocker run --rm --env-file .env mysql-mcp\r\n\r\n# Run with volume mount for configuration\r\ndocker run --rm \\\r\n  -v $(pwd)/.env:/app/.env \\\r\n  mysql-mcp\r\n```\r\n\r\n### Docker Compose\r\n\r\nCreate a `docker-compose.yml` file:\r\n\r\n```yaml\r\nversion: \"3.8\"\r\n\r\nservices:\r\n  mysql-mcp:\r\n    build: .\r\n    environment:\r\n      - DB_SERVER=mysql\r\n      - DB_DATABASE=testdb\r\n      - DB_USER=root\r\n      - DB_PASSWORD=rootpassword\r\n      - DB_PORT=3306\r\n    depends_on:\r\n      - mysql\r\n    restart: unless-stopped\r\n\r\n  mysql:\r\n    image: mysql:8.0\r\n    environment:\r\n      - MYSQL_ROOT_PASSWORD=rootpassword\r\n      - MYSQL_DATABASE=testdb\r\n    ports:\r\n      - \"3306:3306\"\r\n    volumes:\r\n      - mysql_data:/var/lib/mysql\r\n    restart: unless-stopped\r\n\r\nvolumes:\r\n  mysql_data:\r\n```\r\n\r\nRun with Docker Compose:\r\n\r\n```bash\r\n# Start services\r\ndocker-compose up -d\r\n\r\n# View logs\r\ndocker-compose logs -f mysql-mcp\r\n\r\n# Stop services\r\ndocker-compose down\r\n\r\n# Stop and remove volumes\r\ndocker-compose down -v\r\n```\r\n\r\n### Scaling with Docker\r\n\r\nFor high-availability deployments:\r\n\r\n```yaml\r\nversion: \"3.8\"\r\n\r\nservices:\r\n  mysql-mcp:\r\n    build: .\r\n    deploy:\r\n      replicas: 3\r\n      restart_policy:\r\n        condition: on-failure\r\n        delay: 5s\r\n        max_attempts: 3\r\n    environment:\r\n      - DB_SERVER=mysql-primary\r\n      - DB_DATABASE=proddb\r\n      - DB_USER=${DB_USER}\r\n      - DB_PASSWORD=${DB_PASSWORD}\r\n    depends_on:\r\n      - mysql-primary\r\n\r\n  mysql-primary:\r\n    image: mysql:8.0\r\n    environment:\r\n      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}\r\n      - MYSQL_DATABASE=proddb\r\n    volumes:\r\n      - mysql_primary_data:/var/lib/mysql\r\n    deploy:\r\n      placement:\r\n        constraints: [node.role == manager]\r\n\r\nvolumes:\r\n  mysql_primary_data:\r\n```\r\n\r\n## Error Handling\r\n\r\nThe server includes comprehensive error handling:\r\n\r\n- Database connection errors\r\n- Query validation errors\r\n- SQL execution errors\r\n- Parameter validation errors\r\n- Graceful shutdown handling\r\n\r\n## Database Schema Information\r\n\r\nThe server provides detailed schema information including:\r\n\r\n- **Tables**: Columns, data types, constraints, and structure\r\n- **Views**: Available database views and their definitions\r\n- **Data Types**: MySQL-specific data types and constraints\r\n- **Indexes**: Primary keys and index information\r\n- **Character Sets**: UTF-8 and collation support\r\n\r\n## Environment Variables\r\n\r\n| Variable      | Description                 | Default      | Required |\r\n| ------------- | --------------------------- | ------------ | -------- |\r\n| `DB_SERVER`   | MySQL server hostname or IP | -            | ✅       |\r\n| `DB_DATABASE` | Database name               | -            | ✅       |\r\n| `DB_USER`     | Database username           | -            | ✅       |\r\n| `DB_PASSWORD` | Database password           | -            | ✅       |\r\n| `DB_PORT`     | Database port               | 3306         | ❌       |\r\n| `DB_SSL`      | SSL configuration           | 'Amazon RDS' | ❌       |\r\n\r\n### SSL Configuration\r\n\r\n- Set `DB_SSL=false` to disable SSL completely\r\n- Leave undefined or set to `'Amazon RDS'` for AWS RDS SSL support\r\n- For custom SSL configurations, modify the connection settings in the code\r\n\r\n## AWS RDS Integration\r\n\r\nThis MCP server is optimized for AWS RDS MySQL instances:\r\n\r\n```bash\r\n# AWS RDS Configuration\r\nDB_SERVER=your-rds-instance.region.rds.amazonaws.com\r\nDB_DATABASE=your_database\r\nDB_USER=admin\r\nDB_PASSWORD=your_secure_password\r\nDB_PORT=3306\r\n# DB_SSL is automatically set to 'Amazon RDS' for SSL\r\n```\r\n\r\n### RDS Security Groups\r\n\r\nEnsure your RDS security group allows connections from your application:\r\n\r\n- Port: 3306 (or your custom port)\r\n- Source: Your application's IP range or security group\r\n\r\n## Performance and Scalability\r\n\r\n### Connection Pooling\r\n\r\nThe server uses MySQL2's built-in connection pooling:\r\n\r\n- Automatic connection management\r\n- Connection reuse for better performance\r\n- Configurable timeout settings (60 seconds default)\r\n\r\n### Scaling Strategies\r\n\r\n1. **Horizontal Scaling**: Deploy multiple MCP server instances\r\n2. **Database Read Replicas**: Point to MySQL read replicas for read-heavy workloads\r\n3. **Connection Limits**: Monitor and configure MySQL `max_connections`\r\n4. **Resource Monitoring**: Use CloudWatch or similar for RDS monitoring\r\n\r\n### Production Optimization\r\n\r\n```dockerfile\r\n# Multi-stage build for smaller production images\r\nFROM node:22.20-alpine as builder\r\nWORKDIR /app\r\nCOPY package*.json ./\r\nRUN npm ci --only=production\r\n\r\nFROM node:22.20-alpine as production\r\nWORKDIR /app\r\nCOPY --from=builder /app/node_modules ./node_modules\r\nCOPY build ./build\r\nCMD [\"node\", \"build/index.js\"]\r\n```\r\n\r\n## Development\r\n\r\n### Project Structure\r\n\r\n```\r\nmysql-mcp/\r\n├── src/\r\n│   └── index.ts               # Main entry point with MCP server implementation\r\n├── build/                     # Compiled TypeScript output\r\n├── .env                       # Environment configuration\r\n├── .dockerignore              # Docker ignore file\r\n├── Dockerfile                 # Docker container configuration\r\n├── docker-compose.yml         # Docker Compose setup (create this)\r\n├── package.json              # Node.js dependencies and scripts\r\n├── tsconfig.json             # TypeScript configuration\r\n└── README.md                 # This documentation\r\n```\r\n\r\n### Development Commands\r\n\r\n```bash\r\n# Install dependencies\r\nnpm install\r\n\r\n# Start development server with hot reload\r\nnpm run dev\r\n\r\n# Build for production\r\nnpm run build\r\n\r\n# Start production server\r\nnpm start\r\n\r\n# Watch for changes (compile only)\r\nnpm run watch\r\n\r\n# Clean build directory\r\nnpm run clean\r\n```\r\n\r\n### Adding New Tools\r\n\r\nTo add new MCP tools, register them in `src/index.ts`:\r\n\r\n```typescript\r\nserver.registerTool(\r\n  \"your_tool_name\",\r\n  {\r\n    title: \"Your Tool Title\",\r\n    description: \"Description of what your tool does\",\r\n    inputSchema: {\r\n      parameter: z.string().min(1),\r\n    },\r\n  },\r\n  async ({ parameter }) => {\r\n    // Your tool implementation\r\n    const result = await performSomeOperation(parameter);\r\n    return {\r\n      content: [\r\n        {\r\n          type: \"text\",\r\n          text: JSON.stringify(result, null, 2),\r\n        },\r\n      ],\r\n    };\r\n  }\r\n);\r\n```\r\n\r\n## Error Handling\r\n\r\nThe server includes comprehensive error handling:\r\n\r\n- **Database Connection Errors**: Automatic retry with exponential backoff\r\n- **Query Validation Errors**: Detailed error messages for invalid queries\r\n- **SQL Execution Errors**: Safe error reporting without exposing sensitive data\r\n- **Parameter Validation**: Type checking and sanitization\r\n- **Graceful Shutdown**: Proper cleanup of database connections\r\n\r\n## Troubleshooting\r\n\r\n### Common Issues\r\n\r\n1. **Connection Refused**\r\n\r\n   ```bash\r\n   Error: connect ECONNREFUSED\r\n   ```\r\n\r\n   - Check if MySQL server is running\r\n   - Verify DB_SERVER and DB_PORT configuration\r\n   - Check firewall/security group settings\r\n\r\n2. **Authentication Failed**\r\n\r\n   ```bash\r\n   Error: Access denied for user\r\n   ```\r\n\r\n   - Verify DB_USER and DB_PASSWORD\r\n   - Check user permissions in MySQL\r\n   - Ensure user can connect from your host\r\n\r\n3. **Database Not Found**\r\n\r\n   ```bash\r\n   Error: Unknown database\r\n   ```\r\n\r\n   - Verify DB_DATABASE exists\r\n   - Check user has access to the specified database\r\n\r\n4. **SSL Connection Issues**\r\n   ```bash\r\n   Error: SSL connection error\r\n   ```\r\n   - For local development: set `DB_SSL=false`\r\n   - For RDS: ensure SSL certificates are properly configured\r\n\r\n### Debug Mode\r\n\r\nEnable detailed logging by setting NODE_ENV:\r\n\r\n```bash\r\nNODE_ENV=development npm run dev\r\n```\r\n\r\n## Testing\r\n\r\n### Unit Tests\r\n\r\n```bash\r\n# Add testing framework\r\nnpm install --save-dev jest @types/jest\r\n\r\n# Run tests\r\nnpm test\r\n```\r\n\r\n### Integration Tests\r\n\r\n```bash\r\n# Test with actual database\r\nnpm run test:integration\r\n```\r\n\r\n### Load Testing\r\n\r\n```bash\r\n# Test connection pooling and performance\r\nnpm run test:load\r\n```\r\n\r\n## Contributing\r\n\r\nWe welcome contributions! Please follow these guidelines:\r\n\r\n### Getting Started\r\n\r\n1. Fork the repository\r\n2. Create a feature branch: `git checkout -b feature/your-feature-name`\r\n3. Make your changes with proper TypeScript types\r\n4. Add tests for new functionality\r\n5. Update documentation as needed\r\n6. Submit a pull request\r\n\r\n### Code Style\r\n\r\n- Use TypeScript for all new code\r\n- Follow ESLint and Prettier configurations\r\n- Add JSDoc comments for public APIs\r\n- Use semantic commit messages\r\n\r\n### Pull Request Process\r\n\r\n1. Ensure all tests pass\r\n2. Update the README if needed\r\n3. Add a clear description of changes\r\n4. Reference any related issues\r\n\r\n## Changelog\r\n\r\n### v1.1.0\r\n\r\n- Switched from MSSQL to MySQL support\r\n- Added AWS RDS SSL compatibility\r\n- Improved connection pooling\r\n- Added Docker support with multi-stage builds\r\n- Enhanced security with query validation\r\n\r\n### v1.0.0\r\n\r\n- Initial release with basic MCP tools\r\n- TypeScript implementation\r\n- Basic Docker support\r\n\r\n## License\r\n\r\nApache License 2.0 - see [LICENSE](LICENSE) file for details.\r\n\r\n## Support\r\n\r\nFor issues and questions:\r\n\r\n- **GitHub Issues**: [Open an issue](https://github.com/Ahmustufa/mysql-mcp/issues)\r\n- **Documentation**: Check this README for common solutions\r\n- **Community**: Join discussions in GitHub Discussions\r\n\r\n## Related Projects\r\n\r\n- [Model Context Protocol SDK](https://github.com/modelcontextprotocol/typescript-sdk)\r\n- [MySQL2 Node.js Driver](https://github.com/sidorares/node-mysql2)\r\n- [AWS RDS Documentation](https://docs.aws.amazon.com/rds/)\r\n\r\n## Acknowledgments\r\n\r\n- Model Context Protocol team for the excellent SDK\r\n- MySQL2 maintainers for the robust database driver\r\n- The open-source community for continuous improvements\r\n","readmeFilename":"README.md"}