sql-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sql-mcplist databases and then select the 'sales' database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
SQL MCP Gateway (NestJS)
NestJS-based MCP server for MySQL with session-level database selection and SQL safety controls.
Features
MCP tools:
list_databasesconnect_mysql_userselect_databaseexecute_sql
Two transports:
HTTP (
/mcp) via streamable HTTP sessionsstdio (
--stdio) for command-based MCP auto-start
SQL controls:
SQL_MODE:SAFE|WRITE|FULLmode categories:
SAFE=>DQLWRITE=>DQL,DMLFULL=>DQL,DML,DDL,TCL,DCL
hard block on destructive statements like
DROP,TRUNCATE,ALTER DATABASE/SCHEMA,RENAME TABLE
Related MCP server: KatCoder MySQL MCP Server
Project Structure
src/
main.ts
app.module.ts
config/
sql/
mcp/
scripts/
run-stdio.shSetup
npm install
cp .env.example .env.env.example:
MCP_HOST=0.0.0.0
MCP_PORT=8787
MCP_PATH=/mcp
MCP_SERVER_NAME=sql-mcp
MCP_SERVER_VERSION=2.0.0
DATABASE_HOST=127.0.0.1
DATABASE_PORT=3306
SQL_MODE=SAFERun
HTTP mode (manual)
npm startEndpoint: http://localhost:8787/mcp
stdio mode (auto-start via command MCP)
Build once:
npm run buildThen run:
scripts/run-stdio.shOr:
node build/main.js --stdioMCP_TRANSPORT=stdio also enables stdio mode.
Cursor Config (~/.cursor/mcp.json)
Recommended: command mode (auto-start)
{
"mcpServers": {
"sql-mcp": {
"command": "/ABSOLUTE/PATH/TO/sql-mcp/scripts/run-stdio.sh",
"env": {
"MCP_SQL_USER": "your_mysql_user",
"MCP_SQL_PASSWORD": "your_mysql_password"
}
}
}
}Notes:
Replace
/ABSOLUTE/PATH/TO/sql-mcpwith your actual repo path.MCP_SQL_USER/MCP_SQL_PASSWORDare optional. If omitted, useconnect_mysql_userfrom chat.
Alternative: URL mode (manual server)
{
"mcpServers": {
"sql-mcp": {
"url": "http://localhost:8787/mcp",
"headers": {
"x-sql-user": "your_mysql_user",
"x-sql-password": "your_mysql_password"
}
}
}
}Use this only when the HTTP server is running.
Tool Workflow
If credentials are preconfigured (command env or URL headers)
list_databasesselect_databaseexecute_sql
If credentials are not preconfigured
connect_mysql_userselect_databaseexecute_sql
Security
Keep credentials only in user-level
~/.cursor/mcp.json.Do not commit project-level
.cursor/mcp.json.
This server cannot be deployed
Maintenance
Related MCP Connectors
The official MCP Server for the Mux API
- SupabaseOAuthcom.supabase
MCP server for interacting with the Supabase platform
MCP server for InsForge BaaS — database, storage, edge functions, and deployments
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA TypeScript-based MCP server that facilitates SQL query execution and MySQL database connectivity using environment variables.113 npmMIT
- FlicenseNot gradedqualityDmaintenanceA secure MySQL Model Context Protocol server that enables AI agents to interact with MySQL databases through standardized operations. Features comprehensive security with SQL injection prevention, connection pooling, and configurable tool access for database operations.1-
- FlicenseNot gradedqualityDmaintenanceA high-performance MCP server that enables AI assistants to safely interact with MySQL databases through secure CRUD operations, schema inspection, and parameterized queries with built-in SQL injection prevention.1-
- FlicenseBqualityDmaintenanceAn MCP server for MySQL that enables users to execute SQL queries, inspect table structures, and explore database schemas through a clean, SOLID-based architecture. It includes built-in security validations to protect against dangerous operations and ensure safe interaction with database resources.2-