{"id":15358,"library":"mssql-mcp-server","title":"MSSQL Model Context Protocol Server","description":"The `mssql-mcp-server` package provides a Model Context Protocol (MCP) server specifically designed for Microsoft SQL Server, enabling comprehensive database schema exploration and modernization planning. Currently at version 1.2.2, this server facilitates detailed analysis of database structures, including tables, views, stored procedures, triggers, and functions. It leverages the `tedious` library for pure JavaScript connectivity, supporting crucial features like Windows Authentication (NTLM), which necessitates explicit domain credentials through environment variables for secure, non-interactive background processes. Key differentiators include its extensive suite of 29 analytical tools, capabilities for extracting full SQL source code from stored procedures for business logic analysis, and a focus on assisting with modernization efforts for applications like Classic ASP to modern .NET/Angular architectures. While a specific release cadence isn't detailed, the project appears actively maintained with recent updates focused on enhancing core analysis capabilities.","status":"active","version":"1.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/vicagbasi/mssql-mcp","tags":["javascript","mcp","model-context-protocol","mssql","sql-server","database","tedious","microsoft-sql-server","typescript"],"install":[{"cmd":"npm install mssql-mcp-server","lang":"bash","label":"npm"},{"cmd":"yarn add mssql-mcp-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add mssql-mcp-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core library for pure JavaScript SQL Server connectivity, including Windows Authentication (NTLM).","package":"tedious"}],"imports":[{"note":"The primary class to instantiate and configure the MCP server. Package ships with TypeScript types, favoring ESM imports.","wrong":"const MssqlMcpServer = require('mssql-mcp-server');","symbol":"MssqlMcpServer","correct":"import { MssqlMcpServer } from 'mssql-mcp-server';"},{"note":"Type definition for the server configuration options. Use `type` import for clarity and bundler optimization.","wrong":"import { MssqlMcpServerOptions } from 'mssql-mcp-server';","symbol":"MssqlMcpServerOptions","correct":"import type { MssqlMcpServerOptions } from 'mssql-mcp-server';"}],"quickstart":{"code":"import { MssqlMcpServer } from 'mssql-mcp-server';\nimport * as dotenv from 'dotenv'; // For local development, install with `npm install dotenv`\n\ndotenv.config(); // Load environment variables from .env file\n\n// Configure SQL Server connection details using environment variables\nconst SQL_SERVER_HOST = process.env.SQL_SERVER_HOST ?? 'localhost';\nconst SQL_SERVER_PORT = parseInt(process.env.SQL_SERVER_PORT ?? '1433', 10);\nconst SQL_SERVER_USER = process.env.SQL_SERVER_USER ?? ''; // For NTLM Windows Authentication\nconst SQL_SERVER_PASSWORD = process.env.SQL_SERVER_PASSWORD ?? ''; // For NTLM\nconst SQL_SERVER_DOMAIN = process.env.SQL_SERVER_DOMAIN ?? ''; // For NTLM\nconst SQL_SERVER_DATABASE = process.env.SQL_SERVER_DATABASE ?? 'master';\nconst SERVER_PORT = parseInt(process.env.MCP_SERVER_PORT ?? '3000', 10); // Port for the MCP server itself\n\nasync function startMcpServer() {\n  if (!SQL_SERVER_USER || !SQL_SERVER_PASSWORD || !SQL_SERVER_DOMAIN) {\n    console.warn(\"WARNING: NTLM credentials (SQL_SERVER_USER, SQL_SERVER_PASSWORD, SQL_SERVER_DOMAIN) are not fully set. Windows Authentication might fail.\");\n  }\n\n  try {\n    // Instantiate the MCP server with a default connection\n    const server = new MssqlMcpServer({\n      connections: {\n        default: {\n          server: SQL_SERVER_HOST,\n          port: SQL_SERVER_PORT,\n          userName: SQL_SERVER_USER,\n          password: SQL_SERVER_PASSWORD,\n          domain: SQL_SERVER_DOMAIN,\n          options: {\n            database: SQL_SERVER_DATABASE,\n            encrypt: true, // Recommended for Azure SQL DB and modern instances\n            trustServerCertificate: true // Set to false in production if using trusted certificates\n          }\n        }\n      },\n      serverPort: SERVER_PORT\n    });\n\n    await server.start();\n    console.log(`MSSQL MCP Server started successfully on port ${SERVER_PORT}`);\n\n    // --- Simulate an external client (e.g., an AI agent) calling a tool ---\n    console.log('\\n--- Simulating API call to test_connection tool ---');\n    const toolCallResponse = await fetch(`http://localhost:${SERVER_PORT}/api/tool`, {\n      method: 'POST',\n      headers: { 'Content-Type': 'application/json' },\n      body: JSON.stringify({\n        toolName: 'test_connection',\n        toolArgs: { connectionName: 'default' }\n      })\n    });\n\n    const result = await toolCallResponse.json();\n    console.log('Result from test_connection:', result);\n\n  } catch (error) {\n    console.error('Failed to start MSSQL MCP Server or call tool:', error);\n    process.exit(1);\n  }\n}\n\nstartMcpServer();","lang":"typescript","description":"This quickstart demonstrates how to programmatically initialize and start the `mssql-mcp-server` using environment variables for SQL Server connection details, including NTLM authentication. It then shows a hypothetical HTTP POST request to the running server to execute the `test_connection` tool, simulating how an external client or AI agent would interact with the server's API."},"warnings":[{"fix":"Ensure `SQL_SERVER_USER`, `SQL_SERVER_PASSWORD`, and `SQL_SERVER_DOMAIN` environment variables are correctly set for the process running the MCP server.","message":"When using Windows Authentication (NTLM), the server requires explicit environment variables for `SQL_SERVER_USER`, `SQL_SERVER_PASSWORD`, and `SQL_SERVER_DOMAIN`. Running as a background process, it cannot access the current user's interactive Windows session for authentication. Incorrect or missing credentials will lead to connection failures.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review `trustServerCertificate` option in `MssqlMcpServerOptions`. For production, ensure valid SSL certificates are used and configured, setting `trustServerCertificate: false`.","message":"For development environments, `trustServerCertificate: true` might be used for convenience. In production, this should generally be `false` and a trusted certificate explicitly provided or validated to prevent 'man-in-the-middle' attacks.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Adhere to the documented limitations of specific tools. For larger data extraction, consider direct SQL client access or alternative tools. Use `execute_query` only for read-only queries.","message":"Certain database tools, such as `execute_query` and `sample_data`, have built-in safety limits (e.g., read-only, max 20 rows, max 100 rows respectively) to prevent accidental data modification or excessive resource consumption. Attempting to bypass these or expecting larger result sets may lead to unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Verify `SQL_SERVER_USER`, `SQL_SERVER_PASSWORD`, and `SQL_SERVER_DOMAIN` environment variables match valid domain credentials with access to the SQL Server instance. Check SQL Server logs for detailed login failure reasons.","cause":"Incorrect or missing Windows Authentication (NTLM) credentials (username, password, or domain) provided via environment variables, or the specified user lacks database permissions.","error":"Login failed for user 'DOMAIN\\Username'."},{"fix":"Confirm `SQL_SERVER_HOST` and `SQL_SERVER_PORT` environment variables are correct. Check network connectivity, firewall rules (both client and server), and ensure the SQL Server instance is running and configured to accept remote connections.","cause":"The SQL Server instance is unreachable due to incorrect host/port, network firewall blocking the connection, or the SQL Server service not running.","error":"ConnectionError: Failed to connect to localhost:1433 - Could not connect (Error: connect ECONNREFUSED ::1:1433)"},{"fix":"Ensure the `MssqlMcpServer` is initialized with a valid `MssqlMcpServerOptions` object, specifically providing at least one connection configuration under the `connections` property.","cause":"The `MssqlMcpServer` constructor was called without the required `connections` object in its options, or the options object itself was `undefined`.","error":"TypeError: Cannot read properties of undefined (reading 'connections')"}],"ecosystem":"npm"}