# Mysql Mcp Server

> 🔧 MySQL MCP Server for Model Context Protocol Features: • Execute any MySQL query • List all databases • List tables in database • Describe table structure • Environment-based configuration • Built with TypeScript & MCP SDK Ready to use with Claude Desktop, Cursor, and other MCP clients.

- **Type:** MCP server
- **Install:** `agentstack add mcp-myheisenberg-mysql-mcp-server`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [myheisenberg](https://agentstack.voostack.com/s/myheisenberg)
- **Installs:** 0
- **Category:** [Databases](https://agentstack.voostack.com/c/databases)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [myheisenberg](https://github.com/myheisenberg)
- **Source:** https://github.com/myheisenberg/mysql-mcp-server

## Install

```sh
agentstack add mcp-myheisenberg-mysql-mcp-server
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 🔧 MySQL MCP Server

A Model Context Protocol (MCP) server for MySQL database operations. Provides 4 powerful tools for database interaction through any MCP-compatible client.

## ✨ Features

- **🔍 Execute SQL Queries** - Run any SELECT, INSERT, UPDATE, DELETE commands
- **📊 List Databases** - View all available databases
- **📋 List Tables** - Show tables in any database
- **🏗️ Describe Tables** - Get detailed table structure information
- **🔒 Secure** - Environment-based configuration, no hardcoded credentials
- **⚡ Fast** - Built with TypeScript and connection pooling

## 🚀 Quick Start

### Installation

```bash
# Clone the repository
git clone https://github.com/myheisenberg/mysql-mcp-server.git
cd mysql-mcp-server

# Install dependencies
npm install

# Build the project
npm run build
```

### Configuration

The server uses environment variables for database configuration:

```bash
DB_HOST=localhost        # MySQL host (default: localhost)
DB_USER=root            # MySQL username (default: root)
DB_PASSWORD=            # MySQL password (default: empty)
DB_PORT=3306           # MySQL port (default: 3306)
```

## 📖 Usage

### With Claude Desktop

Add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["path/to/mysql-mcp-server/dist/index.js"],
      "env": {
        "DB_HOST": "localhost",
        "DB_USER": "your_username",
        "DB_PASSWORD": "your_password",
        "DB_PORT": "3306"
      }
    }
  }
}
```

### With Cursor IDE

Add to your MCP configuration:

```json
{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["path/to/mysql-mcp-server/dist/index.js"],
      "env": {
        "DB_HOST": "localhost",
        "DB_USER": "your_username", 
        "DB_PASSWORD": "your_password",
        "DB_PORT": "3306"
      }
    }
  }
}
```

## 🛠️ Available Tools

### 1. `mysql_query`
Execute any MySQL query and get formatted results.

**Example:** "Run a SELECT query on the users table"

### 2. `mysql_databases`
List all available databases on the MySQL server.

**Example:** "Show me all databases"

### 3. `mysql_tables`
List all tables in a specific database.

**Example:** "What tables are in the blog database?"

### 4. `mysql_describe`
Get detailed information about a table's structure.

**Example:** "Describe the structure of the users table"

## 🔧 Development

```bash
# Install dependencies
npm install

# Development mode (watch for changes)
npm run dev

# Build for production
npm run build

# Start the server
npm start
```

## 📦 Project Structure

```
mysql-mcp-server/
├── src/
│   └── index.ts          # Main MCP server implementation
├── dist/                 # Compiled JavaScript (auto-generated)
├── package.json          # Project dependencies and scripts
├── tsconfig.json         # TypeScript configuration
├── .gitignore           # Git ignore rules
└── README.md            # This file
```

## 🔒 Security

- **No hardcoded credentials** - All database connection details come from environment variables
- **Connection pooling** - Efficient and secure database connections
- **Error handling** - Proper error messages without exposing sensitive information

## 🤝 Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- Built with the [Model Context Protocol SDK](https://github.com/modelcontextprotocol/typescript-sdk)
- Uses [mysql2](https://github.com/sidorares/node-mysql2) for MySQL connectivity
- Inspired by the MCP community

## 📞 Support

If you encounter any issues or have questions:

1. Check the [Issues](https://github.com/myheisenberg/mysql-mcp-server/issues) page
2. Create a new issue if your problem isn't already reported
3. Provide as much detail as possible including error messages and configuration

---

**Made with ❤️ for the MCP community**

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [myheisenberg](https://github.com/myheisenberg)
- **Source:** [myheisenberg/mysql-mcp-server](https://github.com/myheisenberg/mysql-mcp-server)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-myheisenberg-mysql-mcp-server
- Seller: https://agentstack.voostack.com/s/myheisenberg
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
