Registry / database / mcp-sql-server

mcp-sql-server

JSON →
library1.0.1jsnpmunverified

A Model Context Protocol (MCP) server that provides SQL Server database query capabilities using the tedious driver. Current stable version is 1.0.1, released with no formal release cadence. It enables AI agents (via MCP) to execute SQL queries on SQL Server databases. Key differentiators: pure JavaScript implementation with no native dependencies, environment-based configuration, and support for encrypted/unencrypted connections. Requires Node.js >=18, ESM only. Suitable for local development and production workloads with trusted certificates.

npm install mcp-sql-server
INSTALL
IMPORT
SIG · MCP-SQL-SERVER
M
mcp-sql-server
databasejavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Server
import { Server } from '@modelcontextprotocol/sdk/server/index.js'
import { Server } from '@modelcontextprotocol/sdk'
ESM-only; subpath import required.
StdioServerTransport
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
import { StdioServerTransport } from '@modelcontextprotocol/sdk'
ESM-only; subpath import required.
CallToolRequestSchema
import { CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js'
import { CallToolRequestSchema } from '@modelcontextprotocol/sdk'
ESM-only; subpath import required.

Runs the MCP SQL Server with environment-based configuration, connecting to a local SQL Server instance.

# Install and run with environment variables # Ensure you have Node.js >=18 npm install mcp-sql-server # Start the server with required env vars DB_HOST=localhost \ DB_PORT=1433 \ DB_DATABASE=mydb \ DB_USER=sa \ DB_PASSWORD=MyPassword123! \ npm start # Or run directly with node DB_HOST=localhost \ DB_DATABASE=mydb \ DB_USER=sa \ DB_PASSWORD=MyPassword123! \ node build/index.js # Configure MCP client to use this server with StdioServerTransport # The server exposes a 'query' tool that accepts a 'sql' string parameter
Debug
Known issues
breakingESM-only package. Must use import syntax, not require().
fix
Use ES module imports (import ... from ...) and ensure 'type': 'module' in package.json.
affects: >=1.0.0
gotchaAll environment variables except DB_PORT and DB_TRUST_SERVER_CERTIFICATE are strings. Do not quote boolean values.
fix
Set DB_TRUST_SERVER_CERTIFICATE=true (not 'true') and DB_PORT=1433 (not '1433').
affects: >=1.0.0
deprecatedThe package does not support Windows Authentication; only SQL Server Authentication.
fix
Configure SQL Server to enable mixed mode authentication.
affects: >=1.0.0
gotchaDefault encryption (DB_ENCRYPT=true) may fail with self-signed certificates. Set DB_TRUST_SERVER_CERTIFICATE=true to bypass.
fix
Set DB_ENCRYPT=false for local development or DB_TRUST_SERVER_CERTIFICATE=true for self-signed certs.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module '@modelcontextprotocol/sdk/server/index.js'
Missing or incorrect MCP SDK dependency.
fix
Run 'npm install @modelcontextprotocol/sdk' or ensure it is listed in package.json and node_modules are installed.
Error: ConnectionError: Failed to connect to localhost:1433 - getaddrinfo ENOTFOUND localhost
SQL Server host/port unreachable or DNS resolution failure.
fix
Verify DB_HOST and DB_PORT are correct, and that SQL Server is running and accessible.
Error: ConnectionError: Login failed for user 'sa'.
Invalid credentials or SQL Server authentication not enabled.
fix
Check DB_USER and DB_PASSWORD environment variables. Enable SQL Server Authentication (mixed mode) in SQL Server.
Error: ConnectionError: The server certificate did not match the expected certificate
Self-signed or mismatched certificate, and DB_TRUST_SERVER_CERTIFICATE is not set to true.
fix
Set DB_TRUST_SERVER_CERTIFICATE=true to trust all certificates, or install a valid certificate.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
@modelcontextprotocol/sdkrequiredMCP server framework
tediousrequiredSQL Server driver
Agent activity
4 hits · last 30 days
node
4
Resources
mcp-sql-server — npm install mcp-sql-server · libregistry