MCP SQL Server
Provides SQL database connectivity and query execution capabilities for MySQL databases through SQLAlchemy, enabling AI agents to run SELECT queries, DML operations (INSERT, UPDATE, DELETE), and DDL statements (CREATE, ALTER) with configurable safety restrictions.
Provides SQL database connectivity and query execution capabilities for PostgreSQL databases through SQLAlchemy, enabling AI agents to run SELECT queries, DML operations (INSERT, UPDATE, DELETE), and DDL statements (CREATE, ALTER) with configurable safety restrictions.
Provides SQL database connectivity and query execution capabilities for SQLite databases through SQLAlchemy, enabling AI agents to run SELECT queries, DML operations (INSERT, UPDATE, DELETE), and DDL statements (CREATE, ALTER) with configurable safety restrictions.
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., "@MCP SQL Server show me the top 10 customers by total purchase amount"
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.
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 optionallyDROP/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_capabilitiessql_list_tablessql_describe_tablesql_runsql_run_script
Destructive DDL blocking by default (
DROP/TRUNCATEblocked).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.dbMCP_SQL_MAX_ROWS: maximum rows returned per query. Default:200MCP_SQL_MAX_SCRIPT_STATEMENTS: maximum statements per script. Default:100MCP_SQL_ALLOW_DESTRUCTIVE_DDL:true/falseto allowDROPandTRUNCATE. 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=falseRunning the server
mcp-sql-serverYou can also run it as a module:
python -m mcp_sql_server.serverDouble-click startup on Windows
The file start_mcp_sql_server.bat is included to facilitate startup:
Automatically creates
.venv(if it doesn't exist).Installs/updates dependencies.
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"
}
}
}
}Recommended workflow
sql_capabilitiesto verify active configuration.sql_list_tablesto explore the schema.sql_describe_tableto inspect metadata.sql_runfor specific queries or DML.sql_run_scriptfor 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=falseby 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 toolssql_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
Scored across 5 tools
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.
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.
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.
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
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Draxlr's remote MCP server connects AI assistants to your SQL databases and dashboards. Explore schemas, run read-only queries, manage saved queries and dashboards, and export results, all with row-level security so each user sees only their own data.
Related MCP Servers
- AlicenseBqualityDmaintenanceAn MCP server that connects AI assistants to Microsoft SQL Server databases, enabling schema exploration and read-only queries safely.4913 npm6MIT
- AlicenseNot gradedqualityDmaintenanceA 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 PyPI3MIT
- AlicenseAqualityDmaintenanceA 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.108 npm43MIT
- AlicenseAqualityBmaintenanceA read-only MCP server that exposes SQL database access to LLMs, supporting multiple database types, compact columnar results, pagination, and file export.713 npmMIT