MSSQL
Generic Microsoft SQL Server JSON CLI. Read commands use guarded SQL and read-only connection intent; exec runs one statement allowed by the configured SQL Server account.
Local .env
The CLI automatically loads a private .env beside this SKILL.md through pass-cli. Copy .env.example to .env and replace placeholders with environment values or secret-manager pointers.
A single .env may hold several namespaced profiles. Select one with --profile:
uv run --python 3.13 --with pymssql python scripts/ms.py --profile analytics query --sql "SELECT @@VERSION"
Without --profile, the CLI uses ordinary MSSQL_* variables.
| Variable | Flag | Default |
|---|---|---|
MSSQL_HOST |
--host |
none |
MSSQL_PORT |
--port |
1433 |
MSSQL_DATABASE |
--database |
none |
MSSQL_USER |
--user |
none |
MSSQL_PASSWORD |
none | empty |
MSSQL_ENCRYPTION |
--encryption |
require |
MSSQL_TDS_VERSION |
--tds-version |
driver default |
MSSQL_APPNAME |
--appname |
mssql |
Never pass a password as a CLI argument or commit a real .env.
Read
uv run --python 3.13 --with pymssql python scripts/ms.py query --sql "SELECT TOP 10 * FROM dbo.events"
uv run --python 3.13 --with pymssql python scripts/ms.py list-databases
uv run --python 3.13 --with pymssql python scripts/ms.py list-schemas
uv run --python 3.13 --with pymssql python scripts/ms.py list-tables --schema dbo
uv run --python 3.13 --with pymssql python scripts/ms.py describe-table --schema dbo --table events
Read commands reject obvious mutations, use SQL Server read-only connection intent, and cap results.
Execute
Use exec only after the user approves the exact operation and target:
uv run --python 3.13 --with pymssql python scripts/ms.py \
exec --sql "ALTER TABLE dbo.events ADD source nvarchar(30) NULL"
exec accepts one DDL, DML, or administrative statement. It rejects empty and multi-statement SQL. There is no local write authorization gate: SQL Server account grants are the authorization boundary.
--sql accepts literal SQL, @file.sql, or -. --params accepts a JSON array or object.
Safety contract
- Obtain fresh user approval before each mutation scope.
- Read commands retain local SQL guards, timeout, row limits, and read-only connection intent.
execuses a normal transaction and rolls back on failure.execrejects empty and multi-statement SQL; the configured account decides what is allowed.- Do not print secrets, connection strings,
.envcontents, or environment variables. - Ask before touching sensitive data, even in read mode.
Output
{
"rows": [{"name": "master"}],
"row_count": 1
}
Execution returns {"ok": true} plus affected rows or returned data when available.
Tests
uv run --python 3.13 --with pymssql python tests/test_ms.py