‹ 首页

mssql

@sanjay3290 · 收录于 1 周前

Execute read-only SQL queries against multiple Microsoft SQL Server databases. Use when: (1) querying MSSQL/SQL Server databases, (2) exploring database schemas/tables, (3) running SELECT queries for data analysis, (4) checking database contents. Supports multiple database connections with descriptions for intelligent auto-selection. Blocks all write operations (INSERT, UPDATE, DELETE, DROP, etc.) for safety.

适合你,如果需要安全查询 MSSQL 数据库并分析数据

/ 下载安装
mssql.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add sanjay3290/ai-skills/mssql
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- sanjay3290/ai-skills/mssql
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify sanjay3290/ai-skills/mssql
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
335GitHub stars
~900最小装载
~3K含声明引用
~3.6K文本包总量
镜像托管

怎么用

技能原文 SKILL.md作者撰写 · Apache-2.0 · cde1c83

MSSQL Read-Only Query Skill

Execute safe, read-only queries against configured Microsoft SQL Server databases.

Requirements
  • Python 3.8+
  • pymssql: pip install -r requirements.txt
Setup

Create connections.json in the skill directory or ~/.config/claude/mssql-connections.json.

Security: Set file permissions to 600 since it contains credentials:

chmod 600 connections.json
{
  "databases": [
    {
      "name": "production",
      "description": "Main app database - users, orders, transactions",
      "host": "db.example.com",
      "port": 1433,
      "database": "app_prod",
      "user": "readonly_user",
      "password": "your-password",
      "encrypt": true,
      "tds_version": "7.3"
    }
  ]
}
Config Fields

| Field | Required | Description | |-------|----------|-------------| | name | Yes | Identifier for the database (case-insensitive) | | description | Yes | What data this database contains (used for auto-selection) | | host | Yes | Database hostname | | port | No | Port number (default: 1433) | | database | Yes | Database name | | user | Yes | Username | | password | Yes | Password | | encrypt | No | Enable TLS encryption (default: false) | | tds_version | No | TDS protocol version: 7.0, 7.1, 7.2, 7.3, 7.4 (default: auto) |

Usage
List configured databases
python3 scripts/query.py --list
Query a database
python3 scripts/query.py --db production --query "SELECT TOP 10 * FROM users"
List tables
python3 scripts/query.py --db production --tables
Show schema
python3 scripts/query.py --db production --schema
Limit results
python3 scripts/query.py --db production --query "SELECT * FROM orders" --limit 100

Note: MSSQL uses TOP N instead of LIMIT. The --limit flag automatically inserts TOP N after SELECT.

Database Selection

Match user intent to database description:

| User asks about | Look for description containing | |-----------------|--------------------------------| | users, accounts | users, accounts, customers | | orders, sales | orders, transactions, sales | | analytics, metrics | analytics, metrics, reports | | logs, events | logs, events, audit |

If unclear, run --list and ask user which database.

Safety Features
  • Read-only enforcement: Query validation blocks write operations (use a db_datareader role user for server-side protection)
  • Query validation: Only SELECT, SHOW, EXPLAIN, WITH, SP_HELP queries allowed
  • Single statement: Multiple statements per query rejected
  • TLS support: Configurable encryption for secure connections
  • Query timeout: 30-second timeout enforced via pymssql
  • Connection timeout: 10-second login timeout
  • Memory protection: Max 10,000 rows per query to prevent OOM
  • Column width cap: 100 char max per column for readable output
  • Credential sanitization: Error messages don't leak passwords
Troubleshooting

| Error | Solution | |-------|----------| | Config not found | Create connections.json in skill directory | | Authentication failed | Check username/password in config | | Connection timeout | Verify host/port, check firewall/VPN | | TDS version error | Try "tds_version": "7.3" or "7.4" | | Encryption error | Set "encrypt": true for Azure SQL | | Permission warning | Run chmod 600 connections.json |

Exit Codes
  • 0: Success
  • 1: Error (config missing, auth failed, invalid query, database error)
Workflow
  1. Run --list to show available databases
  2. Match user intent to database description
  3. Run --tables or --schema to explore structure
  4. Execute query with appropriate --limit (auto-converts to TOP N)
按 Apache-2.0 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。