@sassoftware/sas-score-mcp-serverjs 0.4.1-20 → 0.4.1-21

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,314 +0,0 @@
1
- gi ---
2
- name: sas-score-workflow
3
- description: >
4
- Guide the full model scoring workflow: validate model familiarity, route to appropriate scoring tool
5
- based on model type, invoke scoring with scenario data, and present merged results. Use this skill
6
- when the user wants to run predictions on data (already fetched or user-supplied). Supports generic
7
- syntax: "score with model <name>.<type> scenario =<params>" where type is job|jobdef|mas|scr|sas.
8
- Trigger phrases: "score these records", "predict using model", "run model on", "score with model X.mas".
9
- ---
10
-
11
- # SAS Score Workflow
12
-
13
- Orchestrates model validation, type-based routing, scoring invocation, and result presentation.
14
- Handles both MAS models and alternative scoring engines (jobs, jobdefs, SCR, SAS programs).
15
-
16
- ---
17
-
18
- ## Generic Scoring Syntax
19
-
20
- Users can invoke scoring with a unified syntax that automatically routes to the correct tool:
21
-
22
- ```
23
- score with model <name>.<type> [scenario =<key=value pairs>]
24
- score <name>.<type> [scenario =<key=value pairs>]
25
- ```
26
-
27
- **Type determines the routing:**
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
-
34
- If no type is specified (bare model name), assume `.mas` (MAS model).
35
-
36
- ---
37
-
38
- ## Type-Based Routing
39
-
40
- ### Parse and Strip Model Type
41
-
42
- When a user provides a model name with a type suffix (e.g., `simplejon.job`, `churn.mas`):
43
-
44
- 1. **Extract the type:** Split on the last dot to identify the type suffix
45
- - `simplejon.job` → type = `job`, base name = `simplejon`
46
- - `churn.mas` → type = `mas`, base name = `churn`
47
- - `fraud_detector.jobdef` → type = `jobdef`, base name = `fraud_detector`
48
-
49
- 2. **Validate the type:** Confirm it matches one of the supported types: `job`, `jobdef`, `mas`, `scr`, `sas`
50
- - If type is unrecognized, assume `.mas` (default MAS model) and treat the entire input as the model name
51
-
52
- 3. **Strip the type suffix:** Remove the `.type` from the model name before passing to the routing tool
53
- - **Critical:** Always pass the base name (without the dot and type) to the invoked tool
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
-
58
- ### Type: `.mas` (Model Aggregation Service)
59
- - **Tool**: `sas-score-model-score`
60
- - **Use for**: Standard MAS-deployed predictive models
61
- - **Example**: `score with model churn.mas scenario =age=45,income=60000`
62
- - **Invocation**: `sas-score-model-score({ model: "churn", scenario: {...} })`
63
-
64
- ### Type: `.job` (SAS Viya Job)
65
- - **Tool**: `sas-score-run-job`
66
- - **Use for**: Pre-built scoring jobs with parameters
67
- - **Example**: `score with model monthly_scorer.job scenario =month=10,year=2025`
68
- - **Invocation**: `sas-score-run-job({ name: "monthly_scorer", scenario: {...} })`
69
-
70
- ### Type: `.jobdef` (SAS Viya Job Definition)
71
- - **Tool**: `sas-score-run-jobdef`
72
- - **Use for**: Job definitions that perform scoring logic
73
- - **Example**: `score with model fraud_detector.jobdef using amount=500,merchant=online`
74
- - **Invocation**: `sas-score-run-jobdef({ name: "fraud_detector", scenario: {...} })`
75
-
76
- ### Type: `.scr` (Score Code Runtime)
77
- - **Tool**: `sas-score-scr-score`
78
- - **Use for**: Models deployed in SCR containers (REST endpoints)
79
- - **Example**: `score https://scr-host/models/loan.scr using age=45,credit=700`
80
- - **Invocation**: `sas-score-scr-score({ url: "https://scr-host/models/loan", scenario: {...} })`
81
-
82
- ### Type: `.sas` (SAS Program / SQL)
83
- - **Tool**: `sas-score-run-sas-program`
84
- - **Use for**: Custom SAS or SQL scoring code
85
- - **Example**: `score my_scoring_code.sas using x=1,y=2`
86
- - **Invocation**: `sas-score-run-sas-program({ folder: "my_scoring_code", scenario: {...} })`
87
-
88
-
89
-
90
- ---
91
-
92
- ## Scenario Parsing
93
-
94
- The scenario parameter (comma-separated key=value pairs) is parsed into an object:
95
-
96
- ```
97
- scenario =age=45,income=60000,region=South
98
- ↓ parsed as:
99
- { age: "45", income: "60000", region: "South" }
100
- ```
101
-
102
- Accepted formats:
103
- - **String**: `age=45,income=60000`
104
- - **Object**: `{ age: 45, income: 60000 }`
105
- - **Array** (batch): `[ {age:45, income:60000}, {age:50, income:75000} ]`
106
-
107
- ---
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
-
116
- ## Step 1 — Check model familiarity before scoring
117
-
118
- Score immediately if:
119
- - The user names a specific model they've used before in this session, OR
120
- - The model name matches a previously confirmed model in the conversation
121
-
122
- Pause and suggest investigation if:
123
- - The model name is new, vague, or misspelled-looking (e.g. "the churn one", "that cancer model")
124
- - The user seems unsure of the required input variable names
125
-
126
- **Suggested message:**
127
- > "I don't recognize that model — want me to run `find-model` to confirm it exists,
128
- > or `model-info` to check its required inputs first?"
129
-
130
- ---
131
-
132
- ## Step 2 — Prepare the scenario data
133
-
134
- **For a single record** (one object):
135
- ```javascript
136
- scenario = { field1: value1, field2: value2, ... }
137
- ```
138
-
139
- **For batch scoring** (multiple records — the typical case):
140
- ```javascript
141
- scenario = [
142
- { field1: val1, field2: val2, ... },
143
- { field1: val3, field2: val4, ... },
144
- ...
145
- ]
146
- ```
147
-
148
- **Critical rules:**
149
- - Loop or call sas-score-model-score **once per row**.
150
- - Field names in the scenario must match the model's expected input variable names **exactly**.
151
- - If table column names differ from model input names, **flag this to the user** and ask for confirmation before scoring.
152
- - Example: Table has `age_years`, but model expects `age` → ask user which column maps to which input.
153
- - Do not add units, labels, or extra metadata — raw field values only.
154
-
155
- ---
156
-
157
- ## Step 3 — Invoke the appropriate scoring tool
158
-
159
- Based on the type extracted from the model name, invoke the corresponding tool:
160
-
161
- **For `.mas` (default):**
162
- ```javascript
163
- sas-score-model-score({
164
- model: "<modelname>",
165
- scenario: scenario, // object or array
166
- uflag: false // set true if you need field names prefixed with _
167
- })
168
- ```
169
-
170
- **For `.job`:**
171
- ```javascript
172
- sas-score-run-job({
173
- name: "<jobname>",
174
- scenario: scenario
175
- })
176
- ```
177
-
178
- **For `.jobdef`:**
179
- ```javascript
180
- sas-score-run-jobdef({
181
- name: "<jobdefname>",
182
- scenario: scenario
183
- })
184
- ```
185
-
186
- **For `.scr`:**
187
- ```javascript
188
- sas-score-scr-score({
189
- url: "<scr_endpoint_url>",
190
- scenario: scenario
191
- })
192
- ```
193
-
194
- **For `.sas`:**
195
- ```javascript
196
- sas-score-run-sas-program({
197
- src: "<sas_or_sql_code>",
198
- scenario: scenario
199
- })
200
- ```
201
-
202
- **Rules:**
203
- - Pass the full batch in one call; do not loop over rows
204
- - If scoring fails, return the structured error and suggest troubleshooting
205
- - For MAS models, include uflag parameter if underscore-prefixed output is needed
206
- - For jobs/jobdefs, scenario becomes parameter arguments
207
- - For SCR, include full URL endpoint
208
-
209
- ---
210
-
211
- ## Step 4 — Present the results
212
-
213
- Merge the scoring output back with the input records and present as a table where possible.
214
-
215
- **Always surface:**
216
- - The key prediction/score field(s) (e.g. `P_churn`, `score`, `prediction`, `P_risk`)
217
- - Any probability/confidence fields for classification models (e.g. `P_class0`, `P_class1`)
218
- - Selected input fields that drove the prediction, so the user can see context
219
-
220
- **Formatting:**
221
- - Present results in a table for clarity
222
- - If results exceed 10 rows, show the first 10 and ask: *"Want to see more results or export the full set?"*
223
- - Round numeric predictions to 2–4 decimal places for readability
224
-
225
- ---
226
-
227
- ## Common flows
228
-
229
- **Flow A — Score rows with MAS model**
230
- > "Score the first 10 customers in Public.customers with the churn model"
231
-
232
- 1. `sas-score-read-table` → { table: "Public.customers", limit: 10 }
233
- 2. `sas-score-model-score` → { model: "churn", scenario: [ ...10 row objects ] }
234
- 3. Present merged results with prediction + key inputs
235
-
236
- **Flow B — Score with a scoring job**
237
- > "Score December sales with the monthly_scorer job using month=12,year=2025"
238
-
239
- 1. `sas-score-run-job` → { name: "monthly_scorer", scenario: { month: "12", year: "2025" } }
240
- 2. Capture job output and tables
241
- 3. Present results
242
-
243
- **Flow C — Score with a job definition**
244
- > "Run fraud detection jobdef on transaction amount=500, merchant=online"
245
-
246
- 1. `sas-score-run-jobdef` → { name: "fraud_detection", scenario: { amount: "500", merchant: "online" } }
247
- 2. Capture log, listings, and tables
248
- 3. Present results
249
-
250
- **Flow D — Score with SCR endpoint**
251
- > "Score with the loan model at https://scr-host/models/loan using age=45, credit_score=700"
252
-
253
- 1. `sas-score-scr-score` → { url: "https://scr-host/models/loan", scenario: { age: "45", credit_score: "700" } }
254
- 2. Capture prediction response
255
- 3. Present result
256
-
257
- **Flow E — Score results of an analytical query with MAS**
258
- > "Score high-value customers (spend > 5000) in mylib.sales with the fraud model"
259
-
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 ] }
262
- 3. Present merged results
263
-
264
- **Flow F — User supplies scenario data directly**
265
- > "Score age=45, income=60000, region=South with the churn model"
266
-
267
- 1. Skip read step
268
- 2. `sas-score-model-score` → { model: "churn", scenario: { age: "45", income: "60000", region: "South" } }
269
- 3. Present result
270
-
271
- **Flow G — Model unfamiliar, need to confirm**
272
- > "Score Public.applicants with the creditRisk2 model"
273
-
274
- 1. Pause — "creditRisk2" is new
275
- 2. Suggest: `find-model` to confirm it exists, `model-info` to get input variables
276
- 3. Once confirmed → `sas-score-read-table` + `sas-score-model-score`
277
-
278
- **Flow H — Generic score syntax with type routing**
279
- > "score with model churn.mas scenario =age=45,income=60000"
280
- > "score fraud_detector.jobdef where scenario =amount=500"
281
- > "score monthly_report.job using month=10,year=2025"
282
-
283
- 1. Parse model name to extract type (.mas, .job, .jobdef, .scr, .sas)
284
- 2. Route to appropriate tool based on type
285
- 3. Parse scenario and invoke tool with parameters
286
- 4. Present results from routed tool
287
-
288
- ---
289
-
290
- ## Error handling
291
-
292
- | Problem | Action |
293
- |---|---|
294
- | Model not found | Suggest `find-model` to verify the model is deployed |
295
- | Input field name mismatch | Show the mismatch (table has X, model expects Y), ask user to confirm mapping |
296
- | Scoring error / invalid inputs | Return structured error, suggest `model-info` to check required inputs and data types |
297
- | Empty read result | Tell user, ask if they want to adjust the query/filter before scoring |
298
- | Missing input fields | Ask which table columns map to the required model inputs |
299
-
300
- ---
301
-
302
- ## Tips
303
-
304
- - **Batch is better:** Always pass the full set of records in one `sas-score-model-score` call. Do not loop.
305
- - **Confirm mappings:** If column names don't match model inputs, ask before scoring.
306
- - **Show context:** Include key input columns in the result output so predictions make sense.
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
@@ -1,303 +0,0 @@
1
- ---
2
- name: sas-spec-migration
3
- description: >
4
- Migrate or clean up SAS MCP tool spec objects. Use this skill whenever the user asks
5
- to migrate, convert, update, or clean up tool specs. Covers two patterns:
6
- (1) Old Zod-based format (z.string(), z.number(), top-level schema/required) → new
7
- JSON Schema inputSchema format.
8
- (2) Existing JSON Schema specs that need cleanup: removing $schema, fixing required
9
- arrays (optional fields like "where" should not be in required), typing untyped fields
10
- like scenario. Also trigger on: "migrate my tools", "update my specs", "clean up my
11
- specs", "remove $schema", "fix required", or any request to standardize tool specs.
12
- ---
13
-
14
- # SAS Tool Spec Migration
15
-
16
- Covers two migration scenarios:
17
-
18
- - **Zod → JSON Schema**: Old format using `z.string()`, `z.number()` etc. with top-level `schema` and `required`
19
- - **JSON Schema cleanup**: Existing `inputSchema` specs that need `$schema` removed, `required` fixed, or untyped fields corrected
20
-
21
- Identify which pattern applies before proceeding.
22
-
23
- ---
24
-
25
- ## Pattern 1 — JSON Schema cleanup
26
-
27
- Use when the tool already has `inputSchema` but needs tidying. Apply all of these fixes:
28
-
29
- ### Remove `$schema`
30
-
31
- Drop the `$schema` declaration entirely — the MCP SDK and LLMs ignore it at runtime and
32
- it wastes tokens.
33
-
34
- ```js
35
- // Before
36
- inputSchema: {
37
- $schema: "http://json-schema.org/draft-07/schema#",
38
- type: "object",
39
- ...
40
- }
41
-
42
- // After
43
- inputSchema: {
44
- type: "object",
45
- ...
46
- }
47
- ```
48
-
49
- ### Fix `required` arrays
50
-
51
- Only include a field in `required` if it is truly mandatory. Common mistakes:
52
-
53
- | Field | Rule |
54
- |---|---|
55
- | `where` (filter expression) | Optional — remove from `required`, default to `""` in handler |
56
- | `scenario` (job params) | Optional — not all jobs need parameters; remove from `required` |
57
- | `name` | Required — always include |
58
- | `limit`, `start` | Required for list tools — include |
59
-
60
- ### Type untyped fields
61
-
62
- If a field has `{}` or no type, infer the correct type:
63
-
64
- | Field | Type |
65
- |---|---|
66
- | `scenario` | `{ type: "string" }` — handler already parses it as JSON |
67
- | `where` | `{ type: "string" }` |
68
- | Any flexible input | `{ type: "string" }` with note to parse in handler |
69
-
70
- ### Full cleanup example
71
-
72
- **Before:**
73
- ```js
74
- inputSchema: {
75
- $schema: "http://json-schema.org/draft-07/schema#",
76
- type: "object",
77
- properties: {
78
- name: { type: "string" },
79
- scenario: {}
80
- },
81
- required: ["name", "scenario"]
82
- }
83
- ```
84
-
85
- **After:**
86
- ```js
87
- inputSchema: {
88
- type: "object",
89
- properties: {
90
- name: { type: "string" },
91
- scenario: { type: "string" }
92
- },
93
- required: ["name"]
94
- }
95
- ```
96
-
97
- ---
98
-
99
- ## Pattern 2 — Zod → JSON Schema
100
-
101
- ## What changes
102
-
103
- **Old format:**
104
- ```js
105
- let spec = {
106
- name: 'find-job',
107
- aliases: [...],
108
- description: description,
109
- schema: {
110
- name: z.string(),
111
- limit: z.number().optional(),
112
- },
113
- required: ['name'],
114
- handler: async (params) => { ... }
115
- }
116
- ```
117
-
118
- **New format:**
119
- ```js
120
- let spec = {
121
- name: 'find-job',
122
- aliases: [...],
123
- description: description,
124
- inputSchema: {
125
- type: "object",
126
- properties: {
127
- name: { type: "string", description: "Job name to locate" },
128
- limit: { type: "number", description: "Max results to return" }
129
- },
130
- required: ['name']
131
- },
132
- handler: async (params) => { ... }
133
- }
134
- ```
135
-
136
- **Summary of changes:**
137
- - `schema` → `inputSchema`
138
- - `inputSchema` gains `type: "object"` and `properties: {}`
139
- - Each Zod field moves inside `properties` as a JSON Schema object
140
- - Top-level `required` array moves inside `inputSchema`
141
- - Fields with `.optional()` are NOT included in `required`
142
- - Fields without `.optional()` ARE included in `required` (unless already excluded)
143
-
144
- ---
145
-
146
- ## Zod → JSON Schema type mapping
147
-
148
- | Zod | JSON Schema |
149
- |---|---|
150
- | `z.string()` | `{ type: "string" }` |
151
- | `z.number()` | `{ type: "number" }` |
152
- | `z.boolean()` | `{ type: "boolean" }` |
153
- | `z.array(z.string())` | `{ type: "array", items: { type: "string" } }` |
154
- | `z.array(z.number())` | `{ type: "array", items: { type: "number" } }` |
155
- | `z.object({...})` | `{ type: "object", properties: {...} }` |
156
- | `z.enum(['a','b'])` | `{ type: "string", enum: ["a", "b"] }` |
157
- | `.describe("text")` | Add `description: "text"` to the property |
158
- | `.optional()` | Omit field from `required` array |
159
- | `.optional().describe("text")` | Omit from `required`, add `description` |
160
-
161
- ---
162
-
163
- ## Step-by-step migration
164
-
165
- ### Step 1 — Identify the fields
166
-
167
- Read the existing `schema` object. For each key, note:
168
- - Its Zod type (string, number, boolean, array, enum, object)
169
- - Whether it has `.optional()`
170
- - Whether it has `.describe("...")` — extract the description text
171
- - Whether it appears in the top-level `required` array
172
-
173
- ### Step 2 — Build `properties`
174
-
175
- For each field in `schema`, create a JSON Schema property object:
176
-
177
- ```js
178
- // Old
179
- fieldName: z.string().describe("The name of the thing")
180
-
181
- // New
182
- fieldName: { type: "string", description: "The name of the thing" }
183
- ```
184
-
185
- If no `.describe()` is present, infer a short description from the field name and tool context.
186
- Keep descriptions concise — one sentence, imperative style ("Job name to locate", not "This is the name of the job").
187
-
188
- ### Step 3 — Build `required`
189
-
190
- Include a field in `required` if:
191
- - It appeared in the old top-level `required` array, OR
192
- - It has no `.optional()` in its Zod definition
193
-
194
- Exclude a field from `required` if:
195
- - It has `.optional()` in its Zod definition
196
-
197
- ### Step 4 — Assemble `inputSchema`
198
-
199
- ```js
200
- inputSchema: {
201
- type: "object",
202
- properties: {
203
- // one entry per field from Step 2
204
- },
205
- required: [/* field names from Step 3 */]
206
- }
207
- ```
208
-
209
- If `required` would be empty, omit it entirely rather than including `required: []`.
210
-
211
- ### Step 5 — Remove old fields
212
-
213
- Remove `schema` and the top-level `required` from the spec object.
214
- Leave everything else unchanged: `name`, `aliases`, `description`, `handler`.
215
-
216
- ---
217
-
218
- ## Edge cases
219
-
220
- **Field in `required` but also `.optional()` in Zod:**
221
- Trust `.optional()` — exclude from `required`. The old `required` array may be stale.
222
-
223
- **Nested `z.object()`:**
224
- ```js
225
- // Old
226
- config: z.object({ host: z.string(), port: z.number() })
227
-
228
- // New
229
- config: {
230
- type: "object",
231
- properties: {
232
- host: { type: "string", description: "Host address" },
233
- port: { type: "number", description: "Port number" }
234
- }
235
- }
236
- ```
237
-
238
- **`z.union()` / `z.any()` / `z.unknown()`:**
239
- Use `{}` (empty schema, accepts anything) or `{ type: "string" }` with a note that the
240
- field accepts flexible input. Flag this to the user for review.
241
-
242
- **No `schema` field at all:**
243
- The tool takes no inputs. Set `inputSchema: { type: "object", properties: {} }` or omit
244
- `inputSchema` entirely — both are valid. Omitting is cleaner for zero-input tools.
245
-
246
- **`schema` is already a plain JSON object (not Zod):**
247
- Check if values use `z.` prefix. If not, the schema may already be partially migrated —
248
- wrap it in `{ type: "object", properties: { ... } }` and move `required` inside.
249
-
250
- ---
251
-
252
- ## Output format
253
-
254
- - Preserve the existing code style (quote style, indentation, trailing commas)
255
- - Output the full updated spec object, not just the diff
256
- - If migrating multiple specs at once, process them all and output each in full
257
- - After outputting, note any fields that used `z.union()`, `z.any()`, or other ambiguous
258
- types that the user should review manually
259
-
260
- ---
261
-
262
- ## Example — full migration
263
-
264
- **Input:**
265
- ```js
266
- let spec = {
267
- name: 'find-job',
268
- aliases: ['findJob', 'find job'],
269
- description: description,
270
- schema: {
271
- name: z.string(),
272
- caslib: z.string().optional().describe("CAS library name"),
273
- limit: z.number().optional(),
274
- },
275
- required: ['name'],
276
- handler: async (params) => {
277
- let r = await _listJobs(params);
278
- return r;
279
- }
280
- }
281
- ```
282
-
283
- **Output:**
284
- ```js
285
- let spec = {
286
- name: 'find-job',
287
- aliases: ['findJob', 'find job'],
288
- description: description,
289
- inputSchema: {
290
- type: "object",
291
- properties: {
292
- name: { type: "string", description: "Job name to locate" },
293
- caslib: { type: "string", description: "CAS library name" },
294
- limit: { type: "number", description: "Max results to return" }
295
- },
296
- required: ['name']
297
- },
298
- handler: async (params) => {
299
- let r = await _listJobs(params);
300
- return r;
301
- }
302
- }
303
- ```