@sassoftware/sas-score-mcp-serverjs 0.4.1-15 → 0.4.1-18

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.
@@ -1,4 +1,4 @@
1
- ---
1
+ gi ---
2
2
  name: sas-score-workflow
3
3
  description: >
4
4
  Guide the full model scoring workflow: validate model familiarity, route to appropriate scoring tool
@@ -25,11 +25,11 @@ score <name>.<type> [scenario =<key=value pairs>]
25
25
  ```
26
26
 
27
27
  **Type determines the routing:**
28
- - `.job` → route to `run-job` with scoring parameters
29
- - `.jobdef` → route to `run-jobdef` with scoring parameters
30
- - `.mas` → route to `model-score` (Model Analytical Service — default)
31
- - `.scr` → route to `scr-score` (SAS Container Runtime)
32
- - `.sas` → route to `run-sas-program` to run sas program in folder
28
+ - `.job` → route to `sas-score-run-job` with scoring parameters
29
+ - `.jobdef` → route to `sas-score-run-jobdef` with scoring parameters
30
+ - `.mas` → route to `sas-score-model-score` (Model Analytical Service — default)
31
+ - `.scr` → route to `sas-score-scr-score` (SAS Container Runtime)
32
+ - `.sas` → route to `sas-score-run-sas-program` to run sas program in folder
33
33
 
34
34
  If no type is specified (bare model name), assume `.mas` (MAS model).
35
35
 
@@ -51,39 +51,39 @@ When a user provides a model name with a type suffix (e.g., `simplejon.job`, `ch
51
51
 
52
52
  3. **Strip the type suffix:** Remove the `.type` from the model name before passing to the routing tool
53
53
  - **Critical:** Always pass the base name (without the dot and type) to the invoked tool
54
- - `simplejon.job` → pass `simplejon` to `run-job`
55
- - `churn.mas` → pass `churn` to `model-score`
56
- - `fraud_detector.jobdef` → pass `fraud_detector` to `run-jobdef`
54
+ - `simplejon.job` → pass `simplejon` to `sas-score-run-job`
55
+ - `churn.mas` → pass `churn` to `sas-score-model-score`
56
+ - `fraud_detector.jobdef` → pass `fraud_detector` to `sas-score-run-jobdef`
57
57
 
58
58
  ### Type: `.mas` (Model Aggregation Service)
59
- - **Tool**: `model-score`
59
+ - **Tool**: `sas-score-model-score`
60
60
  - **Use for**: Standard MAS-deployed predictive models
61
61
  - **Example**: `score with model churn.mas scenario =age=45,income=60000`
62
- - **Invocation**: `model-score({ model: "churn", scenario: {...} })`
62
+ - **Invocation**: `sas-score-model-score({ model: "churn", scenario: {...} })`
63
63
 
64
64
  ### Type: `.job` (SAS Viya Job)
65
- - **Tool**: `run-job`
65
+ - **Tool**: `sas-score-run-job`
66
66
  - **Use for**: Pre-built scoring jobs with parameters
67
67
  - **Example**: `score with model monthly_scorer.job scenario =month=10,year=2025`
68
- - **Invocation**: `run-job({ name: "monthly_scorer", scenario: {...} })`
68
+ - **Invocation**: `sas-score-run-job({ name: "monthly_scorer", scenario: {...} })`
69
69
 
70
70
  ### Type: `.jobdef` (SAS Viya Job Definition)
71
- - **Tool**: `run-jobdef`
71
+ - **Tool**: `sas-score-run-jobdef`
72
72
  - **Use for**: Job definitions that perform scoring logic
73
73
  - **Example**: `score with model fraud_detector.jobdef using amount=500,merchant=online`
74
- - **Invocation**: `run-jobdef({ name: "fraud_detector", scenario: {...} })`
74
+ - **Invocation**: `sas-score-run-jobdef({ name: "fraud_detector", scenario: {...} })`
75
75
 
76
76
  ### Type: `.scr` (Score Code Runtime)
77
- - **Tool**: `scr-score`
77
+ - **Tool**: `sas-score-scr-score`
78
78
  - **Use for**: Models deployed in SCR containers (REST endpoints)
79
79
  - **Example**: `score https://scr-host/models/loan.scr using age=45,credit=700`
80
- - **Invocation**: `scr-score({ url: "https://scr-host/models/loan", scenario: {...} })`
80
+ - **Invocation**: `sas-score-scr-score({ url: "https://scr-host/models/loan", scenario: {...} })`
81
81
 
82
82
  ### Type: `.sas` (SAS Program / SQL)
83
- - **Tool**: `run-sas-program`
83
+ - **Tool**: `sas-score-run-sas-program`
84
84
  - **Use for**: Custom SAS or SQL scoring code
85
85
  - **Example**: `score my_scoring_code.sas using x=1,y=2`
86
- - **Invocation**: `run-sas-program({ folder: "my_scoring_code", scenario: {...} })`
86
+ - **Invocation**: `sas-score-run-sas-program({ folder: "my_scoring_code", scenario: {...} })`
87
87
 
