@sassoftware/sas-score-mcp-serverjs 1.0.0 → 1.0.1-2

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,156 +0,0 @@
1
- ---
2
- name: sas-read-strategy
3
- description: >
4
- Guide the user in choosing the right data retrieval tool: sas-score-read-table (for raw row access with filters)
5
- or sas-score-sas-query (for analytical queries, aggregations, joins). Use this skill when the user wants to
6
- fetch records from a SAS/CAS table. Trigger phrases include: "read records from", "get data where",
7
- "fetch rows from", "query the table", "give me the first N records", "aggregate by", "join tables",
8
- or any request that starts with data retrieval.
9
- ---
10
-
11
- # SAS Read Strategy
12
-
13
- Guides the decision between `sas-score-read-table` and `sas-score-sas-query` based on the user's intent and the nature
14
- of the data operation. Determines which server contains the data and which retrieval tool is most appropriate.
15
-
16
- ## Determine the server location
17
-
18
- Before retrieving data, verify the library and determine which server(s) contain the table:
19
-
20
- **Step 1: Verify library existence**
21
- - Use `sas-find-library-smart` skill to check the library in CAS first, then SAS if needed
22
- - This establishes the correct server and uppercase convention for SAS libraries
23
- - Informs the user which server contains the library
24
-
25
- **Step 2: Locate the specific table**
26
- - Use `sas-score-find-table` to check if the table exists in the library
27
- - Possible outcomes:
28
- - If table exists **only in CAS** → set `server: "cas"`
29
- - If table exists **only in SAS** → set `server: "sas"`
30
- - If table exists **in both** → ask the user: *"The table exists in both CAS and SAS. Which server would you prefer to query from?"*
31
- - If table exists **in neither** → inform user and suggest verifying the table name
32
-
33
- ---
34
-
35
- ## Determine the read strategy
36
-
37
- Ask yourself: does the user already have the data in hand?
38
-
39
- - **Yes (user pasted values, or data is already in context)** → skip this strategy; data is ready to use.
40
- - **No** → choose the read tool based on intent:
41
-
42
- | User's Intent | Tool | Example |
43
- |---|---|---|
44
- | Get specific raw rows, apply simple filter, retrieve first N records | `sas-score-read-table` | "Show me 10 rows from customers where status='active'" |
45
- | Aggregate/summarize, calculate, join tables, analytical question | `sas-score-sas-query` | "Average salary by department", "Count orders by region" |
46
-
47
- ---
48
-
49
- ## Using read-table
50
-
51
- **When:**
52
- - User asks for raw records, row-by-row data
53
- - Simple WHERE filtering (e.g., "where status = 'active'")
54
- - Pagination needed ("first 50 rows", "next 10 rows")
55
-
56
- **How:**
57
- ```
58
- sas-score-read-table({
59
- table: "tablename",
60
- lib: "libraryname",
61
- server: "cas" or "sas", // determined from sas-score-find-table check
62
- limit: N, // default 10, adjust based on user request
63
- where: "..." // optional SQL WHERE clause
64
- })
65
- ```
66
-
67
- **Rules:**
68
- - Always determine the server first using `sas-score-find-table`
69
- - Keep batch size ≤ 50 rows unless the user explicitly requests more
70
- - If table name is missing, ask: *"Which table should I read from? (format: lib.tablename)"*
71
- - If library is missing, ask: *"Which library contains the table?"*
72
- - If table exists in both servers, ask user which to use
73
- - Return raw column values; do not transform or aggregate
74
-
75
- ---
76
-
77
- ## Using sas-query
78
-
79
- **When:**
80
- - User asks for aggregation (SUM, AVG, COUNT, GROUP BY)
81
- - User asks for joins, calculations, or analytical insights
82
- - User's question is phrased analytically ("compare", "analyze", "breakdown", "trend")
83
-
84
- **How:**
85
- ```
86
- sas-query({
87
- table: "lib.tablename",
88
- query: "user's natural language question",
89
- sql: "SELECT ... FROM ... WHERE ... GROUP BY ..." // generated from query
90
- })
91
- ```
92
-
93
- **Rules:**
94
- - Check which server(s) contain the table using `sas-score-find-table` first
95
- - If table exists in both CAS and SAS, ask user which to query from
96
- - Parse the user's natural language question into a PROC SQL SELECT statement
97
- - Ensure SELECT statement is valid SQL syntax
98
- - Do not add trailing semicolons to the SQL string
99
- - If table name is missing, ask: *"Which table should I query? (format: lib.tablename)"*
100
- - If the intent is unclear, ask for clarification: *"Do you want raw rows, or an aggregated summary?"*
101
-
102
- ---
103
-
104
- ## Common patterns
105
-
106
- **Pattern A — Raw row retrieval**
107
- > "Show me the first 5 rows from Public.customers"
108
-
109
- → `sas-score-read-table({ table: "customers", lib: "Public", limit: 5 })`
110
-
111
- **Pattern B — Filtered retrieval**
112
- > "Get all high-value orders (amount > 5000) from mylib.orders"
113
-
114
- → `sas-score-read-table({ table: "orders", lib: "mylib", where: "amount > 5000" })`
115
-
116
- **Pattern C — Aggregation**
117
- > "What is the average price by make in Public.cars?"
118
-
119
- → `sas-score-sas-query({ table: "Public.cars", query: "average price by make", sql: "SELECT make, AVG(msrp) AS avg_price FROM Public.cars GROUP BY make" })`
120
-
121
- **Pattern D — Join + analysis**
122
- > "Show me total sales by customer in the sales and customers tables"
123
-
124
- → `sas-score-sas-query()` with a JOIN in the generated SQL
125
-
126
- ---
127
-
128
- ## Error handling
129
-
130
- | Problem | Action |
131
- |---|---|
132
- | Library not found | Use `sas-find-library-smart` skill to verify the library exists |
133
- | Table not found in either server | Inform user and suggest checking the table name |
134
- | Table exists in both CAS and SAS | Ask: *"The table exists in both servers. Which would you prefer: CAS or SAS?"* |
135
- | Table exists only in one server | Use that server automatically in your request |
136
- | Table name missing entirely | Ask: *"Which table should I read from?"* |
137
- | Ambiguous intent (raw vs aggregate) | Ask: *"Do you want individual rows or a summary by some field?"* |
138
- | Empty result | Inform user, ask to adjust filter or query |
139
-
140
- ---
141
-
142
- ## Integration with other skills
143
-
144
- - **Before this skill**: Use `sas-find-library-smart` to verify and locate the library
145
- - **After this skill**: Use `sas-read-and-score` to score the retrieved data
146
-
147
- ---
148
-
149
- ## Next steps
150
-
151
- Once data is retrieved, typical follow-ups include:
152
- - **Visualize** — present as table or chart
153
- - **Export** — format and offer download
154
- - **Analyze further** — ask clarifying questions
155
- - **Score** — run predictions on the data
156
- - **Combine** — join with other datasets
@@ -1,69 +0,0 @@
1
- ---
2
- name: sas-request-classifier
3
- description: Classify ambiguous SAS or Viya requests before using MCP tools. Use when prompts mention jobs, code, models, scoring, CAS tables, content, or resources and the correct SAS domain is not yet clear.
4
- ---
5
-
6
- # SAS Request Classifier
7
-
8
- Use this skill to determine what kind of SAS object, workflow, or environment the user is referring to before selecting tools.
9
-
10
- ## When to use
11
- Use this skill when the request contains ambiguous domain terms such as:
12
- - model
13
- - score
14
- - scoring
15
- - read
16
- - query
17
- - job
18
- - jobdef
19
- - code
20
- - table
21
- - content
22
- - asset
23
- - resource
24
-
25
- Use this skill before any execution-oriented tool call if there is a chance the request is referring to the wrong SAS domain.
26
-
27
- ## Goal
28
- Map the user request to the most likely SAS domain and hand off to the correct downstream skill or tool path.
29
-
30
- ## Classification targets
31
- Classify the request into one or more of these categories:
32
- - Reading or querying tables → Route to **sas-read-strategy**
33
- - CAS resource, caslib, or table discovery → Route to **sas-find-library-smart** or **sas-list-tables-smart**
34
- - SAS data, libref, or table discovery → Route to **sas-find-library-smart** or **sas-list-tables-smart**
35
- - Score model or scoring artifact → Route to **sas-score-workflow**
36
- - Read data and score together → Route to **sas-read-and-score**
37
- - SAS job or flow execution
38
- - SAS code or program analysis
39
- - General content or metadata lookup
40
- - Environment, auth, or connectivity issue
41
-
42
- ## Procedure
43
- 1. Read the request and identify ambiguous nouns and verbs.
44
- 2. Infer whether the request is asking to discover, inspect, execute, deploy, score, compare, or troubleshoot.
45
- 3. Decide the most likely SAS domain and matching skill.
46
- 4. If confidence is low, ask one focused clarifying question.
47
- 5. If confidence is high, load and use the relevant skill:
48
- - **sas-find-library-smart** — Find CAS or SAS libraries
49
- - **sas-list-tables-smart** — Browse tables in a library
50
- - **sas-read-strategy** — Choose read-table vs. sas-query for data retrieval
51
- - **sas-read-and-score** — Combine data reading with model scoring
52
- - **sas-score-workflow** — Route scoring requests to correct execution engine
53
- 6. Only after classification and skill guidance, use MCP tools.
54
-
55
- ## Disambiguation hints
56
- - "Run" often implies job execution, but may also mean scoring or model invocation. Check for "score" or "model" context.
57
- - "Model" may refer to MAS models, SAS jobs, jobdefs, or SCR models. Look for context or type suffix (e.g., `.job`, `.mas`, `.scr`).
58
- - "Score" may refer to model scoring or job execution. Look for model name or context.
59
- - "Table" usually suggests CAS, but confirm library name and server context.
60
- - "Find", "list", "browse" — starts as discovery. Route to sas-find-library-smart or sas-list-tables-smart.
61
- - "Read", "query", "fetch" — data retrieval. Route to sas-read-strategy.
62
- - "Predict", "score records", "run model on data" — combined workflow. Route to sas-read-and-score or sas-score-workflow.
63
-
64
- ## Output
65
- When you finish classification, state:
66
- - the inferred SAS domain
67
- - the confidence level
68
- - the relevant skill(s) to load
69
- - any remaining ambiguity or clarifying questions needed
@@ -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