@sassoftware/sas-score-mcp-serverjs 0.0.3 → 0.0.4-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.
package/.env CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  PORT=8080
3
3
  HTTPS=FALSE
4
- MCPTYPE=http
4
+ MCPTYPE=stdio
5
5
 
6
6
  AUTHFLOW=sascli
7
7
  SAS_CLI_PROFILE=00m
@@ -10,4 +10,4 @@ SSLCERT=c:\Users\kumar\.tls
10
10
  # VIYACERT=c:\Users\kumar\viyaCert
11
11
  CAS_SERVER=cas-shared-default
12
12
  COMPUTECONTEXT=SAS Job Execution compute context
13
- ENVFILE=NONE
13
+
package/README.md CHANGED
@@ -51,6 +51,7 @@ HTTPS=FALSE
51
51
  # * sascli * will look for tokens created with sas-viya cli
52
52
  # * token * a custom token
53
53
  # * password * userid/password
54
+ # * none * No aut tokens are created - useful if you want to control authentication
54
55
 
55
56
  AUTHFLOW=sascli
56
57
  SAS_CLI_CONFIG=your-home-directory
@@ -139,6 +140,12 @@ This server supports both stdio and http transport methods.
139
140
  This is ideal for running mcp servers locally.
140
141
  Most clients will autostart the mcp server for you.
141
142
 
143
+ The env variables can be specified in two ways:
144
+
145
+ 1. As part of the mcp configuration as shown below.
146
+ 2. Create a .env file and specify the env variables in that file.
147
+
148
+
142
149
  > Note: You must set the MCPTYPE in the environment variable.
143
150
 
144
151
  ```json
@@ -146,11 +153,12 @@ Most clients will autostart the mcp server for you.
146
153
  "type": "stdio",
147
154
  "command": "npx",
148
155
  "args": [
156
+ "-y",
149
157
  "@sassoftware/sas-app-mcp-serverjs@latest",
150
158
  ],
151
159
  "env": {
152
160
  "MCPTYPE": "stdio",
153
- "AUTHFLOW": "sascli", // sascli|password|token
161
+ "AUTHFLOW": "sascli", // sascli|password|token|none
154
162
  "SAS_CLI_PROFILE": "cli profile name or Default",
155
163
  "SAS_CLI_CONFIG":"where sas-cli stores authentication information",
156
164
  "SSLCERT": "where you have stored the tls information(see below)",
@@ -187,7 +195,7 @@ The mcp configuration is show below
187
195
  }
188
196
  ```
189
197
 
190
- Here is a typical .env file for http transport
198
+ Here is a typical .env file for http transport. Note the value of MCPTYPE.
191
199
 
192
200
  ```env
193
201
 
@@ -214,10 +222,9 @@ But this step is necessary of using http transport.
214
222
 
215
223
 
216
224
  ```sh
