npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcp-sql-server

v1.0.1

Published

MCP server for SQL database queries

Readme

MCP SQL Server

A Model Context Protocol (MCP) server that provides SQL Server database query capabilities.

Features

  • SQL Server database support using tedious driver
  • No native dependencies - pure JavaScript implementation
  • Simple query tool for executing SQL statements
  • Environment variable based configuration
  • Support for encrypted and unencrypted connections

Installation

npm install
npm run build

Configuration

Configure the server using environment variables:

  • DB_HOST: SQL Server host (default: localhost)
  • DB_PORT: SQL Server port (default: 1433)
  • DB_DATABASE (required): Database name
  • DB_USER (required): Database user
  • DB_PASSWORD: Database password
  • DB_TRUST_SERVER_CERTIFICATE: Set to true to trust server certificate (default: false)
  • DB_ENCRYPT: Set to false to disable encryption (default: true)

Usage

Basic Example

DB_HOST=localhost \
DB_PORT=1433 \
DB_DATABASE=mydb \
DB_USER=sa \
DB_PASSWORD=MyPassword123! \
npm start

With Trusted Certificate

DB_HOST=sqlserver.example.com \
DB_DATABASE=production \
DB_USER=appuser \
DB_PASSWORD=SecurePass \
DB_TRUST_SERVER_CERTIFICATE=true \
npm start

Without Encryption (for local development)

DB_HOST=localhost \
DB_DATABASE=testdb \
DB_USER=sa \
DB_PASSWORD=DevPassword \
DB_ENCRYPT=false \
npm start

MCP Integration

This server provides one tool:

  • query: Execute SQL queries against the connected SQL Server database
    • Parameters:
      • sql (string): The SQL query to execute
    • Returns: JSON formatted query results

Example Queries

-- Select data
SELECT TOP 10 * FROM Users

-- Join tables
SELECT o.OrderID, c.CustomerName, o.OrderDate
FROM Orders o
INNER JOIN Customers c ON o.CustomerID = c.CustomerID

-- Aggregate data
SELECT COUNT(*) as TotalOrders, SUM(Amount) as TotalRevenue
FROM Orders
WHERE OrderDate >= '2024-01-01'

Development

# Install dependencies
npm install

# Run in development mode
DB_HOST=localhost \
DB_DATABASE=testdb \
DB_USER=sa \
DB_PASSWORD=TestPass123! \
npm run dev

# Build for production
npm run build

Troubleshooting

Connection Issues

  1. Login failed: Ensure SQL Server authentication is enabled and credentials are correct
  2. Certificate error: Set DB_TRUST_SERVER_CERTIFICATE=true for self-signed certificates
  3. Encryption error: Set DB_ENCRYPT=false for older SQL Server versions or local development
  4. Network error: Check firewall settings and ensure SQL Server is listening on the correct port

SQL Server Configuration

Ensure your SQL Server instance:

  • Has SQL Server authentication enabled (not just Windows authentication)
  • Is configured to accept TCP/IP connections
  • Has the necessary firewall rules configured

License

MIT