Skip to content

Modified to be Langflow Compatible #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 42 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[![smithery badge](https://smithery.ai/badge/mysql-mcp-server)](https://smithery.ai/server/mysql-mcp-server)
[![MseeP.ai Security Assessment Badge](https://mseep.net/mseep-audited.png)](https://mseep.ai/app/designcomputer-mysql-mcp-server)
# MySQL MCP Server
A 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.
A Model Context Protocol (MCP) implementation that enables secure interaction with MySQL databases running on python server. 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.

> **Note**: MySQL MCP Server is not designed to be used as a standalone server, but rather as a communication protocol implementation between AI applications and MySQL databases.
> **Note**: MySQL MCP Server is not designed to be used as a standalone server, but rather as a communication protocol implementation between AI applications and MySQL databases. This modified version of MySQL MCP Server is compatible with [Langflow](https://github.com/langflow-ai/langflow) MCPTools component via STDIO protocol.

## Features
- List available MySQL tables as resources
Expand All @@ -14,39 +14,60 @@ A Model Context Protocol (MCP) implementation that enables secure interaction wi
- Secure database access through environment variables
- Comprehensive logging

## Installation
## Installation
### Manual Installation

1. Open up Windows CMD, cd to desktop location.
```bash
cd desktop
```

2. Cloning the repo
```bash
pip install mysql-mcp-server
git clone https://github.com/CHuiV123/mysql_mcp_server_LangflowCompatible.git
```

### Installing via Smithery
To install MySQL MCP Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/mysql-mcp-server):
3. Get into the folder directory:
```bash
npx -y @smithery/cli install mysql-mcp-server --client claude
cd mysql_mcp_server_LangflowCompatible
```

4. Install dependencies
```bash
pip install -r requirements.txt
```

## Configuration
Set the following environment variables:
5. set up environment variable as below, replace all the "<-CHANGE THIS" section:
```bash
MYSQL_HOST=localhost # Database host
MYSQL_PORT=3306 # Optional: Database port (defaults to 3306 if not specified)
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database
set MYSQL_HOST="YOUR_DATABASE_HOST" <-CHANGE THIS
set MYSQL_PORT=3306 <-CHANGE THIS IF YOUR DATABASE IS NOT RUNNING ON 3306
set MYSQL_USER="YOUR_USER_NAME" <-CHANGE THIS
set MYSQL_PASSWORD="YOUR_PASSWORD" <-CHANGE THIS
set MYSQL_DATABASE="yOUR_DATABASE_NAME" <-CHANGE THIS
```

## Usage
### With Claude Desktop
Add this to your `claude_desktop_config.json`:
```json
6. Start the server:
```bash
uv --directory . run mysql_mcp_server
```

Upon successful server start up, you shall see "mysql_mcp_server - INFO - Starting MCP STDIO server..."

## Setting up in Langflow MCPTools
*** pre-requisite, at this point MySQL MCP server should be already up and running.

1. Go to Langflow setting, look for MCP server.
2. Click **Add MCP Server**
3. Select **JSON**
4. Copy and paste this config under JSON section
```
{
"mcpServers": {
"mysql": {
"command": "uv",
"args": [
"--directory",
"path/to/mysql_mcp_server",
"path/to/mysql_mcp_server",
"run",
"mysql_mcp_server"
],
Expand All @@ -61,32 +82,9 @@ Add this to your `claude_desktop_config.json`:
}
}
```
8. Click **Add server**
9. Restart Langflow (**If necessary)

### With Visual Studio Code
Add this to your `mcp.json`:
```json
{
"servers": {
"mysql": {
"type": "stdio",
"command": "uvx",
"args": [
"--from",
"mysql-mcp-server",
"mysql_mcp_server"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "your_username",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}
```
Note: Will need to install uv for this to work

### Debugging with MCP Inspector
While 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.
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
mcp>=1.0.0
mysql-connector-python>=9.1.0
PyMySQL
uv
6 changes: 4 additions & 2 deletions src/mysql_mcp_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
from pydantic import AnyUrl

# Configure logging
# Log to stderr to not interfere with STDIO stream
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
stream=sys.stderr
)
logger = logging.getLogger("mysql_mcp_server")

Expand Down Expand Up @@ -199,4 +201,4 @@ async def main():
raise

if __name__ == "__main__":
asyncio.run(main())
asyncio.run(main())