Metadata-Version: 2.4
Name: mssql-mcp-server-v2
Version: 0.2.0
Summary: A Model Context Protocol (MCP) server that enables secure interaction with Microsoft SQL Server databases. mcp 2.x-compatible fork of microsoft_sql_server_mcp.
Author-email: Richard Han <noreply@example.com>
Maintainer: SL33PiNg
License: MIT
License-File: LICENSE
Keywords: ai,database,mcp,mssql,sql-server
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Requires-Dist: mcp>=2.0.0
Requires-Dist: pymssql>=2.2.8
Description-Content-Type: text/markdown

# Microsoft SQL Server MCP Server (v2)

[![PyPI](https://img.shields.io/pypi/v/mssql-mcp-server-v2)](https://pypi.org/project/mssql-mcp-server-v2/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

<a href="https://glama.ai/mcp/servers/29cpe19k30">
  <img width="380" height="200" src="https://glama.ai/mcp/servers/29cpe19k30/badge" alt="Microsoft SQL Server MCP server" />
</a>

A Model Context Protocol (MCP) server for secure SQL Server database access through Claude Desktop.

> **This is a fork** of [RichardHan/mssql_mcp_server](https://github.com/RichardHan/mssql_mcp_server)
> (original copyright Dana K. Williams, MIT licensed), ported to the `mcp` 2.x
> `on_*`-handler server API and republished under a new package name so it can
> be installed independently of the original. See [Credits](#credits) below.
> No changes have been proposed back to the upstream repo.

## Features

- 🔍 List database tables
- 📊 Execute SQL queries (SELECT, INSERT, UPDATE, DELETE)
- 🔐 Multiple authentication methods (SQL, Windows, Azure AD)
- 🏢 LocalDB and Azure SQL support
- 🔌 Custom port configuration

## Quick Start

### Install with Claude Desktop

Add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "mssql": {
      "command": "uvx",
      "args": ["--from", "mssql-mcp-server-v2", "mssql_mcp_server"],
      "env": {
        "MSSQL_SERVER": "localhost",
        "MSSQL_DATABASE": "your_database",
        "MSSQL_USER": "your_username",
        "MSSQL_PASSWORD": "your_password"
      }
    }
  }
}
```

`--from` is required because the PyPI package name (`mssql-mcp-server-v2`) is
different from the command it provides (`mssql_mcp_server`) — without it,
`uvx` tries to fetch a package literally named `mssql_mcp_server`, which
doesn't exist.

**On Windows**, use `mssql_mcp_server.exe` (with the `.exe` suffix) as the
last arg instead of `mssql_mcp_server`:

```json
"args": ["--from", "mssql-mcp-server-v2", "mssql_mcp_server.exe"],
```

## Configuration

### Basic SQL Authentication
```bash
MSSQL_SERVER=localhost          # Required
MSSQL_DATABASE=your_database    # Required
MSSQL_USER=your_username        # Required for SQL auth
MSSQL_PASSWORD=your_password    # Required for SQL auth
```

### Windows Authentication
```bash
MSSQL_SERVER=localhost
MSSQL_DATABASE=your_database
MSSQL_WINDOWS_AUTH=true         # Use Windows credentials
```

### Azure SQL Database
```bash
MSSQL_SERVER=your-server.database.windows.net
MSSQL_DATABASE=your_database
MSSQL_USER=your_username
MSSQL_PASSWORD=your_password
# Encryption is automatic for Azure
```

### Optional Settings
```bash
MSSQL_PORT=1433                 # Custom port (default: 1433)
MSSQL_ENCRYPT=true              # Force encryption
```

## Alternative Installation Methods

### Using pip
```bash
pip install mssql-mcp-server-v2
```

Then in `claude_desktop_config.json`:
```json
{
  "mcpServers": {
    "mssql": {
      "command": "python",
      "args": ["-m", "mssql_mcp_server"],
      "env": { ... }
    }
  }
}
```

### Development
```bash
git clone https://github.com/SL33PiNg/mssql_mcp_server.git
cd mssql_mcp_server
pip install -e .
```

## Requirements

Requires `mcp>=2.0.0`, which uses the constructor `on_*`-handler `Server` API
(no `@app.list_resources()`-style decorators). If you're pinned to `mcp<2`
for another server, install this package in an isolated environment (e.g.
via `uvx --from mssql-mcp-server-v2 mssql_mcp_server`, as above) rather than
the same venv.

## Security

- Create a dedicated SQL user with minimal permissions
- Never use admin/sa accounts
- Use Windows Authentication when possible
- Enable encryption for sensitive data

## Credits

This project is a fork of [RichardHan/mssql_mcp_server](https://github.com/RichardHan/mssql_mcp_server),
originally licensed MIT under copyright Dana K. Williams (see [LICENSE](LICENSE)).
All credit for the original design and implementation goes to them. This fork
exists solely to port the server to the `mcp` 2.x server API and publish it
under a distinct package name (`mssql-mcp-server-v2`) independent of the
original, since the original package still targets `mcp` 1.x.

## License

MIT