c0h1b4
MCP Serverc0h1b4public

mssql mcp server

**摘要**:MSSQL MCP Server 是一个用于连接 Microsoft SQL Server 的 npm 包,通过 MCP 实现 SQL 查询执行和数据库管理。

Repository Info

14
Stars
11
Forks
14
Watchers
2
Issues
TypeScript
Language
MIT License
License

About This Server

**摘要**:MSSQL MCP Server 是一个用于连接 Microsoft SQL Server 的 npm 包,通过 MCP 实现 SQL 查询执行和数据库管理。

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

MSSQL MCP Server

smithery badge

A Model Context Protocol (MCP) server for connecting to Microsoft SQL Server databases. This server provides tools for executing SQL queries and managing database connections.

Version Notice: This project has been upgraded to use Model Context Protocol SDK 1.9.0. See UPGRADE.md for details.

Installation

Installing via Smithery

To install MSSQL MCP Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @c0h1b4/mssql-mcp-server --client claude

Manual Installation

npm install mssql-mcp-server

Usage

Add the server to your MCP settings configuration file:

{
  "mcpServers": {
    "mssql": {
      "command": "mssql-mcp-server",
      "env": {
        "MSSQL_CONNECTION_STRING": "Server=localhost;Database=master;User Id=sa;Password=yourpassword;",
        // Or individual connection parameters:
        "MSSQL_HOST": "localhost",
        "MSSQL_PORT": "1433",
        "MSSQL_DATABASE": "master",
        "MSSQL_USER": "sa",
        "MSSQL_PASSWORD": "yourpassword",
        "MSSQL_ENCRYPT": "false",
        "MSSQL_TRUST_SERVER_CERTIFICATE": "true"
      }
    }
  }
}

Tools

query

Execute a SQL query on a MSSQL database.

Parameters

  • connectionString (string, optional): Full connection string (alternative to individual parameters)
  • host (string, optional): Database server hostname
  • port (number, optional): Database server port (default: 1433)
  • database (string, optional): Database name (default: master)
  • username (string, optional): Database username
  • password (string, optional): Database password
  • query (string, required): SQL query to execute
  • encrypt (boolean, optional): Enable encryption (default: false)
  • trustServerCertificate (boolean, optional): Trust server certificate (default: true)

Either connectionString OR (host + username + password) must be provided.

Example

const result = await use_mcp_tool({
  server_name: 'mssql',
  tool_name: 'query',
  arguments: {
    host: 'localhost',
    username: 'sa',
    password: 'yourpassword',
    query: 'SELECT * FROM Users',
  },
});

Running the Server

Local Development

# Install dependencies
npm install

# Run in development mode
npm run dev

# Build
npm run build

# Run the built server
npm start

Using Docker

# Build and start services (SQL Server + MCP server)
docker-compose up

# Or just build the Docker image
docker build -t mssql-mcp-server .

Testing

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

Running evals

The evals package loads an mcp client that then runs the index.ts file, so there is no need to rebuild between tests. You can load environment variables by prefixing the npx command. Full documentation can be found here.

OPENAI_API_KEY=your-key  npx mcp-eval src/evals/evals.ts examples/simple-server.ts

Security

The server includes safeguards against dangerous SQL operations:

  • Blocks potentially harmful commands like DROP, TRUNCATE, ALTER, CREATE, EXEC, etc.
  • Validates all input parameters and database names
  • Sets reasonable limits on query length and timeout
  • Uses connection pooling for better performance and security

License

MIT

Quick Start

1

Clone the repository

git clone https://github.com/c0h1b4/mssql-mcp-server
2

Install dependencies

cd mssql-mcp-server
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerc0h1b4
Repomssql-mcp-server
LanguageTypeScript
LicenseMIT License
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation