JSPM

@fynet/mcp-mssql

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 23
  • Score
    100M100P100Q58837F
  • License MIT

MCP SQL Server Tools - A Model Context Protocol server for Microsoft SQL Server

Package Exports

  • @fynet/mcp-mssql
  • @fynet/mcp-mssql/dist/server.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@fynet/mcp-mssql) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

MCP MSSQL Server

切换到英文 / Switch to English

这是一个基于 Model Context Protocol (MCP) 的 MSSQL 服务器实现,用于在支持 MCP 的开发工具(如 Cursor、Cline 等)中提供数据库操作功能。

功能特点

  • 完全符合 MCP 协议标准
  • 支持 MSSQL 数据库操作
  • 提供安全的数据库连接配置
  • 支持表创建、查询、索引等操作

安装

# 全局安装
npm install -g @fynet/mcp-mssql

# 或直接使用 npx
npx @fynet/mcp-mssql

配置说明

数据库连接参数

必需参数:

  • server: 数据库服务器地址(例如:127.0.0.1localhost
  • database: 数据库名称
  • user: 数据库用户名
  • password: 数据库密码

可选参数:

  • trustServerCertificate: 是否信任服务器证书(默认:true)
  • encrypt: 是否启用加密连接(默认:false)

使用方法

1. 命令行方式

使用 npx 直接运行:

# Windows/Linux/MacOS 通用
npx @fynet/mcp-mssql --server=your-server --database=your-database --user=your-username --password=your-password

2. Cursor 配置方式

  1. 打开 Cursor 设置(Windows/Linux: Ctrl+,,MacOS: Cmd+,
  2. 点击左侧菜单中的 "Extensions"
  3. 找到 "MCP" 部分
  4. 点击 "Edit in settings.json"(文件位置:~/.cursor/mcp.json
  5. 添加配置:
{
  "mcp-mssql": {
    "command": "cmd",  // Windows 使用 "cmd",Linux/MacOS 使用 "bash"
    "args": [
      "/c",           // Windows 使用 "/c",Linux/MacOS 使用 "-c"
      "npx",
      "-y",
      "@fynet/mcp-mssql",
      "--server=127.0.0.1",
      "--database=your-database",
      "--user=your-username",
      "--password=your-password",
      "--trustServerCertificate=true",
      "--encrypt=false"
    ],
    "env": {
      "NPM_CONFIG_REGISTRY": "https://registry.npmjs.org/"
    }
  }
}

3. Cline 配置方式

  1. 打开 Cline 设置
  2. 选择 "Settings" -> "Extensions" -> "MCP"
  3. 添加配置:
{
  "mcp.connections": [
    {
      "name": "mssql",
      "type": "mssql",
      "default": true,
      "config": {
        "server": "your-server",
        "database": "your-database",
        "user": "your-username",
        "password": "your-password",
        "options": {
          "trustServerCertificate": true,
          "encrypt": false
        }
      }
    }
  ]
}

验证配置

配置完成后的验证步骤:

  1. 重启开发工具(Cursor 或 Cline)
  2. 打开命令面板(Windows/Linux: Ctrl+Shift+P,MacOS: Cmd+Shift+P
  3. 输入 "MCP: Test Connection" 并选择配置的连接
  4. 测试查询:在编辑器中输入 "查询当前数据库版本"

常见问题

1. 连接问题

  • 确保数据库服务器地址正确且可访问
  • 验证用户名和密码
  • 检查数据库名称是否存在
  • 确认防火墙设置

2. NPM 相关

  • 确保网络可以访问 npm 源
  • 如遇网络问题,可更换国内镜像源:
    "env": {
      "NPM_CONFIG_REGISTRY": "https://registry.npmmirror.com/"
    }

3. 权限问题

  • 确保数据库用户具有必要权限
  • 检查 SQL Server 认证模式
  • 确认数据库允许远程连接

开发相关

如需修改或开发此项目:

# 克隆仓库
git clone https://github.com/yourusername/mcp-mssql.git

# 安装依赖
npm install

# 构建项目
npm run build

目录结构

  • server.ts - 主服务器实现
  • package.json - 项目配置文件
  • tsconfig.json - TypeScript 配置

许可证

MIT

贡献

欢迎提交 Issue 和 Pull Request!


MCP MSSQL Server (English)

A MSSQL server implementation based on Model Context Protocol (MCP), providing database operations in MCP-supported development tools (such as Cursor, Cline, etc.).

Features

  • Fully compliant with MCP protocol standards
  • Support for MSSQL database operations
  • Secure database connection configuration
  • Support for table creation, queries, indexing, and more

Installation

# Install globally
npm install -g @fynet/mcp-mssql

# Or use npx directly
npx @fynet/mcp-mssql

Configuration Parameters

Required Parameters

  • server: Database server address (e.g., 127.0.0.1 or localhost)
  • database: Database name
  • user: Database username
  • password: Database password

Optional Parameters

  • trustServerCertificate: Whether to trust server certificate (default: true)
  • encrypt: Whether to enable encrypted connection (default: false)

Usage

1. Command Line Usage

# Windows/Linux/MacOS
npx @fynet/mcp-mssql --server=your-server --database=your-database --user=your-username --password=your-password

2. Cursor Configuration

  1. Open Cursor settings (Windows/Linux: Ctrl+,, MacOS: Cmd+,)
  2. Click "Extensions" in the left menu
  3. Find the "MCP" section
  4. Click "Edit in settings.json" (located at ~/.cursor/mcp.json)
  5. Add configuration:
{
  "mcp-mssql": {
    "command": "cmd",  // Use "cmd" for Windows, "bash" for Linux/MacOS
    "args": [
      "/c",           // Use "/c" for Windows, "-c" for Linux/MacOS
      "npx",
      "-y",
      "@fynet/mcp-mssql",
      "--server=127.0.0.1",
      "--database=your-database",
      "--user=your-username",
      "--password=your-password",
      "--trustServerCertificate=true",
      "--encrypt=false"
    ],
    "env": {
      "NPM_CONFIG_REGISTRY": "https://registry.npmjs.org/"
    }
  }
}

3. Cline Configuration

  1. Open Cline settings
  2. Go to "Settings" -> "Extensions" -> "MCP"
  3. Add configuration:
{
  "mcp.connections": [
    {
      "name": "mssql",
      "type": "mssql",
      "default": true,
      "config": {
        "server": "your-server",
        "database": "your-database",
        "user": "your-username",
        "password": "your-password",
        "options": {
          "trustServerCertificate": true,
          "encrypt": false
        }
      }
    }
  ]
}

Verifying Configuration

After configuration:

  1. Restart your development tool (Cursor or Cline)
  2. Open command palette (Windows/Linux: Ctrl+Shift+P, MacOS: Cmd+Shift+P)
  3. Type "MCP: Test Connection" and select your configured connection
  4. Test query: Type "query current database version" in the editor

Common Issues

1. Connection Issues

  • Ensure database server address is correct and accessible
  • Verify username and password
  • Check if database name exists
  • Confirm firewall settings
  • Ensure network access to npm registry
  • For network issues, try changing npm registry:
    "env": {
      "NPM_CONFIG_REGISTRY": "https://registry.npmmirror.com/"
    }

3. Permission Issues

  • Ensure database user has necessary permissions
  • Check SQL Server authentication mode
  • Confirm database allows remote connections

Development

For modifying or developing this project:

# Clone the repository
git clone https://github.com/yourusername/mcp-mssql.git

# Install dependencies
npm install

# Build the project
npm run build

Project Structure

  • server.ts - Main server implementation
  • package.json - Project configuration
  • tsconfig.json - TypeScript configuration

License

MIT

Contributing

Issues and Pull Requests are welcome!