@adriancy/mcp-mssql 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +1 -0
- package/README.md +1 -1
- package/dist/config.js +22 -0
- package/package.json +1 -1
package/.env.example
CHANGED
|
@@ -10,6 +10,7 @@ MSSQL_DATABASE=your_database
|
|
|
10
10
|
# TLS (defaults: encrypt true, trust cert false). MSSQL_ENCRYPT may be true, false, or strict (TDS 8.0).
|
|
11
11
|
# MSSQL_ENCRYPT=true
|
|
12
12
|
# MSSQL_TRUST_SERVER_CERTIFICATE=false
|
|
13
|
+
# Hostname on the SQL Server TLS cert when MSSQL_SERVER is an IP (Node.js cannot use an IP as TLS SNI).
|
|
13
14
|
# MSSQL_TLS_SERVER_NAME=
|
|
14
15
|
# Paths on the MCP host; PEM contents read at startup (fail fast if missing).
|
|
15
16
|
# MSSQL_TLS_CA_FILE=
|
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ All variables are read from the MCP process environment (e.g. Cursor `env`). Boo
|
|
|
64
64
|
| `MSSQL_PORT` | no | `1433` | TCP port; omit when using `MSSQL_INSTANCE_NAME` (driver uses instance + SQL Browser) |
|
|
65
65
|
| `MSSQL_ENCRYPT` | no | `true` | TLS `encrypt`: `true`, `false`, or `strict` (TDS 8.0 / tedious) |
|
|
66
66
|
| `MSSQL_TRUST_SERVER_CERTIFICATE` | no | `false` | Trust self-signed / skip cert validation (dev only) |
|
|
67
|
-
| `MSSQL_TLS_SERVER_NAME` | no | — |
|
|
67
|
+
| `MSSQL_TLS_SERVER_NAME` | no | — | TLS SNI / cert hostname when `MSSQL_SERVER` is an IP or differs from the cert (required for IP + encrypted connections; must be a hostname, not an IP) |
|
|
68
68
|
| `MSSQL_TLS_CA_FILE` | no | — | Path to CA PEM; passed via `cryptoCredentialsDetails.ca` |
|
|
69
69
|
| `MSSQL_TLS_CERT_FILE` | no | — | Optional client cert PEM (mutual TLS) |
|
|
70
70
|
| `MSSQL_TLS_KEY_FILE` | no | — | Optional client private key PEM |
|
package/dist/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
|
+
import { isIP } from 'node:net';
|
|
2
3
|
import * as path from 'node:path';
|
|
3
4
|
import * as v from 'valibot';
|
|
4
5
|
const TRUE_VALUES = new Set(['1', 'true', 'yes', 'on']);
|
|
@@ -36,6 +37,13 @@ function parseEncrypt(raw) {
|
|
|
36
37
|
return 'strict';
|
|
37
38
|
return parseBool(raw, true);
|
|
38
39
|
}
|
|
40
|
+
/** True when MSSQL_ENCRYPT explicitly disables TLS (default is encrypt on). */
|
|
41
|
+
function isEncryptExplicitlyDisabled(raw) {
|
|
42
|
+
const trimmed = raw?.trim();
|
|
43
|
+
if (trimmed === undefined || trimmed === '')
|
|
44
|
+
return false;
|
|
45
|
+
return FALSE_VALUES.has(trimmed.toLowerCase());
|
|
46
|
+
}
|
|
39
47
|
function normalizeAuthType(raw) {
|
|
40
48
|
const trimmed = raw?.trim();
|
|
41
49
|
if (trimmed === undefined || trimmed === '')
|
|
@@ -168,6 +176,20 @@ function rawScalarChecks(e, addIssue) {
|
|
|
168
176
|
addIssue({ message: `${rule.key} must be ${range}.` });
|
|
169
177
|
}
|
|
170
178
|
}
|
|
179
|
+
const serverHost = e.MSSQL_SERVER.trim();
|
|
180
|
+
if (isIP(serverHost) !== 0 && !isEncryptExplicitlyDisabled(e.MSSQL_ENCRYPT)) {
|
|
181
|
+
const tlsName = e.MSSQL_TLS_SERVER_NAME?.trim();
|
|
182
|
+
if (tlsName === undefined || tlsName === '') {
|
|
183
|
+
addIssue({
|
|
184
|
+
message: 'MSSQL_SERVER is an IP address; Node.js TLS cannot set SNI server name to an IP. Set MSSQL_TLS_SERVER_NAME to the hostname on the server certificate (often the machine FQDN), or put that hostname in MSSQL_SERVER if DNS resolves, or set MSSQL_ENCRYPT=false if plaintext is acceptable.',
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
else if (isIP(tlsName) !== 0) {
|
|
188
|
+
addIssue({
|
|
189
|
+
message: 'MSSQL_TLS_SERVER_NAME must be a hostname, not an IP address (Node.js TLS does not allow SNI with an IP).',
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
171
193
|
}
|
|
172
194
|
function rawEnvChecks(e, addIssue) {
|
|
173
195
|
const rawAuth = normalizeAuthType(e.MSSQL_AUTH_TYPE);
|