217
- npx dotenv-cli -e .env -- npx @sassoftware/sas-app-mcp-serverjs@latest
225
+ npx @sassoftware/sas-app-mcp-serverjs@latest
218
226
  ```
219
227
 
220
- An alternative to using dotenv-cli is to preset the environment variables.
221
228
  Make sure that the .env file is in the current working directory
222
229
 
223
230
 
package/cli.js CHANGED
@@ -10,7 +10,6 @@
10
10
  import coreSSE from './src/coreSSE.js';
11
11
  import corehttp from './src/corehttp.js';
12
12
  import createMcpServer from './src/createMcpServer.js';
13
- import { config } from 'dotenv';
14
13
  // import dotenvExpand from 'dotenv-expand';
15
14
  import fs from 'fs';
16
15
  import { randomUUID } from 'node:crypto';
@@ -27,6 +26,24 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
27
26
 
28
27
  let pkg = fs.readFileSync(__dirname + '/package.json', 'utf8');
29
28
 
29
+ if (process.env.ENVFILE === 'NONE') {
30
+ //use this when using remote mcp server and no .env file is desired
31
+ console.error('[Note]: Skipping .env file as ENVFILE is set to NONE...');
32
+ } else {
33
+ let envf = __dirname + '\\.env';
34
+ console.error(envf);
35
+ if (fs.existsSync(envf)) {
36
+ console.error(`Loading environment variables rom ${envf}...`);
37
+ let e = iconfig(envf); // avoid dotenv since it writes to console.log
38
+ console.error('[Note]: Environment variables loaded from .env file...');
39
+ console.error('Loaded env variables:', e);
40
+ // dotenvExpand.expand(e);
41
+ } else {
42
+ console.error(
43
+ '[Note]: No .env file found, Using default environment variables...'
44
+ );
45
+ }
46
+ }
30
47
  /********************************* */
31
48
  const BRAND = 'sas-score'
32
49
  /********************************* */
@@ -42,7 +59,7 @@ console.error(
42
59
  // session sessionCache
43
60
  // For more robust caching consider products like Redis
44
61
  // and storage provided by cloud providers
45
-
62
+ console.error(process.env.COMPUTECONTEXT);
46
63
  debugger;
47
64
  let sessionCache = new NodeCache({ stdTTL: 0, checkperiod: 2 * 60, useClones: false });
48
65
 
@@ -211,4 +228,27 @@ if (mcpType === 'stdio') {
211
228
  console.error('[Note] MCP HTTP server started on port ' + appEnvBase.PORT);
212
229
  }
213
230
 
231
+ // custom reader for .env file to avoid dotenv logging to console
232
+ function iconfig(envFile) {
233
+ try {
234
+ let data = fs.readFileSync(envFile, 'utf8');
235
+ let d = data.split(/\r?\n/);
236
+ let envData = {};
237
+ d.forEach(l => {
238
+ if (l.length > 0 && l.indexOf('#') === -1) {
239
+ let la = l.split('=');
240
+ let envName = la[0];
241
+ if (la.length === 2 && la[1].length > 0) {
242
+ let t = la[1].trim();
243
+ process.env[envName] = t;
244
+ envData[envName] = t;
245
+ }
246
+ }
247
+ });
248
+ return envData;
249
+ } catch (err) {
250
+ console.log(err);
251
+ process.exit(0);
252
+ }
253
+ }
214
254
 
@@ -1,4 +1,7 @@
1
-
1
+ /*
2
+ * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
2
5
 
3
6
  async function _deval(params) {
4
7
 
@@ -4,7 +4,7 @@
4
4
  "type": "stdio",
5
5
  "command": "npx",
6
6
  "args": [
7
- "@sassoftware/sas-score-mcp-serverjs"
7
+ "@sassoftware/sas-score-mcp-serverjs@alpha"
8
8
  ],
9
9
  "env": {
10
10
  "MCPTYPE": "stdio",
@@ -9,7 +9,7 @@
9
9
  "env": {
10
10
  "MCPTYPE": "stdio",
11
11
  "AUTHFLOW": "sascli",
12
- "SAS_CLI_PROFILE": "cis",
12
+ "SAS_CLI_PROFILE": "00m",
13
13
  "SAS_CLI_CONFIG": "c:\\Users\\kumar",
14
14
  "SSLCERT": "c:\\Users\\kumar\\.tls",
15
15
  "COMPUTECONTEXT": "SAS Job Execution compute context",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sassoftware/sas-score-mcp-serverjs",
3
- "version": "0.0.3",
3
+ "version": "0.0.4-1",
4
4
  "description": "A mcp server for SAS Viya",
5
5
  "author": "Deva Kumar <deva.kumar@sas.com>",
6
6
  "license": "Apache-2.0",
@@ -45,8 +45,6 @@
45
45
  "cors": "^2.8.5",
46
46
  "cross-env": "^10.1.0",
47
47
  "debug": "^4.4.3",
48
- "dotenv": "^17.2.3",
49
- "dotenv-expand": "^12.0.3",
50
48
  "express": "^5.2.1",
51
49
  "express-list-endpoints": "^7.1.1",
52
50
  "express-rate-limit": "^8.2.1",
@@ -11,8 +11,9 @@ async function getToken(_appContext) {
11
11
  if (_appContext.SAS_CLI_CONFIG != null) {
12
12
  homedir = _appContext.SAS_CLI_CONFIG;
13
13
  }
14
-
14
+ console.error(os.platform());
15
15
  let sep = (os.platform() === 'win32') ? '\\' : '/';
16
+ console.error('Using sep: ' + sep);
16
17
  let credentials = homedir + sep + '.sas' + sep + 'credentials.json';
17
18
  let url = homedir + sep + '.sas' + sep + 'config.json';
18
19
  console.error('[Note] Using credentials file: ' + credentials);
@@ -72,13 +72,7 @@ Related Tools
72
72
  },
73
73
 
74
74
  handler: async (params) => {
75
- // Ensure contexts object exists
76
- if (_appContext.contexts == null || typeof _appContext.contexts !== 'object') {
77
- _appContext.contexts = {
78
- cas: _appContext.DEFAULT_CAS_SERVER || null,
79
- sas: null
80
- };
81
- }
75
+
82
76
  let {cas, sas} = params;
83
77
  if (typeof cas === 'string' && cas.trim().length > 0) {
84
78
  _appContext.contexts.cas = cas.trim();
package/types.js CHANGED
@@ -18,8 +18,8 @@
18
18
  * @property {logonPayload} logonPayload - kogonPayload object
19
19
  * @property {string|null} casServerId - cas server id. Default is null.(future)
20
20
  * @property {string|null} computeServerId - compute server id. Default is null(future).
21
- * @property {string|null} sas - SAS compute contextModel
22
- * @property {Object|null} cas - cas server name
21
+ * @property {string|null} sas - SAS compute context
22
+ * @property {Object|null} cas - cas server name(useful if multiple cas servers are used).
23
23
  * @property {Object} ext - Additional extensions that a developer may want to add.
24
24
  */
25
25