@vicinitysoftware/mcp-sql 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/dist/index.js +26 -13
  2. package/package.json +5 -3
package/dist/index.js CHANGED
@@ -2,32 +2,45 @@
2
2
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
- import * as sql from "mssql";
6
5
  import * as fs from "fs";
7
6
  import * as path from "path";
8
7
  import * as url from "url";
9
8
  import * as dotenv from "dotenv";
10
9
  dotenv.config();
11
10
  // ── Database config ───────────────────────────────────────────────────────────
11
+ const useWindowsAuth = !process.env.VICINITY_SQL_USER && !process.env.VICINITY_SQL_PASSWORD;
12
12
  const dbConfig = {
13
13
  server: process.env.VICINITY_SQL_SERVER,
14
14
  database: process.env.VICINITY_SQL_DATABASE,
15
- user: process.env.VICINITY_SQL_USER,
16
- password: process.env.VICINITY_SQL_PASSWORD,
17
- port: parseInt(process.env.VICINITY_SQL_PORT || "1433"),
18
- options: {
19
- encrypt: process.env.VICINITY_SQL_ENCRYPT === "true",
20
- trustServerCertificate: process.env.VICINITY_SQL_TRUST_SERVER_CERT !== "false",
21
- connectTimeout: 15000,
22
- requestTimeout: parseInt(process.env.VICINITY_SQL_TIMEOUT || "30000"),
23
- },
15
+ ...(useWindowsAuth
16
+ ? {
17
+ options: {
18
+ trustedConnection: true,
19
+ trustServerCertificate: true,
20
+ connectTimeout: 15000,
21
+ requestTimeout: parseInt(process.env.VICINITY_SQL_TIMEOUT || "30000"),
22
+ },
23
+ }
24
+ : {
25
+ user: process.env.VICINITY_SQL_USER,
26
+ password: process.env.VICINITY_SQL_PASSWORD,
27
+ port: parseInt(process.env.VICINITY_SQL_PORT || "1433"),
28
+ options: {
29
+ encrypt: process.env.VICINITY_SQL_ENCRYPT === "true",
30
+ trustServerCertificate: process.env.VICINITY_SQL_TRUST_SERVER_CERT !== "false",
31
+ connectTimeout: 15000,
32
+ requestTimeout: parseInt(process.env.VICINITY_SQL_TIMEOUT || "30000"),
33
+ },
34
+ }),
24
35
  pool: { max: 5, min: 0, idleTimeoutMillis: 30000 },
25
36
  };
26
37
  const MAX_ROWS = parseInt(process.env.VICINITY_SQL_MAX_ROWS || "500");
38
+ import { ConnectionPool, NVarChar } from "mssql";
27
39
  let pool;
28
40
  async function getPool() {
29
41
  if (!pool) {
30
- pool = await sql.connect(dbConfig);
42
+ pool = new ConnectionPool(dbConfig);
43
+ await pool.connect();
31
44
  }
32
45
  return pool;
33
46
  }
@@ -158,8 +171,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
158
171
  else if (name === "describe_table") {
159
172
  const p = await getPool();
160
173
  const res = await p.request()
161
- .input("table", sql.NVarChar, args?.table_name)
162
- .input("schema", sql.NVarChar, args?.schema ?? "dbo")
174
+ .input("table", NVarChar, args?.table_name)
175
+ .input("schema", NVarChar, args?.schema ?? "dbo")
163
176
  .query(`
164
177
  SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, CHARACTER_MAXIMUM_LENGTH
165
178
  FROM INFORMATION_SCHEMA.COLUMNS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vicinitysoftware/mcp-sql",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "MCP server for Vicinity Software SQL databases",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,7 +12,9 @@
12
12
  "resources/",
13
13
  "README.md"
14
14
  ],
15
- "engines": { "node": ">=18.0.0" },
15
+ "engines": {
16
+ "node": ">=18.0.0"
17
+ },
16
18
  "scripts": {
17
19
  "build": "tsc",
18
20
  "prepublishOnly": "npm run build"
@@ -27,4 +29,4 @@
27
29
  "@types/node": "^20.0.0",
28
30
  "typescript": "^5.0.0"
29
31
  }
30
- }
32
+ }