Skip to main content
Glama

MCP SQL Server (Development)

A professional MCP server to connect any MCP-compatible LLM to a SQL database and execute:

  • Queries (SELECT, WITH, SHOW, etc.)

  • DML (INSERT, UPDATE, DELETE)

  • DDL (CREATE, ALTER, and optionally DROP/TRUNCATE)

This server is designed for personal use in assisted development.

Features

  • MCP protocol via stdio (compatible with MCP clients).

  • Multi-engine connection via SQLAlchemy (sqlite, postgresql, mysql, mssql, etc.).

  • MCP tools focused on daily operations:

    • sql_capabilities

    • sql_list_tables

    • sql_describe_table

    • sql_run

    • sql_run_script

  • Destructive DDL blocking by default (DROP/TRUNCATE blocked).

  • Configurable row and statement limits per script.

Related MCP server: FastMCP MySQL Server

Installation

python -m venv .venv
source .venv/bin/activate
pip install -e .

Configuration (environment variables)

Prefix: MCP_SQL_

  • MCP_SQL_DATABASE_URL: SQLAlchemy URL. Default: sqlite:///./dev.db

  • MCP_SQL_MAX_ROWS: maximum rows returned per query. Default: 200

  • MCP_SQL_MAX_SCRIPT_STATEMENTS: maximum statements per script. Default: 100

  • MCP_SQL_ALLOW_DESTRUCTIVE_DDL: true/false to allow DROP and TRUNCATE. Default: false

Example

export MCP_SQL_DATABASE_URL='postgresql+psycopg://dev_user:dev_pass@localhost:5432/devdb'
export MCP_SQL_MAX_ROWS=500
export MCP_SQL_ALLOW_DESTRUCTIVE_DDL=false

Running the server

mcp-sql-server

You can also run it as a module:

python -m mcp_sql_server.server

Double-click startup on Windows

The file start_mcp_sql_server.bat is included to facilitate startup:

  1. Automatically creates .venv (if it doesn't exist).

  2. Installs/updates dependencies.

  3. Starts the MCP server.

Just double-click that .bat file.

Configuration in an MCP client (generic example)

{
  "mcpServers": {
    "sql-dev": {
      "command": "mcp-sql-server",
      "env": {
        "MCP_SQL_DATABASE_URL": "sqlite:///./dev.db",
        "MCP_SQL_MAX_ROWS": "200",
        "MCP_SQL_ALLOW_DESTRUCTIVE_DDL": "false"
      }
    }
  }
}
  1. sql_capabilities to verify active configuration.

  2. sql_list_tables to explore the schema.

  3. sql_describe_table to inspect metadata.

  4. sql_run for specific queries or DML.

  5. sql_run_script for batches of controlled changes.

Best practices for assisted development

  • Use database users with minimal privileges.

  • Work on a local development DB or disposable snapshot.

  • Keep MCP_SQL_ALLOW_DESTRUCTIVE_DDL=false by default.

  • Version structural changes with migrations.

Security note

This project is not hardened for production. It is oriented toward local productivity in development environments.

Claude in VS Code guide

Check README_CLAUDE_VSCODE.md for a complete configuration and usage example.

Available Tools

5 tools
sql_capabilitiesB

Describe la configuración activa y operaciones soportadas.

Inputs: no named parameters. Returns: object

sql_describe_tableB

Describe columnas, PK, FK e índices de una tabla.

Inputs: table_name (required). Returns: object

sql_list_tablesB

Lista tablas y vistas disponibles en el esquema actual.

Inputs: no named parameters. Returns: object

sql_runB

Ejecuta una sentencia SQL individual usando parámetros nombrados opcionales.

Inputs: statement (required), params. Returns: object

sql_run_scriptA

Ejecuta múltiples sentencias SQL en secuencia; se detiene al primer error.

Inputs: script (required). Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: sql_capabilities provides metadata about the server, sql_describe_table describes a specific table's structure, sql_list_tables enumerates available tables/views, sql_run executes a single SQL statement, and sql_run_script handles multiple statements. There is no overlap or ambiguity between these functions.

    Naming Consistency5/5

    All tool names follow a consistent snake_case pattern with a 'sql_' prefix and descriptive verb_noun combinations (e.g., sql_list_tables, sql_run_script). This uniformity makes the tool set predictable and easy to understand.

    Tool Count5/5

    With 5 tools, the server is well-scoped for SQL operations. Each tool serves a specific, essential function in a database interaction workflow, from discovery (list_tables, describe_table) to execution (run, run_script), and configuration (capabilities). No tool feels redundant or missing.

    Completeness4/5

    The tool set covers core SQL operations effectively: listing and describing tables, running queries and scripts, and checking server capabilities. A minor gap is the lack of tools for schema modification (e.g., create/alter/drop tables) or transaction management, but agents can work around this using sql_run for such operations.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      An MCP server that connects AI assistants to Microsoft SQL Server databases, enabling schema exploration and read-only queries safely.
      49
      13 npm
      6
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A secure and efficient MCP server for MySQL database operations, enabling LLMs to execute SQL queries with read-only access by default and optional write permissions.
      16 PyPI
      3
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A multi-database MCP server that enables LLMs to safely interact with MySQL, PostgreSQL, SQLite, and others through a unified tool interface, with permission modes and schema resources.
      10
      8 npm
      43
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      A read-only MCP server that exposes SQL database access to LLMs, supporting multiple database types, compact columnar results, pagination, and file export.
      7
      13 npm
      MIT