@sassoftware/sas-score-mcp-serverjs 1.0.1-7 → 1.0.1-9

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.
@@ -0,0 +1,128 @@
1
+ ---
2
+ name: sas-list-tables-smart
3
+ description: >
4
+ List all tables in a SAS Viya library with intelligent server detection. When the server is not
5
+ specified, automatically checks CAS first, then SAS if not found. Informs the user if the library
6
+ does not exist in either server. Use this skill when the user wants to browse or explore available
7
+ tables. Trigger phrases include: "list tables in", "show tables in", "what tables are in",
8
+ "browse tables in", "tables in library", "enumerate tables", or any request to explore data sources.
9
+ ---
10
+
11
+ # Smart Data Access in SAS Library (List, Read, Query)
12
+
13
+ Intelligently enumerates tables in a SAS Viya library, automatically determining the correct server
14
+ when not explicitly specified.
15
+
16
+ > **Pre-flight check**: Before listing tables, verify the library and table context using the `sas-find-resource-strategy` skill.
17
+ > This ensures consistent server detection across all data operations.
18
+
19
+ **If the user specifies the server explicitly** (e.g., "list tables in Public in cas"):
20
+ - Use the specified server: `server: "cas"` or `server: "sas"`
21
+ - Proceed directly to listing tables
22
+
23
+ **If the server is NOT specified:**
24
+ 1. **First attempt**: Check CAS (`server: "cas"`)
25
+ 2. **If no tables found in CAS**: Check SAS (`server: "sas"`)
26
+ 3. **If no tables found in either**:
27
+ - Inform user: *"The library '<lib>' was not found in CAS or SAS. Please verify the library name is correct."*
28
+ - Ask for corrected library name or explicit server context
29
+
30
+ ---
31
+
32
+ ## Using sas-score-list-tables
33
+
34
+ **When:**
35
+ - User wants to browse all tables in a library
36
+ - User wants to see what data is available
37
+ - User wants to explore library contents before querying
38
+
39
+ **How:**
40
+ ```
41
+ sas-score-list-tables({
42
+ lib: "libraryname", // required
43
+ server: "cas" or "sas", // required; determined by server check
44
+ limit: 10, // optional; default 10, adjust for pagination
45
+ start: 1 // optional; default 1, use for pagination
46
+ })
47
+ ```
48
+
49
+ **Rules:**
50
+ - Always determine the correct server first (cas → sas → neither)
51
+ - **For SAS server: always uppercase the library name** (e.g., "maps" → "MAPS")
52
+ - If library name is missing, ask: *"Which library should I list tables from?"*
53
+ - Default page size is 10; adjust based on user request ("show me all", "25 tables", etc.)
54
+ - If returned table count equals the limit, suggest pagination: *"There may be more tables. Use `start: {next_offset}` to see more."*
55
+ - If no tables are found despite library existing, report: *"No tables found in {lib} on {server} server."*
56
+ - Return table names only; do not fetch table metadata unless explicitly requested
57
+ - Do not use list tools to determine whether a specific resource exists
58
+
59
+ ---
60
+
61
+ ## Smart server detection logic
62
+
63
+ ```
64
+ IF server specified by user
65
+ → IF server is "sas"
66
+ → uppercase lib
67
+ → use that server
68
+ ELSE
69
+ → TRY sas-score-list-tables(lib, server="cas")
70
+ IF tables found
71
+ → success, return tables
72
+ ELSE
73
+ → uppercase lib
74
+ → TRY sas-score-list-tables(lib.toUpperCase(), server="sas")
75
+ IF tables found
76
+ → success, return tables
77
+ ELSE
78
+ → inform user library not found in either server
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Common patterns
84
+
85
+ **Pattern 1 — List tables, server unspecified**
86
+ > "List tables in Public"
87
+
88
+ 1. Try CAS: `sas-score-list-tables({ lib: "Public", server: "cas" })`
89
+ 2. If empty, try SAS with uppercase: `sas-score-list-tables({ lib: "PUBLIC", server: "sas" })`
90
+ 3. If still empty → inform user
91
+
92
+ **Pattern 2 — List tables with explicit server (SAS)**
93
+ > "List tables in sashelp in sas"
94
+
95
+ 1. Skip server detection
96
+ 2. Call with uppercase lib: `sas-score-list-tables({ lib: "SASHELP", server: "sas" })`
97
+
98
+ **Pattern 3 — List tables with explicit server (CAS)**
99
+ > "List tables in Public in cas"
100
+
101
+ 1. No uppercase needed for CAS
102
+ 2. Call: `sas-score-list-tables({ lib: "Public", server: "cas" })`
103
+
104
+ **Pattern 4 — Pagination**
105
+ > "Show me 25 tables in Samples, then the next batch"
106
+
107
+ 1. First call: `sas-score-list-tables({ lib: "Samples", limit: 25, start: 1 })`
108
+ 2. Next call: `sas-score-list-tables({ lib: "Samples", limit: 25, start: 26 })`
109
+
110
+ **Pattern 5 — Library not found**
111
+ > "List tables in foo"
112
+
113
+ 1. Try CAS: empty
114
+ 2. Try SAS with uppercase: empty
115
+ 3. Response: *"The library 'foo' was not found in CAS or SAS. Please verify the library name."*
116
+
117
+ ---
118
+
119
+ ## Error handling
120
+
121
+ | Scenario | Action |
122
+ |---|---|
123
+ | Library not found in either server | Inform user and ask to verify library name |
124
+ | Empty result on first server | Automatically check second server |
125
+ | User specifies invalid server | Return error; ask user to clarify: `"cas"` or `"sas"` |
126
+ | Missing library name | Ask: *"Which library should I list tables from?"* |
127
+ | Library verification needed | Use `sas-find-resource-strategy` to verify the library exists first |
128
+
@@ -0,0 +1,113 @@
1
+ ---
2
+ name: sas-read-and-score-strategy
3
+ description: >
4
+ Guide the full read → score workflow in SAS Viya: reading records from a table and then scoring
5
+ them with a MAS model (using sas-score-model-score). Use this skill whenever the user wants to score records
6
+ from a table, run a model against query results, predict outcomes for a set of rows, or any
7
+ combination of fetching data and scoring it. Trigger phrases include: "score these records",
8
+ "score results of my query", "run the model on this table", "predict for these customers",
9
+ "fetch and score", "read and score", "score rows from", "run model on table data", or any request
10
+ that combines reading/querying table data with model prediction.
11
+ ---
12
+
13
+ # SAS Read → Score Workflow
14
+
15
+ Orchestrates the full two-step pattern of reading records from a SAS/CAS table and scoring them
16
+ with a deployed MAS model.
17
+
18
+ ---
19
+
20
+ ## Pre-flight verification
21
+
22
+ **Before attempting to read or score table data:**
23
+ 1. **Verify library exists**: Use `sas-find-resource-strategy` for library lookup (CAS first, then SAS if needed)
24
+ 2. **Verify table exists**: Use `sas-find-resource-strategy` for table lookup in the selected library/server
25
+ 3. **Verify model exists**: Use `sas-find-resource-strategy` for model lookup before scoring
26
+ 4. **Confirm server location**: Ensure you know which server (CAS or SAS) contains the data
27
+
28
+ This ensures consistent behavior with other data access operations.
29
+
30
+ ---
31
+
32
+ ## Workflow overview
33
+
34
+ The typical flow involves:
35
+ 1. **Fetch data** — Identify which table/query will provide input records
36
+ 2. **Validate model** — Confirm the model exists and understand its input schema
37
+ 3. **Score** — Invoke the model on the fetched records
38
+ 4. **Present results** — Merge predictions with original data and display
39
+
40
+ ---
41
+
42
+ ## Scenario: User already has data
43
+
44
+ If the user provides scenario data directly (e.g., "Score age=45, income=60000 with model X"):
45
+ - Extract the scenario values
46
+ - Validate against model's input schema
47
+ - Invoke scoring
48
+ - Return prediction
49
+
50
+ ---
51
+
52
+ ## Scenario: User wants to score table rows
53
+
54
+ If the user specifies a table (e.g., "Score all customers in Public.customers with model X"):
55
+ - Fetch raw rows (possibly filtered: "where status='active'")
56
+ - Validate model compatibility with input columns
57
+ - Invoke scoring on each row
58
+ - Merge results with original data
59
+ - Display combined table
60
+
61
+ ---
62
+
63
+ ## Scenario: User wants to score query results
64
+
65
+ If the user wants to score aggregated/filtered results (e.g., "Score high-value customers (spend > 5000) with model X"):
66
+ - Determine which records meet criteria (aggregation/filtering)
67
+ - Validate model expects these input columns
68
+ - Invoke scoring
69
+ - Merge predictions with summary data
70
+ - Display results
71
+
72
+ ---
73
+
74
+ ## Scenario: User unfamiliar with model
75
+
76
+ If the user specifies a model name that's new/unknown:
77
+ - Check if model exists
78
+ - Retrieve model schema (inputs, outputs)
79
+ - Show user what inputs the model expects
80
+ - Confirm before proceeding with scoring
81
+
82
+ ---
83
+
84
+ ## Rules
85
+
86
+ - Always validate table/library existence before attempting to read
87
+ - Always check model exists before invoking `sas-score-model-score`
88
+ - Match table columns to model input variables; warn on mismatch
89
+ - Use find tools only for resource existence checks; do not use list tools to find resources
90
+ - If multiple records: score batch if possible; fall back to row-by-row
91
+ - Merge predictions with original data using row index or key column
92
+ - Present results as table with original columns + new prediction columns
93
+
94
+ ---
95
+
96
+ ## Error handling
97
+
98
+ | Problem | Action |
99
+ |---|---|
100
+ | Table not found | Ask for correct lib.tablename |
101
+ | Model not found | Inform user; suggest verifying model name |
102
+ | Field/column mismatch | Show mismatch, ask user to confirm or adjust query |
103
+ | Scoring error | Return structured error, suggest checking model inputs |
104
+ | Empty read result | Inform user, ask if they want to adjust the query/filter |
105
+ | Data type mismatch | Warn user about type conversion, proceed or ask for clarification |
106
+
107
+ ---
108
+
109
+ ## Integration with other skills
110
+
111
+ - **Before this workflow**: Use `sas-find-resource-strategy` to verify library/table/model resources exist
112
+ - **For data retrieval**: Use `sas-read-strategy` to choose the right read tool (read-table vs sas-query)
113
+ - **For scoring**: Use `sas-score-workflow-strategy` for advanced scoring options beyond MAS models
@@ -0,0 +1,154 @@
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, locate the specific table first and determine which server(s) contain it:
19
+
20
+ **Step 1: Locate the specific table (table-first)**
21
+ - Use `sas-find-resource-strategy` to check if the table exists in CAS first, then SAS if needed
22
+ - Do not perform a separate library-first lookup; table lookup already handles server-aware discovery
23
+ - Possible outcomes:
24
+ - If table exists **only in CAS** → set `server: "cas"`
25
+ - If table exists **only in SAS** → set `server: "sas"`
26
+ - If table exists **in both** → ask the user: *"The table exists in both CAS and SAS. Which server would you prefer to query from?"*
27
+ - If table exists **in neither** → inform user and suggest verifying the table name
28
+
29
+ ---
30
+
31
+ ## Determine the read strategy
32
+
33
+ Ask yourself: does the user already have the data in hand?
34
+
35
+ - **Yes (user pasted values, or data is already in context)** → skip this strategy; data is ready to use.
36
+ - **No** → choose the read tool based on intent:
37
+
38
+ | User's Intent | Tool | Example |
39
+ |---|---|---|
40
+ | Get specific raw rows, apply simple filter, retrieve first N records | `sas-score-read-table` | "Show me 10 rows from customers where status='active'" |
41
+ | Aggregate/summarize, calculate, join tables, analytical question | `sas-score-sas-query` | "Average salary by department", "Count orders by region" |
42
+
43
+ ---
44
+
45
+ ## Using read-table
46
+
47
+ **When:**
48
+ - User asks for raw records, row-by-row data
49
+ - Simple WHERE filtering (e.g., "where status = 'active'")
50
+ - Pagination needed ("first 50 rows", "next 10 rows")
51
+
52
+ **How:**
53
+ ```
54
+ sas-score-read-table({
55
+ table: "tablename",
56
+ lib: "libraryname",
57
+ server: "cas" or "sas", // determined from table-first lookup via sas-find-resource-strategy
58
+ limit: N, // default 10, adjust based on user request
59
+ where: "..." // optional SQL WHERE clause
60
+ })
61
+ ```
62
+
63
+ **Rules:**
64
+ - Always determine the server first using `sas-find-resource-strategy`
65
+ - Keep batch size ≤ 50 rows unless the user explicitly requests more
66
+ - If table name is missing, ask: *"Which table should I read from? (format: lib.tablename)"*
67
+ - If library is missing, ask: *"Which library contains the table?"*
68
+ - Prefer table-first lookup (CAS first, then SAS) instead of a separate library lookup step
69
+ - If table exists in both servers, ask user which to use
70
+ - Return raw column values; do not transform or aggregate
71
+ - Do not use list tools to determine whether a resource exists
72
+
73
+ ---
74
+
75
+ ## Using sas-query
76
+
77
+ **When:**
78
+ - User asks for aggregation (SUM, AVG, COUNT, GROUP BY)
79
+ - User asks for joins, calculations, or analytical insights
80
+ - User's question is phrased analytically ("compare", "analyze", "breakdown", "trend")
81
+
82
+ **How:**
83
+ ```
84
+ sas-query({
85
+ table: "lib.tablename",
86
+ query: "user's natural language question",
87
+ sql: "SELECT ... FROM ... WHERE ... GROUP BY ..." // generated from query
88
+ })
89
+ ```
90
+
91
+ **Rules:**
92
+ - Check which server(s) contain the table using `sas-find-resource-strategy` first
93
+ - If table exists in both CAS and SAS, ask user which to query from
94
+ - Parse the user's natural language question into a PROC SQL SELECT statement
95
+ - Ensure SELECT statement is valid SQL syntax
96
+ - Do not add trailing semicolons to the SQL string
97
+ - If table name is missing, ask: *"Which table should I query? (format: lib.tablename)"*
98
+ - If the intent is unclear, ask for clarification: *"Do you want raw rows, or an aggregated summary?"*
99
+
100
+ ---
101
+
102
+ ## Common patterns
103
+
104
+ **Pattern A — Raw row retrieval**
105
+ > "Show me the first 5 rows from Public.customers"
106
+
107
+ → `sas-score-read-table({ table: "customers", lib: "Public", limit: 5 })`
108
+
109
+ **Pattern B — Filtered retrieval**
110
+ > "Get all high-value orders (amount > 5000) from mylib.orders"
111
+
112
+ → `sas-score-read-table({ table: "orders", lib: "mylib", where: "amount > 5000" })`
113
+
114
+ **Pattern C — Aggregation**
115
+ > "What is the average price by make in Public.cars?"
116
+
117
+ → `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" })`
118
+
119
+ **Pattern D — Join + analysis**
120
+ > "Show me total sales by customer in the sales and customers tables"
121
+
122
+ → `sas-score-sas-query()` with a JOIN in the generated SQL
123
+
124
+ ---
125
+
126
+ ## Error handling
127
+
128
+ | Problem | Action |
129
+ |---|---|
130
+ | Library missing or unclear | Ask the user which library contains the table |
131
+ | Table not found in either server | Inform user and suggest checking the table name |
132
+ | Table exists in both CAS and SAS | Ask: *"The table exists in both servers. Which would you prefer: CAS or SAS?"* |
133
+ | Table exists only in one server | Use that server automatically in your request |
134
+ | Table name missing entirely | Ask: *"Which table should I read from?"* |
135
+ | Ambiguous intent (raw vs aggregate) | Ask: *"Do you want individual rows or a summary by some field?"* |
136
+ | Empty result | Inform user, ask to adjust filter or query |
137
+
138
+ ---
139
+
140
+ ## Integration with other skills
141
+
142
+ - **Before this skill**: Use `sas-find-resource-strategy` for table-first resource lookup
143
+ - **After this skill**: Use `sas-read-and-score-strategy` to score the retrieved data
144
+
145
+ ---
146
+
147
+ ## Next steps
148
+
149
+ Once data is retrieved, typical follow-ups include:
150
+ - **Visualize** — present as table or chart
151
+ - **Export** — format and offer download
152
+ - **Analyze further** — ask clarifying questions
153
+ - **Score** — run predictions on the data
154
+ - **Combine** — join with other datasets
@@ -0,0 +1,74 @@
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
+ - Resource existence lookup (library/table/model/job/jobdef) -> Route to **sas-find-resource-strategy**
33
+ - Resource listing (library/table/model/job/jobdef) -> Route to **sas-list-resource-strategy**
34
+ - Reading or querying tables → Route to **sas-read-strategy**
35
+ - CAS resource, SAS resource, caslib, or table discovery → Route to **sas-find-library-smart**
36
+ - SAS data, libref, or table discovery → Route to **sas-find-library-smart**
37
+ - Score model or scoring artifact → Route to **sas-score-workflow-strategy**
38
+ - Read data and score together → Route to **sas-read-and-score-strategy**
39
+ - SAS job or flow execution
40
+ - SAS code or program analysis
41
+ - General content or metadata lookup
42
+ - Environment, auth, or connectivity issue
43
+
44
+ ## Procedure
45
+ 1. Read the request and identify ambiguous nouns and verbs.
46
+ 2. Infer whether the request is asking to discover, inspect, execute, deploy, score, compare, or troubleshoot.
47
+ 3. Decide the most likely SAS domain and matching skill.
48
+ 4. If confidence is low, ask one focused clarifying question.
49
+ 5. If confidence is high, load and use the relevant skill:
50
+ - **sas-find-resource-strategy** — Unified find-only strategy for library/table/model/job/jobdef
51
+ - **sas-list-resource-strategy** — Unified list strategy for library/table/model/job/jobdef with non-null pagination defaults
52
+ - **sas-find-library-smart** — Find CAS or SAS libraries
53
+ - **sas-list-tables-smart** — Browse tables in a library
54
+ - **sas-read-strategy** — Choose read-table vs. sas-query for data retrieval
55
+ - **sas-read-and-score-strategy** — Combine data reading with model scoring
56
+ - **sas-score-workflow-strategy** — Route scoring requests to correct execution engine
57
+ 6. Only after classification and skill guidance, use MCP tools.
58
+
59
+ ## Disambiguation hints
60
+ - "Run" often implies job execution, but may also mean scoring or model invocation. Check for "score" or "model" context.
61
+ - "Model" may refer to MAS models, SAS jobs, jobdefs, or SCR models. Look for context or type suffix (e.g., `.job`, `.mas`, `.scr`).
62
+ - "Score" may refer to model scoring or job execution. Look for model name or context.
63
+ - "Table" usually suggests CAS or SAS but confirm library name and server context.
64
+ - "Find" — resource lookup. Route to sas-find-resource-strategy.
65
+ - "List" or "browse" — resource exploration. Route to sas-list-resource-strategy.
66
+ - "Read", "query", "fetch" — data retrieval. Route to sas-read-strategy.
67
+ - "Predict", "score records", "run model on data" — combined workflow. Route to sas-read-and-score-strategy or sas-score-workflow-strategy.
68
+
69
+ ## Output
70
+ When you finish classification, state:
71
+ - the inferred SAS domain
72
+ - the confidence level
73
+ - the relevant skill(s) to load
74
+ - any remaining ambiguity or clarifying questions needed