MSSQL-MCP-Node

MSSQL-MCP-Node

Node.js MCP server for SQL Server with auto-detected single or multi-database support.

4
Stars
1
Forks
0
Releases

Overview

This project is a Node.js implementation of the Model Context Protocol (MCP) server for Microsoft SQL Server databases. It exposes database tables as resources and provides tools to execute SQL queries and retrieve table schemas. The server supports automatic configuration mode detection and can operate in either single-database mode (configured with MSSQL_SERVER, MSSQL_DATABASE, etc.) or multi-database mode (configured with MSSQL_<DBNAME>_* variables for multiple databases). At runtime, it auto-detects the active mode and exposes the same MCP REST/STDIO interface in both modes. In multi-database mode, any database names can be used following the MSSQL_<YOUR_CUSTOM_NAME>_* pattern; databases are exposed under lowercase keys (e.g., analytics, customers). If no dbKey is provided in a request, the server uses the first configured database alphabetically. The project also includes an Express HTTP API for local testing, alongside the MCP STDIO mode for integration with clients like Claude Desktop or VS Code. It leverages Zod for input validation, uses parameterized queries for security, and provides tooling to manage resources, execute SQL, and obtain table schemas.

Details

Owner
mihai-dulgheru
Language
JavaScript
License
MIT License
Updated
2025-12-07

Features

Auto-detect Configuration Mode

Automatically determines whether to use single- or multi-database mode at runtime based on environment variables.

Resource Management

Access SQL Server tables as resources via the MCP interface.

SQL Query Execution

Execute SQL queries against the connected database(s) and return results.

Schema Information

Retrieve metadata and schema details for database tables.

MCP Protocol Support

Communicates via STDIO using the Model Context Protocol SDK.

HTTP API

Express-based API for local testing and development.

Enhanced Validation

Uses Zod for robust input validation with clear error messages.

Security Features

Parameterized queries and SQL injection protection with safe error handling.

Audience

DevelopersBuild MCP-based tooling to interact with SQL Server, expose tables as resources, and test via Express or MCP STDIO.

Tags

MSSQLMCPNode.jsSQL ServerMulti-databaseSingle-databaseExpressZod