88
88
 
89
89
 
@@ -106,6 +106,13 @@ Accepted formats:
106
106
 
107
107
  ---
108
108
 
109
+ ## Integration with other skills
110
+
111
+ - **Before scoring table data**: Use `sas-find-library-smart` to verify the library, then `sas-read-strategy` to fetch records
112
+ - **For read + score workflows**: Use `sas-read-and-score` for the complete end-to-end pattern
113
+
114
+ ---
115
+
109
116
  ## Step 1 — Check model familiarity before scoring
110
117
 
111
118
  Score immediately if:
@@ -139,7 +146,7 @@ scenario = [
139
146
  ```
140
147
 
141
148
  **Critical rules:**
142
- - Loop or call model-score **once per row**.
149
+ - Loop or call sas-score-model-score **once per row**.
143
150
  - Field names in the scenario must match the model's expected input variable names **exactly**.
144
151
  - If table column names differ from model input names, **flag this to the user** and ask for confirmation before scoring.
145
152
  - Example: Table has `age_years`, but model expects `age` → ask user which column maps to which input.
@@ -153,7 +160,7 @@ Based on the type extracted from the model name, invoke the corresponding tool:
153
160
 
154
161
  **For `.mas` (default):**
155
162
  ```javascript
156
- model-score({
163
+ sas-score-model-score({
157
164
  model: "<modelname>",
158
165
  scenario: scenario, // object or array
159
166
  uflag: false // set true if you need field names prefixed with _
@@ -162,7 +169,7 @@ model-score({
162
169
 
163
170
  **For `.job`:**
164
171
  ```javascript
165
- run-job({
172
+ sas-score-run-job({
166
173
  name: "<jobname>",
167
174
  scenario: scenario
168
175
  })
@@ -170,7 +177,7 @@ run-job({
170
177
 
171
178
  **For `.jobdef`:**
172
179
  ```javascript
173
- run-jobdef({
180
+ sas-score-run-jobdef({
174
181
  name: "<jobdefname>",
175
182
  scenario: scenario
176
183
  })
@@ -178,7 +185,7 @@ run-jobdef({
178
185
 
179
186
  **For `.scr`:**
180
187
  ```javascript
181
- scr-score({
188
+ sas-score-scr-score({
182
189
  url: "<scr_endpoint_url>",
183
190
  scenario: scenario
184
191
  })
@@ -186,7 +193,7 @@ scr-score({
186
193
 
187
194
  **For `.sas`:**
188
195
  ```javascript
189
- run-sas-program({
196
+ sas-score-run-sas-program({
190
197
  src: "<sas_or_sql_code>",
191
198
  scenario: scenario
192
199
  })
@@ -222,43 +229,43 @@ Merge the scoring output back with the input records and present as a table wher
222
229
  **Flow A — Score rows with MAS model**
223
230
  > "Score the first 10 customers in Public.customers with the churn model"
224
231
 
225
- 1. `read-table` → { table: "Public.customers", limit: 10 }
226
- 2. `model-score` → { model: "churn", scenario: [ ...10 row objects ] }
232
+ 1. `sas-score-read-table` → { table: "Public.customers", limit: 10 }
233
+ 2. `sas-score-model-score` → { model: "churn", scenario: [ ...10 row objects ] }
227
234
  3. Present merged results with prediction + key inputs
228
235
 
229
236
  **Flow B — Score with a scoring job**
230
237
  > "Score December sales with the monthly_scorer job using month=12,year=2025"
231
238
 
232
- 1. `run-job` → { name: "monthly_scorer", scenario: { month: "12", year: "2025" } }
239
+ 1. `sas-score-run-job` → { name: "monthly_scorer", scenario: { month: "12", year: "2025" } }
233
240
  2. Capture job output and tables
234
241
  3. Present results
235
242
 
236
243
  **Flow C — Score with a job definition**
237
244
  > "Run fraud detection jobdef on transaction amount=500, merchant=online"
238
245
 
239
- 1. `run-jobdef` → { name: "fraud_detection", scenario: { amount: "500", merchant: "online" } }
246
+ 1. `sas-score-run-jobdef` → { name: "fraud_detection", scenario: { amount: "500", merchant: "online" } }
240
247
  2. Capture log, listings, and tables
241
248
  3. Present results
242
249
 
243
250
  **Flow D — Score with SCR endpoint**
244
251
  > "Score with the loan model at https://scr-host/models/loan using age=45, credit_score=700"
245
252
 
246
- 1. `scr-score` → { url: "https://scr-host/models/loan", scenario: { age: "45", credit_score: "700" } }
253
+ 1. `sas-score-scr-score` → { url: "https://scr-host/models/loan", scenario: { age: "45", credit_score: "700" } }
247
254
  2. Capture prediction response
248
255
  3. Present result
249
256
 
250
257
  **Flow E — Score results of an analytical query with MAS**
251
258
  > "Score high-value customers (spend > 5000) in mylib.sales with the fraud model"
252
259
 
253
- 1. `sas-query` → { table: "mylib.sales", sql: "SELECT * FROM mylib.sales WHERE spend > 5000" }
254
- 2. `model-score` → { model: "fraud", scenario: [ ...result rows ] }
260
+ 1. `sas-score-sas-query` → { table: "mylib.sales", sql: "SELECT * FROM mylib.sales WHERE spend > 5000" }
261
+ 2. `sas-score-model-score` → { model: "fraud", scenario: [ ...result rows ] }
255
262
  3. Present merged results
256
263
 
257
264
  **Flow F — User supplies scenario data directly**
258
265
  > "Score age=45, income=60000, region=South with the churn model"
259
266
 
260
267
  1. Skip read step
261
- 2. `model-score` → { model: "churn", scenario: { age: "45", income: "60000", region: "South" } }
268
+ 2. `sas-score-model-score` → { model: "churn", scenario: { age: "45", income: "60000", region: "South" } }
262
269
  3. Present result
263
270
 
264
271
  **Flow G — Model unfamiliar, need to confirm**
@@ -266,7 +273,7 @@ Merge the scoring output back with the input records and present as a table wher
266
273
 
267
274
  1. Pause — "creditRisk2" is new
268
275
  2. Suggest: `find-model` to confirm it exists, `model-info` to get input variables
269
- 3. Once confirmed → `read-table` + `model-score`
276
+ 3. Once confirmed → `sas-score-read-table` + `sas-score-model-score`
270
277
 
271
278
  **Flow H — Generic score syntax with type routing**
272
279
  > "score with model churn.mas scenario =age=45,income=60000"
@@ -294,7 +301,14 @@ Merge the scoring output back with the input records and present as a table wher
294
301
 
295
302
  ## Tips
296
303
 
297
- - **Batch is better:** Always pass the full set of records in one `model-score` call. Do not loop.
304
+ - **Batch is better:** Always pass the full set of records in one `sas-score-model-score` call. Do not loop.
298
305
  - **Confirm mappings:** If column names don't match model inputs, ask before scoring.
299
306
  - **Show context:** Include key input columns in the result output so predictions make sense.
300
307
  - **Limit output:** For large result sets (>10 rows), ask before showing all.
308
+
309
+ ---
310
+
311
+ ## Integration with other skills
312
+
313
+ - **Before scoring table data**: Use `sas-find-library-smart` to verify the library, then `sas-read-strategy` to fetch records
314
+ - **For read + score workflows**: Use `sas-read-and-score` for the complete end-to-end pattern
@@ -31,15 +31,18 @@ async function callback(req, res, pkceStore, codeStore, appContext) {
31
31
  }).toString();
32
32
 
33
33
  console.error("[Note] Token request body:", body.toString());
34
+
34
35
  let connectOpts = {
35
- ca: appContext.contexts.viyaCert.ca, // trust this CA
36
36
  rejectUnauthorized: false // or false, if you really want to bypass checks
37
37
  }
38
+ if (appContext.contexts.viyaCert != null && appContext.contexts.viyaCert.ca != null) {
39
+ connectOpts.ca = appContext.contexts.viyaCert.ca;
40
+ }
38
41
  const agent = new Agent({ connect: connectOpts });
39
42
  console.error("[Note] Initiating token exchange with SAS Viya");
40
43
  let clientID= appContext.CLIENTID;
41
44
  let h = buildBasicAuthFromClientId(clientID);
42
- console.error("[Note] Authorization header for token request:", h);
45
+ // console.error("[Note] Authorization header for token request:", h);
43
46
  const response = await undiciFetch(`${appContext.VIYA_SERVER}/SASLogon/oauth/token`, {
44
47
  method: "POST",
45
48
  headers: {
@@ -57,7 +60,7 @@ async function callback(req, res, pkceStore, codeStore, appContext) {
57
60
  }
58
61
 
59
62
  const tokens = await response.json();
60
- console.error("[Note] Received tokens from SAS Viya:", tokens);
63
+ // console.error("[Note] Received tokens from SAS Viya:", tokens);
61
64
  const ourCode = randomUUID();
62
65
  codeStore.set(ourCode, {
63
66
  access_token: tokens.access_token,
@@ -9,10 +9,11 @@ async function refreshToken(_appContext, params) {
9
9
  let url = `${host}/SASLogon/oauth/token`;
10
10
 
11
11
  let aconnect = {
12
- ca: _appContext.contexts.viyaCert.ca, // trust this CA
13
12
  rejectUnauthorized: false // or false, if you really want to bypass checks
14
13
  }
15
-
14
+ if (_appContext.contexts.viyaCert != null && _appContext.contexts.viyaCert.ca != null) {
15
+ aconnect.ca = _appContext.contexts.viyaCert.ca;
16
+ }
16
17
  const agent = new Agent(aconnect);
17
18
 
18
19
  console.error('[Info] Refreshing token...', token);