@eamonboyle/mssql-mcp 1.1.0 → 1.3.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 +169 -22
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +74 -0
- package/dist/config.js.map +1 -0
- package/dist/db.d.ts +29 -24
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +144 -112
- package/dist/db.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +382 -122
- package/dist/index.js.map +1 -1
- package/dist/mcpResults.d.ts +49 -0
- package/dist/mcpResults.d.ts.map +1 -0
- package/dist/mcpResults.js +246 -0
- package/dist/mcpResults.js.map +1 -0
- package/dist/promptRegistry.d.ts +16 -0
- package/dist/promptRegistry.d.ts.map +1 -0
- package/dist/promptRegistry.js +112 -0
- package/dist/promptRegistry.js.map +1 -0
- package/dist/resourceRegistry.d.ts +14 -0
- package/dist/resourceRegistry.d.ts.map +1 -0
- package/dist/resourceRegistry.js +311 -0
- package/dist/resourceRegistry.js.map +1 -0
- package/dist/schema.d.ts +57 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +390 -0
- package/dist/schema.js.map +1 -0
- package/dist/serverState.d.ts +28 -0
- package/dist/serverState.d.ts.map +1 -0
- package/dist/serverState.js +99 -0
- package/dist/serverState.js.map +1 -0
- package/dist/sql.d.ts +7 -0
- package/dist/sql.d.ts.map +1 -0
- package/dist/sql.js +73 -0
- package/dist/sql.js.map +1 -0
- package/dist/toolRegistry.d.ts +20 -0
- package/dist/toolRegistry.d.ts.map +1 -0
- package/dist/toolRegistry.js +547 -0
- package/dist/toolRegistry.js.map +1 -0
- package/dist/tools/AnalyzeTableTool.d.ts +37 -0
- package/dist/tools/AnalyzeTableTool.d.ts.map +1 -0
- package/dist/tools/AnalyzeTableTool.js +81 -0
- package/dist/tools/AnalyzeTableTool.js.map +1 -0
- package/dist/tools/CreateIndexTool.d.ts +30 -23
- package/dist/tools/CreateIndexTool.d.ts.map +1 -1
- package/dist/tools/CreateIndexTool.js +47 -77
- package/dist/tools/CreateIndexTool.js.map +1 -1
- package/dist/tools/CreateTableTool.d.ts +18 -11
- package/dist/tools/CreateTableTool.d.ts.map +1 -1
- package/dist/tools/CreateTableTool.js +37 -61
- package/dist/tools/CreateTableTool.js.map +1 -1
- package/dist/tools/DeleteDataTool.d.ts +22 -0
- package/dist/tools/DeleteDataTool.d.ts.map +1 -0
- package/dist/tools/DeleteDataTool.js +38 -0
- package/dist/tools/DeleteDataTool.js.map +1 -0
- package/dist/tools/DescribeObjectTool.d.ts +21 -0
- package/dist/tools/DescribeObjectTool.d.ts.map +1 -0
- package/dist/tools/DescribeObjectTool.js +31 -0
- package/dist/tools/DescribeObjectTool.js.map +1 -0
- package/dist/tools/DescribeRelationshipsTool.d.ts +20 -0
- package/dist/tools/DescribeRelationshipsTool.d.ts.map +1 -0
- package/dist/tools/DescribeRelationshipsTool.js +24 -0
- package/dist/tools/DescribeRelationshipsTool.js.map +1 -0
- package/dist/tools/DescribeTableTool.d.ts +19 -20
- package/dist/tools/DescribeTableTool.d.ts.map +1 -1
- package/dist/tools/DescribeTableTool.js +23 -44
- package/dist/tools/DescribeTableTool.js.map +1 -1
- package/dist/tools/DropTableTool.d.ts +13 -11
- package/dist/tools/DropTableTool.d.ts.map +1 -1
- package/dist/tools/DropTableTool.js +30 -44
- package/dist/tools/DropTableTool.js.map +1 -1
- package/dist/tools/ExplainQueryTool.d.ts +32 -0
- package/dist/tools/ExplainQueryTool.d.ts.map +1 -0
- package/dist/tools/ExplainQueryTool.js +102 -0
- package/dist/tools/ExplainQueryTool.js.map +1 -0
- package/dist/tools/InsertDataTool.d.ts +20 -16
- package/dist/tools/InsertDataTool.d.ts.map +1 -1
- package/dist/tools/InsertDataTool.js +91 -108
- package/dist/tools/InsertDataTool.js.map +1 -1
- package/dist/tools/ListDatabasesTool.d.ts +16 -0
- package/dist/tools/ListDatabasesTool.d.ts.map +1 -0
- package/dist/tools/ListDatabasesTool.js +26 -0
- package/dist/tools/ListDatabasesTool.js.map +1 -0
- package/dist/tools/ListForeignKeysTool.d.ts +19 -0
- package/dist/tools/ListForeignKeysTool.d.ts.map +1 -0
- package/dist/tools/ListForeignKeysTool.js +24 -0
- package/dist/tools/ListForeignKeysTool.js.map +1 -0
- package/dist/tools/ListObjectsTool.d.ts +20 -0
- package/dist/tools/ListObjectsTool.d.ts.map +1 -0
- package/dist/tools/ListObjectsTool.js +26 -0
- package/dist/tools/ListObjectsTool.js.map +1 -0
- package/dist/tools/ListTableTool.d.ts +20 -16
- package/dist/tools/ListTableTool.d.ts.map +1 -1
- package/dist/tools/ListTableTool.js +32 -51
- package/dist/tools/ListTableTool.js.map +1 -1
- package/dist/tools/PreviewDeleteTool.d.ts +28 -0
- package/dist/tools/PreviewDeleteTool.d.ts.map +1 -0
- package/dist/tools/PreviewDeleteTool.js +31 -0
- package/dist/tools/PreviewDeleteTool.js.map +1 -0
- package/dist/tools/PreviewUpdateTool.d.ts +30 -0
- package/dist/tools/PreviewUpdateTool.d.ts.map +1 -0
- package/dist/tools/PreviewUpdateTool.js +34 -0
- package/dist/tools/PreviewUpdateTool.js.map +1 -0
- package/dist/tools/ReadDataTool.d.ts +35 -33
- package/dist/tools/ReadDataTool.d.ts.map +1 -1
- package/dist/tools/ReadDataTool.js +92 -105
- package/dist/tools/ReadDataTool.js.map +1 -1
- package/dist/tools/SearchDataTool.d.ts +27 -0
- package/dist/tools/SearchDataTool.d.ts.map +1 -0
- package/dist/tools/SearchDataTool.js +61 -0
- package/dist/tools/SearchDataTool.js.map +1 -0
- package/dist/tools/UpdateDataTool.d.ts +22 -16
- package/dist/tools/UpdateDataTool.d.ts.map +1 -1
- package/dist/tools/UpdateDataTool.js +48 -65
- package/dist/tools/UpdateDataTool.js.map +1 -1
- package/dist/validation.d.ts +13 -13
- package/dist/validation.js +133 -133
- package/dist/validation.js.map +1 -1
- package/dist/writePreview.d.ts +20 -0
- package/dist/writePreview.d.ts.map +1 -0
- package/dist/writePreview.js +27 -0
- package/dist/writePreview.js.map +1 -0
- package/dist/writePreviewGrant.d.ts +18 -0
- package/dist/writePreviewGrant.d.ts.map +1 -0
- package/dist/writePreviewGrant.js +71 -0
- package/dist/writePreviewGrant.js.map +1 -0
- package/dist/writePreviewGrantStore.d.ts +10 -0
- package/dist/writePreviewGrantStore.d.ts.map +1 -0
- package/dist/writePreviewGrantStore.js +47 -0
- package/dist/writePreviewGrantStore.js.map +1 -0
- package/dist/writeSafety.d.ts +21 -0
- package/dist/writeSafety.d.ts.map +1 -0
- package/dist/writeSafety.js +169 -0
- package/dist/writeSafety.js.map +1 -0
- package/package.json +6 -5
- package/dist/__tests__/db.test.d.ts +0 -2
- package/dist/__tests__/db.test.d.ts.map +0 -1
- package/dist/__tests__/db.test.js +0 -204
- package/dist/__tests__/db.test.js.map +0 -1
- package/dist/__tests__/validation.test.d.ts +0 -2
- package/dist/__tests__/validation.test.d.ts.map +0 -1
- package/dist/__tests__/validation.test.js +0 -111
- package/dist/__tests__/validation.test.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@eamonboyle/mssql-mcp)
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
|
|
7
|
-
[](https://cursor.com/en/install-mcp?name=MSSQL&config=
|
|
8
|
-
[](https://intradeus.github.io/http-protocol-redirector?r=vscode%
|
|
7
|
+
[](https://cursor.com/en/install-mcp?name=MSSQL&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBlYW1vbmJveWxlL21zc3FsLW1jcCJdLCJlbnYiOnsiU0VSVkVSX05BTUUiOiJsb2NhbGhvc3QiLCJEQVRBQkFTRV9OQU1FIjoiWW91ckRhdGFiYXNlIiwiREFUQUJBU0VTIjoiIiwiREJfVVNFUiI6IiIsIkRCX1BBU1NXT1JEIjoiIiwiUkVBRE9OTFkiOiJmYWxzZSIsIkNPTk5FQ1RJT05fVElNRU9VVCI6IjMwIiwiUVVFUllfVElNRU9VVF9NUyI6IjMwMDAwIiwiTUFYX1JPV1MiOiIxMDAwMCIsIlRSVVNUX1NFUlZFUl9DRVJUSUZJQ0FURSI6ImZhbHNlIiwiTUNQX1RSQU5TUE9SVCI6InN0ZGlvIiwiTUNQX0hUVFBfSE9TVCI6IjEyNy4wLjAuMSIsIk1DUF9IVFRQX1BPUlQiOiIzMzMzIiwiTUNQX0JBU0VfVVJMIjoiIiwiRU5BQkxFX0RETCI6ImZhbHNlIiwiTUFYX1dSSVRFX1JPV1MiOiIxMDAiLCJSRVFVSVJFX1dSSVRFX1BSRVZJRVciOiJ0cnVlIn19)
|
|
8
|
+
[](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%2522YourDatabase%2522%252C%2522DATABASES%2522%253A%2522%2522%252C%2522DB_USER%2522%253A%2522%2522%252C%2522DB_PASSWORD%2522%253A%2522%2522%252C%2522READONLY%2522%253A%2522false%2522%252C%2522CONNECTION_TIMEOUT%2522%253A%252230%2522%252C%2522QUERY_TIMEOUT_MS%2522%253A%252230000%2522%252C%2522MAX_ROWS%2522%253A%252210000%2522%252C%2522TRUST_SERVER_CERTIFICATE%2522%253A%2522false%2522%252C%2522MCP_TRANSPORT%2522%253A%2522stdio%2522%252C%2522MCP_HTTP_HOST%2522%253A%2522127.0.0.1%2522%252C%2522MCP_HTTP_PORT%2522%253A%25223333%2522%252C%2522MCP_BASE_URL%2522%253A%2522%2522%252C%2522ENABLE_DDL%2522%253A%2522false%2522%252C%2522MAX_WRITE_ROWS%2522%253A%2522100%2522%252C%2522REQUIRE_WRITE_PREVIEW%2522%253A%2522true%2522%257D%257D)
|
|
9
9
|
|
|
10
10
|
> ⚠️ **EXPERIMENTAL USE ONLY** — This MCP Server is provided for educational and experimental purposes. It is NOT intended for production use. Use appropriate security measures and test thoroughly before any deployment.
|
|
11
11
|
|
|
@@ -23,11 +23,16 @@ AI: *queries your MSSQL database and returns the results in plain English*
|
|
|
23
23
|
## Features 📊
|
|
24
24
|
|
|
25
25
|
- **Natural language to SQL** — Ask questions in plain English
|
|
26
|
-
- **CRUD
|
|
27
|
-
- **Schema
|
|
26
|
+
- **Row-level CRUD support** — Read, insert, update, and delete rows with dedicated tools
|
|
27
|
+
- **Schema discovery** — Inspect tables, views, procedures, functions, and triggers
|
|
28
|
+
- **Safer write workflows** — `preview_update` and `preview_delete` plus confirmation gating for destructive tools
|
|
29
|
+
- **Rich text tool results** — Concise summaries with JSON inlined in the primary text block when helpful, plus resource links for large artifacts
|
|
30
|
+
- **Query analysis** — Generate estimated execution plans with `explain_query`
|
|
31
|
+
- **MCP resources and prompts** — Expose schema snapshots, query artifacts, and prompt templates to capable clients
|
|
32
|
+
- **Remote transport support** — Run locally over `stdio` or remotely over Streamable HTTP
|
|
28
33
|
- **Multi-database support** — Connect to multiple databases on the same server
|
|
29
|
-
- **Read-only mode** — Restrict to
|
|
30
|
-
- **Secure by default** — WHERE clauses required for
|
|
34
|
+
- **Read-only mode** — Restrict to inspection, search, read, and explain tools for safer environments
|
|
35
|
+
- **Secure by default** — WHERE clauses required for updates/deletes; SQL injection safeguards for reads; DDL tools off unless `ENABLE_DDL=true`
|
|
31
36
|
|
|
32
37
|
## Supported AI Clients
|
|
33
38
|
|
|
@@ -40,7 +45,11 @@ AI: *queries your MSSQL database and returns the results in plain English*
|
|
|
40
45
|
|
|
41
46
|
### One-Click Install (Cursor / VS Code)
|
|
42
47
|
|
|
43
|
-
Click **Add to Cursor** or **Install in VS Code** above to add the MCP server
|
|
48
|
+
Click **Add to Cursor** or **Install in VS Code** above to add the MCP server—no cloning required; it runs via `npx`.
|
|
49
|
+
|
|
50
|
+
**Cursor** opens a dedicated install page that lists env vars you can edit before saving (similar to a short form). The **Add to Cursor** preset includes every variable from the table below (connection, timeouts, **`ENABLE_DDL`** defaulting to **`false`**, write caps, **`MCP_TRANSPORT`** / HTTP settings, **`MCP_BASE_URL`**, etc.); set **`ENABLE_DDL`** to **`true`** there if you want schema tools.
|
|
51
|
+
|
|
52
|
+
**VS Code** only applies the JSON embedded in the `vscode:mcp/install` link: you get static placeholder values, not an interactive database wizard. To be prompted for host, database, and credentials when the server starts, add [`inputs`](https://code.visualstudio.com/docs/copilot/reference/mcp-configuration#_input-variables-for-sensitive-data) to `.vscode/mcp.json` as in the **Prompted inputs** example under **VS Code (`mcp.json`)** below.
|
|
44
53
|
|
|
45
54
|
### Prerequisites
|
|
46
55
|
|
|
@@ -80,15 +89,24 @@ npm run build
|
|
|
80
89
|
| `READONLY` | No | `"true"` for read-only mode, `"false"` for full access (default: `"false"`) |
|
|
81
90
|
| `DATABASES` | No | Comma-separated allowlist for multi-database access (e.g., `ProdDB,StagingDB`) |
|
|
82
91
|
| `CONNECTION_TIMEOUT` | No | Timeout in seconds (default: `30`) |
|
|
92
|
+
| `QUERY_TIMEOUT_MS` | No | Query timeout in milliseconds (default: `30000`) |
|
|
93
|
+
| `MAX_ROWS` | No | Maximum rows returned by read tools (default: `10000`) |
|
|
83
94
|
| `TRUST_SERVER_CERTIFICATE` | No | `"true"` for self-signed certs (e.g., local dev) (default: `"false"`) |
|
|
95
|
+
| `MCP_TRANSPORT` | No | `stdio` (default) or `http` |
|
|
96
|
+
| `MCP_HTTP_HOST` | No | Bind host for Streamable HTTP mode (default: `127.0.0.1`) |
|
|
97
|
+
| `MCP_HTTP_PORT` | No | Bind port for Streamable HTTP mode (default: `3333`) |
|
|
98
|
+
| `MCP_BASE_URL` | No | Optional externally visible base URL for remote deployments |
|
|
99
|
+
| `ENABLE_DDL` | No | `"true"` enables `create_table`, `create_index`, and `drop_table` (default: `false`) |
|
|
100
|
+
| `MAX_WRITE_ROWS` | No | Maximum rows a single write tool may affect before it is blocked (default: `100`) |
|
|
101
|
+
| `REQUIRE_WRITE_PREVIEW` | No | `"true"` (default): call `preview_update` / `preview_delete`, then pass the returned `previewToken` with `confirmed=true` on `update_data` / `delete_data`. Set `"false"` to skip the token (confirmation still applies). |
|
|
84
102
|
|
|
85
103
|
\* Required for SQL authentication. For Windows/Integrated authentication, consult the [mssql](https://www.npmjs.com/package/mssql) package documentation.
|
|
86
104
|
|
|
87
105
|
\*\* Required for single-database setups. When `DATABASES` is provided, `DATABASE_NAME` becomes optional and is used as the default database if set.
|
|
88
106
|
|
|
89
|
-
###
|
|
107
|
+
### Cursor (`mcp.json`)
|
|
90
108
|
|
|
91
|
-
|
|
109
|
+
Use [global or project MCP config](https://cursor.com/docs/context/mcp): e.g. `~/.cursor/mcp.json` or `.cursor/mcp.json` in your repo.
|
|
92
110
|
|
|
93
111
|
```json
|
|
94
112
|
{
|
|
@@ -109,9 +127,113 @@ npm run build
|
|
|
109
127
|
}
|
|
110
128
|
```
|
|
111
129
|
|
|
112
|
-
|
|
130
|
+
Restart Cursor after changes.
|
|
131
|
+
|
|
132
|
+
### Cursor HTTP MCP
|
|
133
|
+
|
|
134
|
+
To expose the server remotely over Streamable HTTP:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"mcpServers": {
|
|
139
|
+
"mssql-http": {
|
|
140
|
+
"url": "http://127.0.0.1:3333"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Run the server with:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
MCP_TRANSPORT=http MCP_HTTP_HOST=127.0.0.1 MCP_HTTP_PORT=3333 npx -y @eamonboyle/mssql-mcp
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### VS Code (`mcp.json`)
|
|
153
|
+
|
|
154
|
+
VS Code uses `.vscode/mcp.json` (or **MCP: Open User Configuration**) with a top-level [`servers`](https://code.visualstudio.com/docs/copilot/reference/mcp-configuration) object—**not** `mcpServers`.
|
|
113
155
|
|
|
114
|
-
|
|
156
|
+
**Static env** (same idea as the one-click link; edit values in the file):
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"servers": {
|
|
161
|
+
"mssql": {
|
|
162
|
+
"type": "stdio",
|
|
163
|
+
"command": "npx",
|
|
164
|
+
"args": ["-y", "@eamonboyle/mssql-mcp"],
|
|
165
|
+
"env": {
|
|
166
|
+
"SERVER_NAME": "localhost",
|
|
167
|
+
"DATABASE_NAME": "AppDB",
|
|
168
|
+
"DATABASES": "AppDB,ReportingDB",
|
|
169
|
+
"DB_USER": "your_username",
|
|
170
|
+
"DB_PASSWORD": "your_password",
|
|
171
|
+
"READONLY": "false",
|
|
172
|
+
"CONNECTION_TIMEOUT": "30",
|
|
173
|
+
"QUERY_TIMEOUT_MS": "30000",
|
|
174
|
+
"MAX_ROWS": "10000",
|
|
175
|
+
"TRUST_SERVER_CERTIFICATE": "false"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Prompted inputs** (closest to Cursor’s hosted form: VS Code asks on first start, then stores values). Use `${input:…}` in `env` and define matching entries under `inputs`:
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"inputs": [
|
|
187
|
+
{
|
|
188
|
+
"type": "promptString",
|
|
189
|
+
"id": "mssql-server",
|
|
190
|
+
"description": "SQL Server host (e.g. localhost or my-server.database.windows.net)"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"type": "promptString",
|
|
194
|
+
"id": "mssql-database",
|
|
195
|
+
"description": "Default database name"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"type": "promptString",
|
|
199
|
+
"id": "mssql-databases",
|
|
200
|
+
"description": "Optional: comma-separated DB allowlist (e.g. AppDB,ReportingDB). Leave empty for a single database."
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"type": "promptString",
|
|
204
|
+
"id": "mssql-user",
|
|
205
|
+
"description": "SQL Server login (SQL authentication)"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"type": "promptString",
|
|
209
|
+
"id": "mssql-password",
|
|
210
|
+
"description": "SQL Server password",
|
|
211
|
+
"password": true
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
"servers": {
|
|
215
|
+
"mssql": {
|
|
216
|
+
"type": "stdio",
|
|
217
|
+
"command": "npx",
|
|
218
|
+
"args": ["-y", "@eamonboyle/mssql-mcp"],
|
|
219
|
+
"env": {
|
|
220
|
+
"SERVER_NAME": "${input:mssql-server}",
|
|
221
|
+
"DATABASE_NAME": "${input:mssql-database}",
|
|
222
|
+
"DATABASES": "${input:mssql-databases}",
|
|
223
|
+
"DB_USER": "${input:mssql-user}",
|
|
224
|
+
"DB_PASSWORD": "${input:mssql-password}",
|
|
225
|
+
"READONLY": "false",
|
|
226
|
+
"CONNECTION_TIMEOUT": "30",
|
|
227
|
+
"QUERY_TIMEOUT_MS": "30000",
|
|
228
|
+
"MAX_ROWS": "10000",
|
|
229
|
+
"TRUST_SERVER_CERTIFICATE": "false"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Claude Desktop Setup
|
|
115
237
|
|
|
116
238
|
1. Open **File → Settings → Developer → Edit Config**
|
|
117
239
|
2. Add the MCP server configuration:
|
|
@@ -166,30 +288,55 @@ See `src/samples/` for example configs:
|
|
|
166
288
|
Once configured, you can ask things like:
|
|
167
289
|
|
|
168
290
|
- "Show me all users from New York"
|
|
291
|
+
- "List the configured databases this MCP can access"
|
|
292
|
+
- "Preview the rows that would be updated before changing status to archived"
|
|
293
|
+
- "Explain this query and open the execution plan viewer"
|
|
294
|
+
- "Show the foreign keys and relationships around dbo.Orders"
|
|
295
|
+
- "Search the customers table for email addresses containing acme.com"
|
|
169
296
|
- "Create a new table called products with columns for id, name, and price"
|
|
170
297
|
- "Update all pending orders to completed status"
|
|
298
|
+
- "Delete inactive sessions older than 30 days"
|
|
171
299
|
- "List all tables in the database"
|
|
172
300
|
- "Describe the schema of the customers table"
|
|
301
|
+
- "List all views and procedures in the reporting database"
|
|
302
|
+
- "Explain why this SELECT query is slow"
|
|
173
303
|
|
|
174
304
|
## Available Tools
|
|
175
305
|
|
|
176
|
-
| Tool
|
|
177
|
-
|
|
|
178
|
-
| `read_data`
|
|
179
|
-
| `
|
|
180
|
-
| `
|
|
181
|
-
| `
|
|
182
|
-
| `
|
|
183
|
-
| `
|
|
184
|
-
| `
|
|
185
|
-
| `
|
|
306
|
+
| Tool | Read-only | Description |
|
|
307
|
+
| ----------------- | --------- | ------------------------------------------------------- |
|
|
308
|
+
| `read_data` | ✓ | Execute validated SELECT queries |
|
|
309
|
+
| `search_data` | ✓ | Search one or more columns with parameterized `LIKE` |
|
|
310
|
+
| `explain_query` | ✓ | Get an estimated execution plan for a SELECT query |
|
|
311
|
+
| `list_table` | ✓ | List tables in a database |
|
|
312
|
+
| `describe_table` | ✓ | Get table schema (optional `schemaName`) |
|
|
313
|
+
| `list_objects` | ✓ | List tables, views, procedures, functions, and triggers |
|
|
314
|
+
| `describe_object` | ✓ | Describe an object definition and metadata |
|
|
315
|
+
| `insert_data` | | Insert rows |
|
|
316
|
+
| `update_data` | | Update rows (requires WHERE; optional `schemaName`) |
|
|
317
|
+
| `delete_data` | | Delete rows (requires WHERE; optional `schemaName`) |
|
|
318
|
+
| `create_table` | | Create tables |
|
|
319
|
+
| `create_index` | | Create indexes |
|
|
320
|
+
| `drop_table` | | Drop tables |
|
|
321
|
+
|
|
322
|
+
## Resources And Prompts
|
|
323
|
+
|
|
324
|
+
Clients that support MCP resources and prompts can use additional discovery surfaces:
|
|
325
|
+
|
|
326
|
+
- **Resources** — Server config, prompt catalog, per-database table lists, per-database object lists, and dynamic table/object resources
|
|
327
|
+
- **Prompts** — `explore_schema`, `draft_safe_select`, and `review_write_operation`
|
|
328
|
+
|
|
329
|
+
## Changelog
|
|
330
|
+
|
|
331
|
+
Release notes: [CHANGELOG.md](https://github.com/eamonboyle/mssql-mcp/blob/main/CHANGELOG.md).
|
|
186
332
|
|
|
187
333
|
## Security Notes
|
|
188
334
|
|
|
189
335
|
- **Credentials** — Never commit `DB_USER`/`DB_PASSWORD` or config files with secrets. Use environment variables or a secrets manager.
|
|
190
336
|
- **Read-only mode** — Set `READONLY: "true"` when you only need queries.
|
|
191
|
-
- **WHERE clauses** —
|
|
337
|
+
- **WHERE clauses** — Update and delete operations require explicit WHERE clauses to reduce accidental full-table changes.
|
|
192
338
|
- **SQL injection** — The server validates and restricts dangerous SQL patterns.
|
|
339
|
+
- **DDL tools** — Disabled by default (`ENABLE_DDL` unset or `false`). Set `ENABLE_DDL=true` only if the assistant should create/drop tables or indexes.
|
|
193
340
|
|
|
194
341
|
## Contributing
|
|
195
342
|
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type McpTransportMode = "stdio" | "http";
|
|
2
|
+
export declare function getMaxRows(): number;
|
|
3
|
+
export declare function getQueryTimeoutMs(): number;
|
|
4
|
+
export declare function getDefaultSearchLimit(): number;
|
|
5
|
+
export declare function clampRowLimit(limit: unknown, fallback?: number): number;
|
|
6
|
+
export declare function getMcpTransport(): McpTransportMode;
|
|
7
|
+
export declare function getMcpHttpPort(): number;
|
|
8
|
+
export declare function getMcpHttpHost(): string;
|
|
9
|
+
export declare function getMcpBaseUrl(): string | undefined;
|
|
10
|
+
export declare function isDdlEnabled(): boolean;
|
|
11
|
+
export declare function getMaxWriteRows(): number;
|
|
12
|
+
export declare function isWritePreviewRequired(): boolean;
|
|
13
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA4CA,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAK1C;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,SAAe,GAAG,MAAM,CAa7E;AAED,wBAAgB,eAAe,IAAI,gBAAgB,CAIlD;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAGlD;AAED,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED,wBAAgB,eAAe,IAAI,MAAM,CAKxC;AAED,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const DEFAULT_MAX_ROWS = 10000;
|
|
2
|
+
const DEFAULT_QUERY_TIMEOUT_MS = 30000;
|
|
3
|
+
const DEFAULT_SEARCH_LIMIT = 100;
|
|
4
|
+
const DEFAULT_HTTP_PORT = 3333;
|
|
5
|
+
const DEFAULT_HTTP_HOST = "127.0.0.1";
|
|
6
|
+
const DEFAULT_MAX_WRITE_ROWS = 100;
|
|
7
|
+
function parsePositiveInt(value, fallback, minimum = 1) {
|
|
8
|
+
if (!value) {
|
|
9
|
+
return fallback;
|
|
10
|
+
}
|
|
11
|
+
const parsed = Number.parseInt(value, 10);
|
|
12
|
+
if (!Number.isFinite(parsed) || parsed < minimum) {
|
|
13
|
+
return fallback;
|
|
14
|
+
}
|
|
15
|
+
return parsed;
|
|
16
|
+
}
|
|
17
|
+
function parseBoolean(value, fallback) {
|
|
18
|
+
if (!value) {
|
|
19
|
+
return fallback;
|
|
20
|
+
}
|
|
21
|
+
const normalized = value.trim().toLowerCase();
|
|
22
|
+
if (normalized === "true") {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (normalized === "false") {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return fallback;
|
|
29
|
+
}
|
|
30
|
+
export function getMaxRows() {
|
|
31
|
+
return parsePositiveInt(process.env.MAX_ROWS, DEFAULT_MAX_ROWS);
|
|
32
|
+
}
|
|
33
|
+
export function getQueryTimeoutMs() {
|
|
34
|
+
return parsePositiveInt(process.env.QUERY_TIMEOUT_MS, DEFAULT_QUERY_TIMEOUT_MS);
|
|
35
|
+
}
|
|
36
|
+
export function getDefaultSearchLimit() {
|
|
37
|
+
return Math.min(getMaxRows(), DEFAULT_SEARCH_LIMIT);
|
|
38
|
+
}
|
|
39
|
+
export function clampRowLimit(limit, fallback = getMaxRows()) {
|
|
40
|
+
const parsed = typeof limit === "number"
|
|
41
|
+
? limit
|
|
42
|
+
: typeof limit === "string"
|
|
43
|
+
? Number.parseInt(limit, 10)
|
|
44
|
+
: Number.NaN;
|
|
45
|
+
if (!Number.isFinite(parsed) || parsed < 1) {
|
|
46
|
+
return Math.min(fallback, getMaxRows());
|
|
47
|
+
}
|
|
48
|
+
return Math.min(Math.floor(parsed), getMaxRows());
|
|
49
|
+
}
|
|
50
|
+
export function getMcpTransport() {
|
|
51
|
+
return process.env.MCP_TRANSPORT?.trim().toLowerCase() === "http"
|
|
52
|
+
? "http"
|
|
53
|
+
: "stdio";
|
|
54
|
+
}
|
|
55
|
+
export function getMcpHttpPort() {
|
|
56
|
+
return parsePositiveInt(process.env.MCP_HTTP_PORT, DEFAULT_HTTP_PORT);
|
|
57
|
+
}
|
|
58
|
+
export function getMcpHttpHost() {
|
|
59
|
+
return process.env.MCP_HTTP_HOST?.trim() || DEFAULT_HTTP_HOST;
|
|
60
|
+
}
|
|
61
|
+
export function getMcpBaseUrl() {
|
|
62
|
+
const value = process.env.MCP_BASE_URL?.trim();
|
|
63
|
+
return value ? value : undefined;
|
|
64
|
+
}
|
|
65
|
+
export function isDdlEnabled() {
|
|
66
|
+
return parseBoolean(process.env.ENABLE_DDL, false);
|
|
67
|
+
}
|
|
68
|
+
export function getMaxWriteRows() {
|
|
69
|
+
return parsePositiveInt(process.env.MAX_WRITE_ROWS, DEFAULT_MAX_WRITE_ROWS);
|
|
70
|
+
}
|
|
71
|
+
export function isWritePreviewRequired() {
|
|
72
|
+
return parseBoolean(process.env.REQUIRE_WRITE_PREVIEW, true);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,MAAM,wBAAwB,GAAG,KAAK,CAAC;AACvC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,iBAAiB,GAAG,WAAW,CAAC;AACtC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,SAAS,gBAAgB,CACvB,KAAyB,EACzB,QAAgB,EAChB,OAAO,GAAG,CAAC;IAEX,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,OAAO,EAAE,CAAC;QACjD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CACnB,KAAyB,EACzB,QAAiB;IAEjB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,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|
-
|
|
24
|
-
|
|
1
|
+
import sql from "mssql";
|
|
2
|
+
export declare function getDefaultDatabaseName(): string | null;
|
|
3
|
+
/**
|
|
4
|
+
* Returns the list of allowed database names.
|
|
5
|
+
* If DATABASES is set, returns those; otherwise returns only DATABASE_NAME.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getAllowedDatabases(): string[];
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the database name to use (param or default).
|
|
10
|
+
* Returns null if invalid.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveDatabaseName(databaseName?: string): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Ensures a connection pool exists for the given database.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ensureSqlConnection(databaseName: string): Promise<sql.ConnectionPool>;
|
|
17
|
+
/**
|
|
18
|
+
* Returns a sql.Request for the given database.
|
|
19
|
+
* Resolves database name (param or default), validates against allowed list,
|
|
20
|
+
* ensures connection, and returns pool.request().
|
|
21
|
+
*/
|
|
22
|
+
export declare function getSqlRequest(databaseName?: string): Promise<{
|
|
23
|
+
request: sql.Request;
|
|
24
|
+
error?: string;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function getDedicatedSqlPool(databaseName?: string): Promise<{
|
|
27
|
+
pool: sql.ConnectionPool;
|
|
28
|
+
error?: string;
|
|
29
|
+
}>;
|
|
25
30
|
//# sourceMappingURL=db.d.ts.map
|
package/dist/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAC;AAiBxB,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAatD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAQ9C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQxE;AA6CD;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAoB7B;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC;IAAE,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAWnD;AAED,wBAAsB,mBAAmB,CACvC,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,CAAC,cAAc,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAqBvD"}
|