Skip to main content
Glama

SQL MCP Gateway (NestJS)

NestJS-based MCP server for MySQL with session-level database selection and SQL safety controls.

Features

  • MCP tools:

    • list_databases

    • connect_mysql_user

    • select_database

    • execute_sql

  • Two transports:

    • HTTP (/mcp) via streamable HTTP sessions

    • stdio (--stdio) for command-based MCP auto-start

  • SQL controls:

    • SQL_MODE: SAFE | WRITE | FULL

    • mode categories:

      • SAFE => DQL

      • WRITE => DQL, DML

      • FULL => 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.sh

Setup

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=SAFE

Run

HTTP mode (manual)

npm start

Endpoint: http://localhost:8787/mcp

stdio mode (auto-start via command MCP)

Build once:

npm run build

Then run:

scripts/run-stdio.sh

Or:

node build/main.js --stdio

MCP_TRANSPORT=stdio also enables stdio mode.

Cursor Config (~/.cursor/mcp.json)

{
  "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-mcp with your actual repo path.

  • MCP_SQL_USER / MCP_SQL_PASSWORD are optional. If omitted, use connect_mysql_user from 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)

  1. list_databases

  2. select_database

  3. execute_sql

If credentials are not preconfigured

  1. connect_mysql_user

  2. select_database

  3. execute_sql

Security

  • Keep credentials only in user-level ~/.cursor/mcp.json.

  • Do not commit project-level .cursor/mcp.json.

F
license - not found
-
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    -
    quality
    D
    maintenance
    A 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
  • F
    license
    -
    quality
    D
    maintenance
    A 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
  • F
    license
    B
    quality
    C
    maintenance
    An 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

View all related MCP servers

Related MCP Connectors

  • MCP server for managing Prisma Postgres.

  • MCP (Model Context Protocol) server for Appwrite

  • MCP server for interacting with the Supabase platform

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/arpitg-cashify/sql-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server