@eamonboyle/mssql-mcp 1.5.0 → 2.0.0
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/README.md +379 -361
- package/dist/apps/queryResultsApp.d.ts +18 -0
- package/dist/apps/queryResultsApp.d.ts.map +1 -0
- package/dist/apps/queryResultsApp.js +272 -0
- package/dist/apps/queryResultsApp.js.map +1 -0
- package/dist/checkNodeVersion.d.ts +2 -0
- package/dist/checkNodeVersion.d.ts.map +1 -0
- package/dist/checkNodeVersion.js +9 -0
- package/dist/checkNodeVersion.js.map +1 -0
- package/dist/config.d.ts +58 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +202 -33
- package/dist/config.js.map +1 -1
- package/dist/confirmationMessage.d.ts +2 -0
- package/dist/confirmationMessage.d.ts.map +1 -0
- package/dist/confirmationMessage.js +105 -0
- package/dist/confirmationMessage.js.map +1 -0
- package/dist/db.d.ts +24 -0
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +152 -36
- package/dist/db.js.map +1 -1
- package/dist/filteredRead.js +0 -0
- package/dist/httpServer.d.ts +25 -0
- package/dist/httpServer.d.ts.map +1 -0
- package/dist/httpServer.js +128 -0
- package/dist/httpServer.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -366
- package/dist/index.js.map +1 -1
- package/dist/mcpResults.d.ts +1 -1
- package/dist/mcpResults.d.ts.map +1 -1
- package/dist/mcpResults.js +2 -2
- package/dist/mcpResults.js.map +1 -1
- package/dist/nodeVersion.d.ts +14 -0
- package/dist/nodeVersion.d.ts.map +1 -0
- package/dist/nodeVersion.js +23 -0
- package/dist/nodeVersion.js.map +1 -0
- package/dist/packageInfo.d.ts +3 -0
- package/dist/packageInfo.d.ts.map +1 -0
- package/dist/packageInfo.js +5 -0
- package/dist/packageInfo.js.map +1 -0
- package/dist/promptRegistry.d.ts +1 -1
- package/dist/promptRegistry.d.ts.map +1 -1
- package/dist/promptRegistry.js +1 -1
- package/dist/promptRegistry.js.map +1 -1
- package/dist/resourceRegistry.d.ts +9 -1
- package/dist/resourceRegistry.d.ts.map +1 -1
- package/dist/resourceRegistry.js +9 -2
- package/dist/resourceRegistry.js.map +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +16 -20
- package/dist/schema.js.map +1 -1
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +320 -0
- package/dist/server.js.map +1 -0
- package/dist/serverState.js +2 -4
- package/dist/serverState.js.map +1 -1
- package/dist/sql.js +0 -0
- package/dist/sqlErrors.d.ts +10 -0
- package/dist/sqlErrors.d.ts.map +1 -0
- package/dist/sqlErrors.js +32 -0
- package/dist/sqlErrors.js.map +1 -0
- package/dist/toolRegistry.d.ts +1 -1
- package/dist/toolRegistry.d.ts.map +1 -1
- package/dist/toolRegistry.js +1 -1
- package/dist/toolRegistry.js.map +1 -1
- package/dist/tools/AnalyzeTableTool.js +2 -4
- package/dist/tools/AnalyzeTableTool.js.map +1 -1
- package/dist/tools/CreateIndexTool.js +2 -4
- package/dist/tools/CreateIndexTool.js.map +1 -1
- package/dist/tools/CreateTableTool.js +2 -4
- package/dist/tools/CreateTableTool.js.map +1 -1
- package/dist/tools/DeleteDataTool.js +2 -4
- package/dist/tools/DeleteDataTool.js.map +1 -1
- package/dist/tools/DescribeDependenciesTool.js +2 -4
- package/dist/tools/DescribeDependenciesTool.js.map +1 -1
- package/dist/tools/DescribeObjectTool.js +2 -4
- package/dist/tools/DescribeObjectTool.js.map +1 -1
- package/dist/tools/DescribeRelationshipsTool.js +2 -4
- package/dist/tools/DescribeRelationshipsTool.js.map +1 -1
- package/dist/tools/DescribeTableTool.js +2 -4
- package/dist/tools/DescribeTableTool.js.map +1 -1
- package/dist/tools/DropTableTool.js +2 -4
- package/dist/tools/DropTableTool.js.map +1 -1
- package/dist/tools/ExplainQueryTool.d.ts.map +1 -1
- package/dist/tools/ExplainQueryTool.js +4 -6
- package/dist/tools/ExplainQueryTool.js.map +1 -1
- package/dist/tools/InsertDataTool.js +2 -4
- package/dist/tools/InsertDataTool.js.map +1 -1
- package/dist/tools/ListDatabasesTool.d.ts.map +1 -1
- package/dist/tools/ListDatabasesTool.js +2 -4
- package/dist/tools/ListDatabasesTool.js.map +1 -1
- package/dist/tools/ListForeignKeysTool.js +2 -4
- package/dist/tools/ListForeignKeysTool.js.map +1 -1
- package/dist/tools/ListLargestTablesTool.js +2 -4
- package/dist/tools/ListLargestTablesTool.js.map +1 -1
- package/dist/tools/ListObjectsTool.js +2 -4
- package/dist/tools/ListObjectsTool.js.map +1 -1
- package/dist/tools/ListTableTool.js +2 -4
- package/dist/tools/ListTableTool.js.map +1 -1
- package/dist/tools/PreviewDeleteTool.js +2 -4
- package/dist/tools/PreviewDeleteTool.js.map +1 -1
- package/dist/tools/PreviewUpdateTool.js +2 -4
- package/dist/tools/PreviewUpdateTool.js.map +1 -1
- package/dist/tools/ReadDataTool.d.ts +15 -12
- package/dist/tools/ReadDataTool.d.ts.map +1 -1
- package/dist/tools/ReadDataTool.js +86 -64
- package/dist/tools/ReadDataTool.js.map +1 -1
- package/dist/tools/SearchDataTool.js +2 -4
- package/dist/tools/SearchDataTool.js.map +1 -1
- package/dist/tools/SummarizeSchemaTool.js +2 -4
- package/dist/tools/SummarizeSchemaTool.js.map +1 -1
- package/dist/tools/UpdateDataTool.js +2 -4
- package/dist/tools/UpdateDataTool.js.map +1 -1
- package/dist/validation.d.ts +26 -3
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +237 -85
- package/dist/validation.js.map +1 -1
- package/dist/writePreview.js +0 -0
- package/dist/writePreviewGrant.js +0 -0
- package/dist/writePreviewGrantStore.js +0 -0
- package/dist/writeSafety.js +0 -0
- package/package.json +27 -18
package/README.md
CHANGED
|
@@ -1,361 +1,379 @@
|
|
|
1
|
-
# MSSQL MCP Server
|
|
2
|
-
|
|
3
|
-
[](https://opensource.org/licenses/MIT)
|
|
4
|
-
[](https://www.npmjs.com/package/@eamonboyle/mssql-mcp)
|
|
5
|
-
[](https://x.com/eamonyo)
|
|
7
|
-
|
|
8
|
-
[](https://cursor.com/en/install-mcp?name=
|
|
9
|
-
[](https://intradeus.github.io/http-protocol-redirector?r=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522mssql%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522-y%2522%252C%2522%2540eamonboyle%252Fmssql-mcp%2522%255D%252C%2522env%2522%253A%257B%2522SERVER_NAME%2522%253A%2522localhost%2522%252C%2522DATABASE_NAME%2522%253A%
|
|
10
|
-
|
|
11
|
-
>
|
|
12
|
-
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
`
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
-
|
|
299
|
-
-
|
|
300
|
-
-
|
|
301
|
-
-
|
|
302
|
-
-
|
|
303
|
-
-
|
|
304
|
-
-
|
|
305
|
-
-
|
|
306
|
-
-
|
|
307
|
-
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
1
|
+
# MSSQL MCP Server
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://www.npmjs.com/package/@eamonboyle/mssql-mcp)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://x.com/eamonyo)
|
|
7
|
+
|
|
8
|
+
[](https://cursor.com/en/install-mcp?name=mssql-local&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBlYW1vbmJveWxlL21zc3FsLW1jcCJdLCJlbnYiOnsiU0VSVkVSX05BTUUiOiJsb2NhbGhvc3QiLCJEQVRBQkFTRV9OQU1FIjoiQXBwREIiLCJEQVRBQkFTRVMiOiJBcHBEQixSZXBvcnRpbmdEQiIsIkRCX1VTRVIiOiJ5b3VyX3VzZXJuYW1lIiwiREJfUEFTU1dPUkQiOiJ5b3VyX3Bhc3N3b3JkIiwiVFJVU1RfU0VSVkVSX0NFUlRJRklDQVRFIjoidHJ1ZSIsIlJFQURPTkxZIjoiZmFsc2UiLCJFTkFCTEVfRERMIjoiZmFsc2UifX0=)
|
|
9
|
+
[](https://intradeus.github.io/http-protocol-redirector?r=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522mssql-local%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522-y%2522%252C%2522%2540eamonboyle%252Fmssql-mcp%2522%255D%252C%2522env%2522%253A%257B%2522SERVER_NAME%2522%253A%2522localhost%2522%252C%2522DATABASE_NAME%2522%253A%2522AppDB%2522%252C%2522DATABASES%2522%253A%2522AppDB%252CReportingDB%2522%252C%2522DB_USER%2522%253A%2522your_username%2522%252C%2522DB_PASSWORD%2522%253A%2522your_password%2522%252C%2522TRUST_SERVER_CERTIFICATE%2522%253A%2522true%2522%252C%2522READONLY%2522%253A%2522false%2522%252C%2522ENABLE_DDL%2522%253A%2522false%2522%257D%257D)
|
|
10
|
+
|
|
11
|
+
> Experimental use only. This server is intended for education and evaluation, not production. Use a dedicated least-privilege SQL login and test all operations.
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
`@eamonboyle/mssql-mcp` exposes Microsoft SQL Server tools, resources, and prompts through the [Model Context Protocol](https://modelcontextprotocol.io/). The MCP client and its language model interpret natural-language requests and choose tools. This package validates requests, executes SQL Server operations, and returns structured results.
|
|
16
|
+
|
|
17
|
+
Key capabilities:
|
|
18
|
+
|
|
19
|
+
- Schema, object, relationship, dependency, and storage discovery
|
|
20
|
+
- Validated reads, parameterized searches, and estimated execution plans
|
|
21
|
+
- Insert, update, and delete tools with confirmation and row limits
|
|
22
|
+
- Preview tokens for update and delete operations
|
|
23
|
+
- DDL tools with an explicit configuration gate
|
|
24
|
+
- Multiple allowed databases on one SQL Server
|
|
25
|
+
- Local stdio and stateless Streamable HTTP transports
|
|
26
|
+
|
|
27
|
+
Supported clients include Cursor, VS Code, Claude Desktop, and other MCP-compatible hosts.
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
### Prerequisites
|
|
32
|
+
|
|
33
|
+
- Node.js 22 or newer (check with `node --version`)
|
|
34
|
+
- Microsoft SQL Server
|
|
35
|
+
- An MCP-compatible client
|
|
36
|
+
|
|
37
|
+
> **Still on Node.js 20?** Version 1.6.0 is the last release that runs on Node 20, which reached end-of-life in April 2026. Newer releases stop at startup with a message explaining this. Upgrade Node.js, or pin the older release in your MCP configuration with `npx -y @eamonboyle/mssql-mcp@1.6.0`.
|
|
38
|
+
|
|
39
|
+
The recommended installation runs the published package directly:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx -y @eamonboyle/mssql-mcp
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
A global installation also exposes the `mssql-mcp` command:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g @eamonboyle/mssql-mcp
|
|
49
|
+
mssql-mcp
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The one-click links use the minimal configuration shown below. Replace the sample connection values before use.
|
|
53
|
+
|
|
54
|
+
The badge payloads are generated from `src/samples/claude_desktop_config.json`. After changing the sample, run `npm run docs:update-install-links`; use `npm run docs:check-install-links` to verify they are current.
|
|
55
|
+
|
|
56
|
+
## Minimal MCP configuration
|
|
57
|
+
|
|
58
|
+
The standard presets show connection placeholders and keep DDL disabled:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"mssql-local": {
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": ["-y", "@eamonboyle/mssql-mcp"],
|
|
66
|
+
"env": {
|
|
67
|
+
"SERVER_NAME": "localhost",
|
|
68
|
+
"DATABASE_NAME": "AppDB",
|
|
69
|
+
"DATABASES": "AppDB,ReportingDB",
|
|
70
|
+
"DB_USER": "your_username",
|
|
71
|
+
"DB_PASSWORD": "your_password",
|
|
72
|
+
"TRUST_SERVER_CERTIFICATE": "true",
|
|
73
|
+
"READONLY": "false",
|
|
74
|
+
"ENABLE_DDL": "false"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Cursor uses `mcpServers` in `~/.cursor/mcp.json` or `.cursor/mcp.json`. Claude Desktop uses the same shape in its configuration file.
|
|
82
|
+
|
|
83
|
+
Set `ENABLE_DDL=true` only when the assistant specifically needs to create or remove schema objects.
|
|
84
|
+
|
|
85
|
+
VS Code uses `.vscode/mcp.json` or its user MCP configuration with a top-level `servers` object:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"servers": {
|
|
90
|
+
"mssql-local": {
|
|
91
|
+
"type": "stdio",
|
|
92
|
+
"command": "npx",
|
|
93
|
+
"args": ["-y", "@eamonboyle/mssql-mcp"],
|
|
94
|
+
"env": {
|
|
95
|
+
"SERVER_NAME": "localhost",
|
|
96
|
+
"DATABASE_NAME": "AppDB",
|
|
97
|
+
"DATABASES": "AppDB,ReportingDB",
|
|
98
|
+
"DB_USER": "your_username",
|
|
99
|
+
"DB_PASSWORD": "your_password",
|
|
100
|
+
"TRUST_SERVER_CERTIFICATE": "true",
|
|
101
|
+
"READONLY": "false",
|
|
102
|
+
"ENABLE_DDL": "false"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
See [`src/samples/`](src/samples/) for copyable Claude Desktop and VS Code files. Do not commit configuration files containing real credentials.
|
|
110
|
+
|
|
111
|
+
## Required configuration
|
|
112
|
+
|
|
113
|
+
The server validates these variables before starting. Missing or blank values produce an actionable startup error.
|
|
114
|
+
|
|
115
|
+
| Variable | Accepted format | Purpose |
|
|
116
|
+
| -------------------------- | ---------------------- | --------------------------------------------------------------------- |
|
|
117
|
+
| `DB_USER` | Nonblank string | SQL login (or NTLM) username; not used for Entra ID auth |
|
|
118
|
+
| `DB_PASSWORD` | Nonblank string | SQL login (or NTLM) password; not used for Entra ID auth |
|
|
119
|
+
|
|
120
|
+
At least one database variable is required: set `DATABASE_NAME`, `DATABASES`, or both. With only `DATABASE_NAME`, that database is both the default and the allowlist. With only `DATABASES`, the first entry is the default. When both are set, `DATABASE_NAME` is used if it appears in `DATABASES`; otherwise the first allowed database is the runtime default.
|
|
121
|
+
|
|
122
|
+
### Authentication
|
|
123
|
+
|
|
124
|
+
`SQL_AUTH_TYPE` selects how the server signs in to SQL Server. The default, `sql`, uses `DB_USER` and `DB_PASSWORD`.
|
|
125
|
+
|
|
126
|
+
| `SQL_AUTH_TYPE` | Also requires | Notes |
|
|
127
|
+
| ------------------------- | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
128
|
+
| `sql` (default) | `DB_USER`, `DB_PASSWORD` | SQL Server login |
|
|
129
|
+
| `ntlm` | `DB_USER`, `DB_PASSWORD`, `DB_DOMAIN` | Windows domain account over NTLM; integrated (SSPI) auth of the current user is not supported |
|
|
130
|
+
| `azure-default` | Optional `AZURE_CLIENT_ID` | Microsoft Entra ID via `DefaultAzureCredential`: `az login`, managed identity, workload identity, environment credentials |
|
|
131
|
+
| `azure-service-principal` | `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_TENANT_ID` | Entra ID app registration with a client secret |
|
|
132
|
+
| `azure-access-token` | `AZURE_ACCESS_TOKEN` | A pre-acquired Entra ID token; it is not refreshed, so restart the server when it expires |
|
|
133
|
+
|
|
134
|
+
Entra ID types default `ENCRYPT` to `true` and `TRUST_SERVER_CERTIFICATE` to `false`, because Azure SQL requires TLS and presents publicly trusted certificates. For Azure SQL with `azure-default` after `az login`:
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
SERVER_NAME=myserver.database.windows.net
|
|
138
|
+
DATABASE_NAME=mydb
|
|
139
|
+
SQL_AUTH_TYPE=azure-default
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Hostname and port
|
|
143
|
+
|
|
144
|
+
> Do not include the port in `SERVER_NAME`. Values such as `localhost,1434` are not supported by the Node.js `mssql` driver configuration used by this package. Set `SERVER_NAME` to the hostname and use `SERVER_PORT` separately.
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"SERVER_NAME": "localhost",
|
|
149
|
+
"SERVER_PORT": "1434"
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
For a Docker port mapping such as:
|
|
154
|
+
|
|
155
|
+
```yaml
|
|
156
|
+
ports:
|
|
157
|
+
- "1434:1433"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
use the published host port:
|
|
161
|
+
|
|
162
|
+
```text
|
|
163
|
+
SERVER_NAME=localhost
|
|
164
|
+
SERVER_PORT=1434
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
The container still listens on `1433`, but the MCP process connects through host port `1434`.
|
|
168
|
+
|
|
169
|
+
## Advanced configuration
|
|
170
|
+
|
|
171
|
+
Optional variables do not need empty placeholders. In-code defaults apply when they are absent.
|
|
172
|
+
|
|
173
|
+
| Variable | Accepted format | Default | Purpose |
|
|
174
|
+
| ----------------------- | ----------------------------- | --------------------- | -------------------------------------------------------------- |
|
|
175
|
+
| `SERVER_NAME` | Hostname | `localhost` | SQL Server hostname only |
|
|
176
|
+
| `SERVER_PORT` | Integer from `1` to `65535` | Driver default `1433` | SQL Server TCP port; omitted from the driver config when unset |
|
|
177
|
+
| `SQL_AUTH_TYPE` | See [Authentication](#authentication) | `sql` | SQL Server authentication method |
|
|
178
|
+
| `ENCRYPT` | `"true"` or `"false"` | `"false"` (`"true"` for Entra ID) | Enable TLS encryption in the `mssql` driver |
|
|
179
|
+
| `TRUST_SERVER_CERTIFICATE` | `"true"` or `"false"` | `"true"` (`"false"` for Entra ID) | Trust the SQL Server certificate without validating its chain |
|
|
180
|
+
| `READONLY` | `"true"` or `"false"` | `"false"` | Remove write and DDL tools when enabled |
|
|
181
|
+
| `ENABLE_DDL` | `"true"` or `"false"` | `"false"` | Allow registered DDL tools to execute |
|
|
182
|
+
| `CONNECTION_TIMEOUT` | Positive integer seconds | `30` | SQL Server connection timeout |
|
|
183
|
+
| `QUERY_TIMEOUT_MS` | Positive integer milliseconds | `30000` | SQL request timeout |
|
|
184
|
+
| `MAX_ROWS` | Positive integer | `10000` | Maximum rows returned by read tools |
|
|
185
|
+
| `MAX_WRITE_ROWS` | Positive integer | `100` | Maximum rows one write operation may affect |
|
|
186
|
+
| `REQUIRE_WRITE_PREVIEW` | `"true"` or `"false"` | `"true"` | Require a matching preview token for updates and deletes |
|
|
187
|
+
| `MCP_TRANSPORT` | `stdio` or `http` | `stdio` | MCP transport mode |
|
|
188
|
+
| `MCP_HTTP_HOST` | Host or IP string | `127.0.0.1` | Bind address for HTTP mode |
|
|
189
|
+
| `MCP_HTTP_PORT` | Integer from `1` to `65535` | `3333` | Bind port for HTTP mode |
|
|
190
|
+
| `MCP_BASE_URL` | Absolute HTTP or HTTPS URL | Unset | Public HTTP base advertised by the server; `/mcp` is appended |
|
|
191
|
+
| `MCP_HTTP_AUTH_TOKEN` | Nonblank string | Unset | Require `Authorization: Bearer <token>` on HTTP requests |
|
|
192
|
+
| `MCP_HTTP_ALLOWED_HOSTS`| Comma-separated hostnames | Loopback + bind host + `MCP_BASE_URL` host | Hostnames accepted in `Host`/`Origin` headers |
|
|
193
|
+
| `MCP_HTTP_ALLOW_UNAUTHENTICATED` | `"true"` or `"false"` | `"false"` | Allow a non-loopback `MCP_HTTP_HOST` without a token |
|
|
194
|
+
|
|
195
|
+
Blank optional values use their documented defaults. Explicit nonblank invalid integers, booleans, ports, URLs, or transport names fail validation rather than falling back silently.
|
|
196
|
+
|
|
197
|
+
`ENCRYPT=false` preserves the existing unencrypted connection behavior. Set `ENCRYPT=true` for TLS. With encryption enabled, keep `TRUST_SERVER_CERTIFICATE=false` for certificates that chain to a trusted authority. Use `TRUST_SERVER_CERTIFICATE=true` only when explicitly accepting a self-signed or otherwise untrusted certificate, such as local development.
|
|
198
|
+
|
|
199
|
+
## Multi-database behavior
|
|
200
|
+
|
|
201
|
+
`DATABASES` is an allowlist. Every tool accepts an optional `databaseName`. When a tool omits it, the server uses `DATABASE_NAME` if that name is allowed, otherwise it uses the first entry in `DATABASES`. A requested database outside the allowlist is rejected.
|
|
202
|
+
|
|
203
|
+
## Safe writes and DDL
|
|
204
|
+
|
|
205
|
+
`READONLY=true` removes insert, update, delete, and DDL tools. Read-only preview tools remain available because they do not modify data.
|
|
206
|
+
|
|
207
|
+
When writes are enabled:
|
|
208
|
+
|
|
209
|
+
1. `insert_data`, `update_data`, `delete_data`, and DDL tools ask the user to confirm through MCP elicitation when the client supports it (Cursor, VS Code, Claude). Clients without elicitation must pass `confirmed: true`. Over HTTP, prompts work for 2026-07-28 clients; 2025-era HTTP clients must pass `confirmed: true` because the stateless transport cannot carry their elicitation round trip.
|
|
210
|
+
2. `update_data` and `delete_data` require nonempty structured `filters`, not raw SQL WHERE text.
|
|
211
|
+
3. With the default `REQUIRE_WRITE_PREVIEW=true`, call `preview_update` or `preview_delete` first and pass its `previewToken` to the matching write.
|
|
212
|
+
4. Preview tokens expire after 10 minutes, are single-use, and are bound to the same tool, table, filters, and update payload.
|
|
213
|
+
5. `MAX_WRITE_ROWS` rejects oversized operations, and update/delete execution applies a row cap.
|
|
214
|
+
|
|
215
|
+
Supported filter operators are `=`, `!=`, `>`, `>=`, `<`, `<=`, `LIKE`, `IN`, `IS NULL`, and `IS NOT NULL`.
|
|
216
|
+
|
|
217
|
+
DDL tools are registered when `READONLY=false`, but calls fail with `DDL_DISABLED` unless `ENABLE_DDL=true`.
|
|
218
|
+
|
|
219
|
+
For `insert_data`, pass the table in `tableName` and the schema separately in `schemaName`. Do not use a dotted `schema.table` value for `tableName`.
|
|
220
|
+
|
|
221
|
+
## Streamable HTTP
|
|
222
|
+
|
|
223
|
+
The default transport is stdio. To run the stateless HTTP transport from a directory containing a configured `.env`:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
MCP_TRANSPORT=http npx -y @eamonboyle/mssql-mcp
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
The default endpoint is:
|
|
230
|
+
|
|
231
|
+
```text
|
|
232
|
+
http://127.0.0.1:3333/mcp
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The HTTP endpoint serves both the 2026-07-28 MCP protocol and 2025-era clients. A client must accept `application/json, text/event-stream`. Each HTTP request creates a fresh MCP server instance; preview tokens, stored query results, and query plans use process-wide stores, so they stay valid across requests to the same process.
|
|
236
|
+
|
|
237
|
+
HTTP security:
|
|
238
|
+
|
|
239
|
+
- Only `/mcp` is served. `Host` and `Origin` headers are checked against `MCP_HTTP_ALLOWED_HOSTS` (by default loopback names, the bind host, and the `MCP_BASE_URL` host) to block DNS-rebinding attacks from web pages.
|
|
240
|
+
- Set `MCP_HTTP_AUTH_TOKEN` to require `Authorization: Bearer <token>`.
|
|
241
|
+
- The server speaks plain HTTP. Off loopback, put a TLS-terminating reverse proxy in front so the bearer token and query results are encrypted, and set `MCP_BASE_URL` to its `https://` address. Startup logs a warning when a non-loopback bind has no `https://` `MCP_BASE_URL`.
|
|
242
|
+
- Binding `MCP_HTTP_HOST` to anything other than loopback fails at startup unless `MCP_HTTP_AUTH_TOKEN` is set, or `MCP_HTTP_ALLOW_UNAUTHENTICATED=true` acknowledges that another layer (reverse proxy, network policy) protects the endpoint.
|
|
243
|
+
|
|
244
|
+
For a reverse proxy or externally published path, set `MCP_BASE_URL` to the public base without the final `/mcp` segment:
|
|
245
|
+
|
|
246
|
+
```text
|
|
247
|
+
MCP_BASE_URL=https://example.com/services/mssql
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
The server continues binding to `MCP_HTTP_HOST:MCP_HTTP_PORT`, logs `https://example.com/services/mssql/mcp` as its public endpoint, and exposes that URL through `mssql://config/server`. `MCP_E2E_BASE_URL` is a separate test-harness variable used only by `scripts/e2e-mcp-tools.mjs`.
|
|
251
|
+
|
|
252
|
+
Cursor HTTP configuration:
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"mcpServers": {
|
|
257
|
+
"mssql-http": {
|
|
258
|
+
"url": "http://127.0.0.1:3333/mcp",
|
|
259
|
+
"headers": { "Authorization": "Bearer ${env:MSSQL_MCP_TOKEN}" }
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Omit `headers` when `MCP_HTTP_AUTH_TOKEN` is not set.
|
|
266
|
+
|
|
267
|
+
## Tools
|
|
268
|
+
|
|
269
|
+
| Tool | Mode | Purpose |
|
|
270
|
+
| ------------------------ | ----- | ---------------------------------------------------------------- |
|
|
271
|
+
| `list_databases` | Read | List configured databases |
|
|
272
|
+
| `list_table` | Read | List tables, optionally filtered by schema names in `parameters` |
|
|
273
|
+
| `describe_table` | Read | Describe a table schema |
|
|
274
|
+
| `list_objects` | Read | List tables, views, procedures, functions, and triggers |
|
|
275
|
+
| `describe_object` | Read | Return object metadata and definitions |
|
|
276
|
+
| `summarize_schema` | Read | Summarize object counts by type and schema |
|
|
277
|
+
| `list_largest_tables` | Read | Rank tables by storage and row count |
|
|
278
|
+
| `list_foreign_keys` | Read | List foreign keys |
|
|
279
|
+
| `describe_relationships` | Read | Describe foreign keys involving one table |
|
|
280
|
+
| `describe_dependencies` | Read | List objects that depend on an object |
|
|
281
|
+
| `analyze_table` | Read | Return row counts, storage, and index details |
|
|
282
|
+
| `read_data` | Read | Execute a validated SELECT (or CTE) query in a rolled-back transaction |
|
|
283
|
+
| `search_data` | Read | Search columns with parameterized LIKE predicates |
|
|
284
|
+
| `explain_query` | Read | Generate an estimated SELECT execution plan |
|
|
285
|
+
| `preview_update` | Read | Preview an update and issue a token when required |
|
|
286
|
+
| `preview_delete` | Read | Preview a delete and issue a token when required |
|
|
287
|
+
| `insert_data` | Write | Insert rows |
|
|
288
|
+
| `update_data` | Write | Update rows selected by structured filters |
|
|
289
|
+
| `delete_data` | Write | Delete rows selected by structured filters |
|
|
290
|
+
| `create_table` | DDL | Create a table |
|
|
291
|
+
| `create_index` | DDL | Create an index |
|
|
292
|
+
| `drop_table` | DDL | Drop a table |
|
|
293
|
+
|
|
294
|
+
## Resources and prompts
|
|
295
|
+
|
|
296
|
+
Clients with MCP resource support can discover:
|
|
297
|
+
|
|
298
|
+
- `mssql://config/server`
|
|
299
|
+
- `mssql://config/prompts`
|
|
300
|
+
- `mssql://database/{databaseName}/tables`
|
|
301
|
+
- `mssql://database/{databaseName}/objects`
|
|
302
|
+
- `mssql://database/{databaseName}/schema-summary`
|
|
303
|
+
- `mssql://database/{databaseName}/foreign-keys`
|
|
304
|
+
- `mssql://table/{databaseName}/{schemaName}/{tableName}`
|
|
305
|
+
- `mssql://object/{databaseName}/{schemaName}/{objectName}`
|
|
306
|
+
- `mssql://database/{databaseName}/object/{schemaName}/{objectName}/dependencies`
|
|
307
|
+
- `mssql://query-plan/{planId}`
|
|
308
|
+
- `mssql://query-result/{resultId}`
|
|
309
|
+
- `ui://mssql/query-results.html` (MCP Apps view)
|
|
310
|
+
|
|
311
|
+
Table and object listings are cached for 30 seconds. Query plan and large query result resources are temporary process-local artifacts.
|
|
312
|
+
|
|
313
|
+
### Query results grid (MCP Apps)
|
|
314
|
+
|
|
315
|
+
`read_data` and `search_data` declare an [MCP Apps](https://modelcontextprotocol.io/extensions/apps) view. Hosts that support MCP Apps (Claude, VS Code, Cursor 2.6+, and others) render results as a sortable, filterable grid inline in the conversation. Other clients ignore the view and use the normal text and structured result.
|
|
316
|
+
|
|
317
|
+
### read_data rules
|
|
318
|
+
|
|
319
|
+
`read_data` accepts one `SELECT` statement, optionally preceded by common table expressions (`WITH ...`). String literals, comments, and bracketed or quoted identifiers are ignored when checking for disallowed keywords, so `[Update]` columns or `'Update pending'` values are fine. Statements that modify data, execute code (`EXEC`, `sp_`/`xp_` procedures), declare variables, or read server identity (`@@` variables, `SUSER_SNAME()`) are rejected.
|
|
320
|
+
|
|
321
|
+
Every query also runs inside a transaction that is always rolled back, and results stream until `MAX_ROWS` rows have been read, at which point the query is cancelled and the result is marked `truncated`. SQL Server error messages (for example `Invalid column name`) are returned so the model can correct the query. Cancelling a tool call in the client cancels the running SQL request.
|
|
322
|
+
|
|
323
|
+
Available prompts:
|
|
324
|
+
|
|
325
|
+
- `explore_schema`
|
|
326
|
+
- `draft_safe_select`
|
|
327
|
+
- `review_write_operation`
|
|
328
|
+
|
|
329
|
+
## Development
|
|
330
|
+
|
|
331
|
+
For local source development only:
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
git clone https://github.com/eamonboyle/mssql-mcp.git
|
|
335
|
+
cd mssql-mcp
|
|
336
|
+
npm install
|
|
337
|
+
npm run build
|
|
338
|
+
node /path/to/mssql-mcp/dist/index.js
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
The repository includes a seeded SQL Server 2022 Docker environment:
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
cp .env.example .env
|
|
345
|
+
npm run db:up
|
|
346
|
+
npm run test:e2e # every tool over HTTP, then protocol checks (2026-07-28 + 2025 stdio)
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
See [`docs/dev-database.md`](docs/dev-database.md) for database and E2E details and [`CONTRIBUTING.md`](CONTRIBUTING.md) for build, lint, and test commands.
|
|
350
|
+
|
|
351
|
+
## Troubleshooting
|
|
352
|
+
|
|
353
|
+
- `SERVER_PORT must be a valid TCP port`: use a whole number from `1` to `65535`.
|
|
354
|
+
- `getaddrinfo ENOTFOUND localhost,1434`: move `1434` from `SERVER_NAME` to `SERVER_PORT`.
|
|
355
|
+
- `DDL_DISABLED`: set `ENABLE_DDL` to `"true"` only when DDL access is intended.
|
|
356
|
+
- `PREVIEW_TOKEN_INVALID`: create a new matching preview and use its token once within 10 minutes.
|
|
357
|
+
- stdio JSON parse errors: ensure scripts and dependencies write logs to stderr, not stdout.
|
|
358
|
+
- HTTP `403 Forbidden`: the request's `Host` or `Origin` is not in `MCP_HTTP_ALLOWED_HOSTS`; add the public hostname (or set `MCP_BASE_URL`).
|
|
359
|
+
- HTTP `401 Unauthorized`: send `Authorization: Bearer <MCP_HTTP_AUTH_TOKEN>`.
|
|
360
|
+
- database rejected: add it to `DATABASES` and use the exact allowed name in `databaseName`.
|
|
361
|
+
|
|
362
|
+
## Security
|
|
363
|
+
|
|
364
|
+
- Use a dedicated SQL login with the minimum permissions required.
|
|
365
|
+
- Set `READONLY=true` whenever writes are unnecessary.
|
|
366
|
+
- Keep `ENABLE_DDL=false` unless schema changes are explicitly needed.
|
|
367
|
+
- Keep credentials out of source control and use your client's secret-input support or a secrets manager.
|
|
368
|
+
- Keep HTTP mode on loopback, or set `MCP_HTTP_AUTH_TOKEN` and `MCP_HTTP_ALLOWED_HOSTS` when exposing it. Prefer TLS termination at a reverse proxy.
|
|
369
|
+
- `read_data` validation and its rolled-back transaction are defense in depth; a least-privilege login is still the primary control.
|
|
370
|
+
- Set `ENCRYPT=true` for TLS deployments and keep `TRUST_SERVER_CERTIFICATE=false` when the server certificate is publicly or privately trusted.
|
|
371
|
+
- Report vulnerabilities through the [security policy](.github/SECURITY.md).
|
|
372
|
+
|
|
373
|
+
## Project links
|
|
374
|
+
|
|
375
|
+
- [Changelog](CHANGELOG.md)
|
|
376
|
+
- [Contributing](CONTRIBUTING.md)
|
|
377
|
+
- [Code of Conduct](CODE_OF_CONDUCT.md)
|
|
378
|
+
- [Security Policy](.github/SECURITY.md)
|
|
379
|
+
- [License](LICENSE)
|