Skip to main content

MCP Server for Microsoft SQL Server — no native drivers required

Project description

jewei-mcp-mssql

Microsoft SQL Server MCP Server — 让 AI 助手能够查询和操作 SQL Server,无需安装任何本地驱动(纯 Python 实现)。

特性

  • 无驱动:基于 python-tds,无需 ODBC 驱动或 FreeTDS
  • 权限控制:INSERT / UPDATE / DELETE / DDL 各自独立开关,默认全只读
  • 支持 stdio 和 Streamable HTTP 两种传输模式

快速开始

Claude Code

在项目 .mcp.json 或全局配置中添加:

{
  "mcpServers": {
    "mssql": {
      "type": "stdio",
      "command": "uvx",
      "args": ["jewei-mcp-mssql"],
      "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_PORT": "1433",
        "MSSQL_DATABASE": "master",
        "MSSQL_USERNAME": "sa",
        "MSSQL_PASSWORD": "your_password"
      }
    }
  }
}

Cursor

~/.cursor/mcp.json 中添加:

{
  "mcpServers": {
    "mssql": {
      "command": "uvx",
      "args": ["jewei-mcp-mssql"],
      "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_USERNAME": "sa",
        "MSSQL_PASSWORD": "your_password"
      }
    }
  }
}

OpenCode

~/.opencode/opencode.json 中添加:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "mssql": {
      "type": "local",
      "command": ["uvx", "jewei-mcp-mssql"],
      "enabled": true,
      "environment": {
        "MSSQL_HOST": "localhost",
        "MSSQL_USERNAME": "sa",
        "MSSQL_PASSWORD": "your_password"
      }
    }
  }
}

Claude Desktop

claude_desktop_config.json 中添加:

{
  "mcpServers": {
    "mssql": {
      "command": "uvx",
      "args": ["jewei-mcp-mssql"],
      "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_USERNAME": "sa",
        "MSSQL_PASSWORD": "your_password"
      }
    }
  }
}

环境变量

连接配置

变量 说明 必填 默认值
MSSQL_HOST SQL Server 主机地址 localhost
MSSQL_PORT SQL Server 端口 1433
MSSQL_DATABASE 默认数据库 master
MSSQL_USERNAME 用户名 -
MSSQL_PASSWORD 密码 -

权限控制

变量 说明 默认值
MSSQL_ALLOW_INSERT 是否允许 INSERT false
MSSQL_ALLOW_UPDATE 是否允许 UPDATE false
MSSQL_ALLOW_DELETE 是否允许 DELETE false
MSSQL_ALLOW_DDL 是否允许 DDL(CREATE/DROP/ALTER/TRUNCATE) false

传输模式

变量 说明 默认值
MCP_TRANSPORT 传输模式:stdiostreamable_http stdio
MCP_PORT HTTP 模式端口 8000

可用工具

工具 说明
mssql_execute_sql 执行 SQL 语句(SELECT 始终允许,写操作受环境变量控制)
mssql_list_databases 列出所有可访问的数据库
mssql_list_tables 列出指定数据库下的所有表
mssql_describe_table 获取表的列结构(列名、类型、可空性等)

提示示例

查询 orders 表中最近 10 条记录
列出 AdventureWorks 数据库里所有的表
描述 dbo.Customers 表的结构
统计 sales 库中每个城市的订单数量,按数量降序排列

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jewei_mcp_mssql-0.1.9.tar.gz (90.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jewei_mcp_mssql-0.1.9-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file jewei_mcp_mssql-0.1.9.tar.gz.

File metadata

  • Download URL: jewei_mcp_mssql-0.1.9.tar.gz
  • Upload date:
  • Size: 90.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jewei_mcp_mssql-0.1.9.tar.gz
Algorithm Hash digest
SHA256 6087f76a7cb63bd855bb15de39ae4874d157dbe1d0ef487c82224520c3723fc5
MD5 7dfd327cbaf27a72f201230eec4964f2
BLAKE2b-256 b3d607abaf05502f9c920d8ad139b7e559b83a873959aaf3d999e5fde537ef99

See more details on using hashes here.

Provenance

The following attestation bundles were made for jewei_mcp_mssql-0.1.9.tar.gz:

Publisher: publish.yml on jeweis/jewei-mcp-mssql

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jewei_mcp_mssql-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for jewei_mcp_mssql-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 52e96ffda6d0e14d2b3fa633da7f5ada9f9a2836ac1763ba21df338fb23091eb
MD5 4f59575979860d2b790f23a7b9867ae9
BLAKE2b-256 7ae0c56fa549579372d3c5ba85865f60dddec567092d20d39034d401a174091a

See more details on using hashes here.

Provenance

The following attestation bundles were made for jewei_mcp_mssql-0.1.9-py3-none-any.whl:

Publisher: publish.yml on jeweis/jewei-mcp-mssql

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page