Content
# MySQL MCP Server Generator (Supports stdio + SSE)
This project is used to **batch** generate MCP server scripts based on **MySQL**. Each generated script supports two transport methods:
* **stdio** – Called through local subprocess / pipe
* **SSE (HTTP)** – Provides remote access via the `/sse` endpoint (compatible with MCP Inspector)
---
## Installation
```bash
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS / Linux / WSL
source .venv/bin/activate
pip install -r requirements.txt
```
---
## Usage Process
### 1️⃣ Start the Generator Interface
```bash
python app.py
```
Open your browser and go to **http://127.0.0.1:5000**, then complete the following steps:
1. Enter MySQL connection information (host, port, user, password, database).
2. Specify the output file name (**must end with `.py`**, e.g., `my_server.py`).
3. Click **Generate**. The script will automatically include a `check_database` tool for quick connectivity testing.
### 2️⃣ Add Custom Tools
Go to the **"Add Tool Function"** page and fill in the details for each SQL query:
| Field | Description |
|----------------|----------------------|
| Tool Function Name | Use `snake_case` |
| Tool Description | 1-line description |
| SQL Statement | Use `%s` as a placeholder for parameters |
| Output Format (optional) | Python code snippet, concatenate return text using `content.append()` |
Example formatted code:
```python
for row in rows:
content.append(f"Device Account: {row['username']}")
content.append(f"IPv4: {row['user_ip4']}")
```
After saving, the script will automatically insert the tool function.
### 3️⃣ Run the Generated Server Script
| Mode | Command | Access Address |
|--------------------|-----------------------------|-------------------------------|
| **stdio** (default) | `python my_server.py` | – |
| **SSE / HTTP** | `python my_server.py --http` | `http://127.0.0.1:8000/sse` |
> 📌 **Note**
> The current `FastMCP.run()` listens on `0.0.0.0:8000` by default.
> If you need to customize the port, you can set the environment variable before starting, for example:
>
> ```bash
> # Windows
> set MCP_PORT=9110
> # Linux / macOS / WSL
> export MCP_PORT=9110
> python my_server.py --http
> ```
### 4️⃣ Test with MCP Inspector
```bash
npx @modelcontextprotocol/inspector
```
* Select **SSE** for Transport
* Enter **http://127.0.0.1:8000/sse** for URL
Once connected successfully, you will see the automatically discovered tool list on the left side and can invoke them.
---
## Project Structure
```
├── app.py # Flask GUI generator
├── templates/ # Jinja2 + Bootstrap pages
├── static/ # Frontend static resources
├── requirements.txt # Dependency list
└── README.md # Usage instructions (this file)
```
Wishing you smooth development and quick batch generation of MCP Server!
Connection Info
You Might Also Like
everything-claude-code
Complete Claude Code configuration collection - agents, skills, hooks,...
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
servers
Model Context Protocol Servers
servers
Model Context Protocol Servers
Time
A Model Context Protocol server for time and timezone conversions.
Filesystem
Node.js MCP Server for filesystem operations with dynamic access control.