Releases: gunvertugberk/mcp-sqlserver
Release list
v1.3.2 — Comprehensive Test Suite
Added
- Comprehensive test suite — 238 tests across 10 test files using Vitest
utils/security.test.ts(44 tests) — escapeIdentifier, validateQuery, isDatabaseAllowed, isSchemaAllowed, applyMasking, ensureRowLimitutils/formatter.test.ts(14 tests) — markdown table formatting, ISO dates, NULL handling, truncation, JSON outputtools/schema.test.ts(22 tests) — all 9 schema discovery tools with access control and schema filteringtools/query.test.ts(21 tests) — execute_query/execute_mutation with validation, masking, multi-servertools/ddl.test.ts(11 tests) — DDL gating, blocked keywords, database accesstools/procedure.test.ts(18 tests) — list/describe/execute_procedure with readonly gatingtools/performance.test.ts(18 tests) — query plans, active queries, table/index stats, server/db infotools/dba.test.ts(48 tests) — wait stats, deadlocks, blocking, backups, query store, health checktools/utility.test.ts(42 tests) — compare_schemas, generate_code, ER diagram, sample_table, export_query
npm testandnpm run test:watchscripts- Test helper utilities (
tests/tools/_helpers.ts)
Changed
- Updated project docs (CLAUDE.md, workflow.md, tool-authoring.md, coding-standards.md) to reflect test availability
Full Changelog: v1.3.1...v1.3.2
v1.3.1 — Security Hardening & Error Handling
Security
- Database allow/block list bypass fixed —
execute_query,execute_mutation,execute_ddl, andexport_querynow enforceisDatabaseAllowedwhen the optionaldatabaseparameter is supplied get_query_planhardened — now extractssecurityfromresolveServer, enforcesisDatabaseAllowedandvalidateQueryon user-supplied SQL- Numeric interpolation sanitized —
get_wait_stats,get_space_usage,get_backup_history,get_query_store_stats,sample_table,generate_insert_scripts, andgenerate_test_datanow validatetop/countas safe integers before SQL interpolation describe_procedureparameterized —OBJECT_IDcall now uses@parambinding instead of manual single-quote escaping- Schema allow/block list enforced —
get_foreign_keys,get_indexes,get_constraints,get_triggers, anddescribe_procedurenow checkisSchemaAllowed
Fixed
- All
schema.tsandprocedure.tshandlers now wrapped intry/catch— errors return structured{ isError: true }instead of crashing the MCP transport execute_ddlnow acceptsTRUNCATEstatements (previously rejected by regex despite passingvalidateQuery)execute_procedure— added separateschemaparameter and escapes schema/procedure independently (previouslyescapeIdentifierwrapped the entire dotted name as one identifier)execute_mutation— regex type check now runs beforevalidateQuery(consistent withexecute_ddlordering)export_query— replaced dynamicawait import()of security utilities with static importsgenerateCreateTablehelper — usesescapeIdentifier()instead of raw bracket interpolation
Full Changelog: v1.3.0...v1.3.1
v1.3.0 — Multi-Server Support
Multi-Server Support
Define multiple named SQL Server connections (dev, staging, prod) in a single config file and switch between them with the server parameter on any tool call. Fully backward compatible — existing single-server configs work without any changes.
New Config Format
Use connections (plural) to define multiple servers:
defaultServer: dev
connections:
dev:
host: dev-server.example.com
database: MyDatabase
authentication:
type: sql
user: sa
password: DevPass123
security:
mode: admin
maxRowCount: 5000
prod:
host: prod-server.example.com
database: MyDatabase
authentication:
type: sql
user: readonly_user
password: ProdReadOnly
security:
mode: readonly
blockedDatabases: [master, msdb, tempdb, model]
# Global security defaults (applied to all servers unless overridden)
security:
maxRowCount: 1000
blockedKeywords: [xp_cmdshell, SHUTDOWN, DROP DATABASE]New Tool
| Tool | Description |
|---|---|
list_servers |
List all configured server connections with host, database, auth type, and security mode |
server Parameter on All Tools
Every existing tool now accepts an optional server parameter:
list_tables(server: "prod", database: "MyDatabase")
health_check(server: "dev")
execute_query(server: "prod", sql: "SELECT TOP 10 * FROM Orders")
compare_schemas(server: "dev", source_database: "DevDB", target_database: "StagingDB")
Omit server to use the defaultServer from config.
Per-Server Security
Each server can have its own security configuration:
- Security mode (readonly / readwrite / admin)
- Max row count
- Blocked databases
- Allowed/blocked schemas
- Column masking rules
Global security block serves as defaults; per-server security overrides specific settings.
Architecture
- Connection pools are now keyed by server name — each server gets its own dedicated pool
- DDL tools are registered if any configured server allows DDL (per-server permission check inside each handler)
- Environment variables (
MSSQL_HOST,MSSQL_PASSWORD, etc.) apply to the default server only
Files Changed
| File | Change |
|---|---|
src/config.ts |
New AppConfig type with servers map + resolveServer() helper + multi-server config loader |
src/database.ts |
Pool Map<string, ConnectionPool> keyed by server name |
src/server.ts |
New list_servers tool, DDL registration checks all servers |
src/index.ts |
Startup logging lists all configured servers |
src/tools/*.ts |
All 38 tools now accept optional server parameter |
config.example.yaml |
Multi-server configuration example added |
README.md |
v1.3 What's New, Server Management section, Multi-Server Configuration docs |
Stats
- 38 tools (37 existing + 1 new
list_servers) - 15 files changed, +681 / -245 lines
- 100% backward compatible — single-server
connectionformat still works
Full Changelog: v1.2.3...v1.3.0
v1.2.2 — 16 New Tools, SQL Injection Fix, HTTP Transport
What's New
This is a major feature release adding 16 new tools (total: 37), critical security improvements, and HTTP transport support.
Security
- SQL injection protection — All queries now use parameterized inputs (
@param) and escaped identifiers ([name]). Previously, user-provided values like table/schema names were interpolated via string replacement, which was vulnerable to injection. This is now fully fixed across all 37 tools. escapeIdentifier()helper — Centralized SQL Server bracket escaping for all object names.
New DBA & Performance Tools (9)
| Tool | Description |
|---|---|
get_wait_stats |
Top server wait statistics — identifies CPU, I/O, lock bottlenecks |
get_deadlocks |
Recent deadlock events from the system_health Extended Events session |
get_blocking_chains |
Current blocking chains — which sessions are blocking others |
get_long_transactions |
Long-running open transactions that may be holding locks |
get_space_usage |
Detailed disk space usage by table (data, index, unused) |
get_backup_history |
Recent backup history: type, size, duration, device path |
get_query_store_stats |
Top resource-consuming queries from Query Store (SQL Server 2016+), sortable by CPU/duration/reads/writes/executions |
rebuild_index |
Rebuild or reorganize fragmented indexes (requires admin mode) |
health_check |
Connection health check with latency, server version, active sessions, batch requests/sec |
New Developer Utility Tools (6)
| Tool | Description |
|---|---|
compare_schemas |
Compare two databases side-by-side — tables only in source/target, column differences, type mismatches. Perfect for dev vs prod comparison. |
generate_code |
Generate TypeScript interfaces, C# classes, or CREATE TABLE scripts from any table's schema. Proper type mapping (e.g. money → decimal, nvarchar → string, bit → boolean). |
generate_insert_scripts |
Generate INSERT statements from existing table data — for migration scripts, seed data, or reference table backups. Skips identity/computed columns automatically. |
generate_er_diagram |
Generate Mermaid ER diagrams from foreign key relationships. Paste into GitHub, Notion, VS Code, or any Mermaid renderer. |
generate_test_data |
Generate INSERT statements with realistic fake data based on column names and types. Smart heuristics for email, phone, name, city, price, etc. |
sample_table |
Random sample of rows using NEWID() — helps AI assistants understand data patterns without full table scans. |
New Query Tool (1)
| Tool | Description |
|---|---|
export_query |
Export SELECT query results as CSV or JSON format with proper escaping and type handling. |
Improvements
- ISO date formatting — Dates now display as
2025-01-27or2025-01-27 14:30:00instead of raw JavaScript Date strings likeThu Jan 27 2025 02:00:00 GMT+0200. - Streamable HTTP transport — Start the server with
--http <port>for remote hosting. Endpoints:/mcp(MCP protocol) and/health(health check). Includes CORS support. - Comprehensive README — Detailed tool documentation with usage examples, authentication comparison table, collapsible MCP client configs.
Bug Fixes
- Fixed
get_long_transactions— invalid column reference (t.name→at.name)
Files Changed
src/tools/dba.ts— New file: 9 DBA tools + test data generator + health checksrc/tools/utility.ts— New file: schema diff, code gen, INSERT scripts, ER diagram, sampling, exportsrc/tools/schema.ts— Parameterized queries + escapeIdentifier for all 9 toolssrc/tools/performance.ts— Parameterized queries + escapeIdentifier for all 7 toolssrc/tools/procedure.ts— Parameterized queries + escapeIdentifier for all 3 toolssrc/tools/query.ts— escapeIdentifier for USE statementssrc/tools/ddl.ts— escapeIdentifier for USE statementssrc/utils/security.ts— AddedescapeIdentifier()exportsrc/utils/formatter.ts— AddedformatValue()with ISO date formattingsrc/server.ts— Register new tool modules, version bump to 1.2.0src/index.ts— Added--httpflag and Streamable HTTP transport
Full Changelog
21 tools → 37 tools | v1.1.1 → v1.2.2