🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@atom8n/mcp-mssql

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atom8n/mcp-mssql

An MCP server for executing queries against Microsoft SQL Server

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
3
-40%
Maintainers
1
Weekly downloads
 
Created
Source

MCP Mssql Server

An MCP server that exposes a single execute_sql tool for running parameterless SQL statements against Microsoft SQL Server using the native msnodesqlv8 driver. It is intended for MCP-compatible clients that need direct database access over stdio without exposing credentials in logs.

Features

  • SQL Server Native Driver: Uses msnodesqlv8 and ensures an explicit driver prefix on every connection string.
  • Secure Logging: Masks password fields when echoing the effective connection string to stderr.
  • Flexible Connection Sources: Pulls the connection string from MSSQL_CONNECTION_STRING or an override supplied with each request.
  • Structured Results: Returns rowsAffected counts and all recordsets from the query for easy downstream parsing.
  • Stdio Transport: Ships as an MCP stdio server so it can be dropped into any MCP client configuration.

Installation

npm install @atom8n/mcp-mssql

MCP Configuration

Add the following configuration to your MCP client:

{
  "mcp-mssql": {
    "command": "npx",
    "args": [
      "@atom8n/mcp-mssql"
    ]
  }
}

Available Tools

execute_sql

Execute a SQL statement against Microsoft SQL Server.

Parameters:

  • query (required): T-SQL command text to execute.
  • connectionString (optional): Overrides the MSSQL_CONNECTION_STRING environment variable for this call.

The tool automatically injects Driver={SQL Server Native Client 11.0} when the provided connection string omits a driver segment, so both DSN-style and bare connection strings work out of the box.

Usage Examples

Run a query with the default connection string

{
  "tool": "execute_sql",
  "arguments": {
    "query": "SELECT TOP (5) name FROM sys.databases ORDER BY name"
  }
}

Override the connection string per call

{
  "tool": "execute_sql",
  "arguments": {
    "query": "EXEC dbo.RefreshMaterializedView @name = 'daily_snapshot'",
    "connectionString": "Server=sql.internal;Database=Ops;Trusted_Connection=yes;"
  }
}

Response Format

Requests return JSON text via MCP content with the following shape:

{
  "rowsAffected": [123],
  "recordsets": [
    [
      { "name": "master" },
      { "name": "model" }
    ]
  ]
}

Development

Prerequisites

  • Node.js 18+
  • TypeScript 5.6+
  • npm

Setup

# Clone the repository
git clone <repository-url>
cd mcp-mssql

# Install dependencies
npm install

# Build the project
npm run prepare

Project Structure

├── src/
│   ├── index.mts          # MCP server implementation
│   └── execute_sql.test.mts # Ad-hoc SQL runner for local verification
├── lib/
│   ├── index.mjs          # Compiled JavaScript
│   ├── index.mjs.map      # Source map
│   └── index.d.mts        # TypeScript declarations
├── package.json           # Package configuration
├── tsconfig.json          # TypeScript configuration
└── eslint.config.mjs      # ESLint configuration

Build Process

The project uses TypeScript with the following build configuration:

  • Target: ES2015
  • Module: CommonJS
  • Output: lib/ directory
  • Source Maps: Enabled
  • Declarations: Generated

Scripts

  • prepare: Compiles TypeScript and makes the binary executable
  • inspect: Launches the MCP inspector against the compiled server
  • test:sql: Runs src/execute_sql.test.mts with ts-node for manual checks

Dependencies

Runtime Dependencies

  • @modelcontextprotocol/sdk: MCP server framework
  • dotenv: Environment variable loader
  • msnodesqlv8: Native SQL Server driver
  • rimraf: File system utilities
  • spawn-rx: Process spawning utilities

Development Dependencies

  • @types/node: Node.js type definitions
  • shx: Shell utilities for cross-platform compatibility
  • ts-node: TypeScript execution
  • typescript: TypeScript compiler

License

MIT License - see COPYING file for details.

Contributing

Please read CODE_OF_CONDUCT.md for our code of conduct and contribution guidelines.

Version

Current version: 1.0.0

Support

For issues and feature requests, please use the project's issue tracker.

FAQs

Package last updated on 17 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts