@sassoftware/sas-score-mcp-serverjs 0.4.1-1 → 0.4.1-5

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,57 +1,58 @@
1
- /*
2
- * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- import { z } from 'zod';
6
- import debug from 'debug';
7
-
8
- import _tableInfo from '../toolHelpers/_tableInfo.js';
9
- function tableInfo(_appContext) {
10
-
11
- let describe = `
12
- table-info retrieve metadata about a table in a CAS or SAS library.
13
-
14
- USE when: what columns, describe structure, show schema, table statistics, column info
15
- DO NOT USE for: read data (use read-table), list tables (use list-tables), find table (use find-table), queries (use sas-query)
16
-
17
- PARAMETERS
18
- - table: string — table name (required)
19
- - lib: string — caslib or libref (required)
20
- - server: string (default: 'cas') 'cas' or 'sas'
21
-
22
- ROUTING RULES
23
- - "what columns are in cars" → { table: "cars", lib: "<lib>", server: "cas" }
24
- - "describe table sales in Public" → { table: "sales", lib: "Public", server: "cas" }
25
- - "show schema for mylib.iris on sas" → { table: "iris", lib: "mylib", server: "sas" }
26
-
27
- EXAMPLES
28
- - "what columns in cars" → { table: "cars", lib: "<lib>", server: "cas" }
29
- - "describe structure of customers in Public" → { table: "customers", lib: "Public", server: "cas" }
30
-
31
- NEGATIVE EXAMPLES (do not route here)
32
- - "read table cars" (use read-table)
33
- - "list tables in Public" (use list-tables)
34
- - "does table exist" (use find-table)
35
- - "query table" (use sas-query)
36
-
37
- ERRORS
38
- Returns columns array (name, type, label, format, length) and tableInfo (rowCount, fileSize, created, modified).
39
- `;
40
-
41
- let specs = {
42
- name: 'table-info',
43
- description: describe,
44
- inputSchema: z.object({
45
- table: z.string(),
46
- lib: z.string(),
47
- server: z.string()
48
- }),
49
- handler: async (params) => {
50
- params.describe = true;
51
- let r = await _tableInfo(params);
52
- return r;
53
- }
54
- }
55
- return specs;
56
- }
57
- export default tableInfo;
1
+ /*
2
+ * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { z } from 'zod';
6
+ import debug from 'debug';
7
+
8
+ import _tableInfo from '../toolHelpers/_tableInfo.js';
9
+ import { type } from 'node:os';
10
+ function tableInfo(_appContext) {
11
+
12
+ let describe = `
13
+ table-info — retrieve metadata about a table in a CAS or SAS library.
14
+
15
+ USE when: what columns, describe structure, show schema, table statistics, column info
16
+ DO NOT USE for: read data (use read-table), list tables (use list-tables), find table (use find-table), queries (use sas-query)
17
+
18
+ PARAMETERS
19
+ - table: string — table name (required)
20
+ - lib: string — caslib or libref (required)
21
+ - server: string (default: 'cas') — 'cas' or 'sas'
22
+
23
+ ROUTING RULES
24
+ - "what columns are in cars" → { table: "cars", lib: "<lib>", server: "cas" }
25
+ - "describe table sales in Public" → { table: "sales", lib: "Public", server: "cas" }
26
+ - "show schema for mylib.iris on sas" → { table: "iris", lib: "mylib", server: "sas" }
27
+
28
+ EXAMPLES
29
+ - "what columns in cars" → { table: "cars", lib: "<lib>", server: "cas" }
30
+ - "describe structure of customers in Public" → { table: "customers", lib: "Public", server: "cas" }
31
+
32
+ NEGATIVE EXAMPLES (do not route here)
33
+ - "read table cars" (use read-table)
34
+ - "list tables in Public" (use list-tables)
35
+ - "does table exist" (use find-table)
36
+ - "query table" (use sas-query)
37
+
38
+ ERRORS
39
+ Returns columns array (name, type, label, format, length) and tableInfo (rowCount, fileSize, created, modified).
40
+ `;
41
+
42
+ let specs = {
43
+ name: 'table-info',
44
+ description: describe,
45
+ inputSchema: z.object({
46
+ table: z.string(),
47
+ lib: z.string().optional(),
48
+ server: z.string().optional()
49
+ }),
50
+ handler: async (params) => {
51
+ params.describe = true;
52
+ let r = await _tableInfo(params);
53
+ return r;
54
+ }
55
+ }
56
+ return specs;
57
+ }
58
+ export default tableInfo;
@@ -1,129 +0,0 @@
1
- ---
2
- name: mcp-tool-description-optimizer
3
- description: >
4
- Optimize MCP (Model Context Protocol) tool descriptions for token efficiency and LLM routing accuracy.
5
- Use this skill whenever a user shares a raw, verbose, or poorly structured MCP tool description and wants
6
- it improved, rewritten, or reviewed. Trigger on phrases like: "optimize this tool description",
7
- "rewrite my MCP tool description", "make this tool description more efficient", "clean up my tool spec",
8
- "improve how Claude picks my tool", or when a user pastes a JavaScript/TypeScript tool description string
9
- and asks for help with it. Also trigger when the user mentions token efficiency, tool routing,
10
- or LLM disambiguation in the context of MCP servers.
11
- ---
12
-
13
- # MCP Tool Description Optimizer
14
-
15
- Rewrites verbose or poorly structured MCP tool descriptions into compact, signal-rich versions that
16
- improve LLM tool selection accuracy while reducing token usage.
17
-
18
- ## Why this matters
19
-
20
- Claude and other LLMs select MCP tools based entirely on the `description` field. Descriptions that are
21
- too long, redundant, or badly structured waste context tokens and reduce routing precision.
22
- A well-optimized description:
23
- - States what the tool does and when to use it upfront
24
- - Eliminates redundancy (same info repeated across sections)
25
- - Uses a compact, scannable format (labeled blocks, not nested markdown)
26
- - Includes clear negative examples to prevent mis-routing
27
- - Keeps parameters terse — name, type, default, one-line purpose
28
-
29
- ---
30
-
31
- ## Optimization Process
32
-
33
- ### Step 1 — Analyze the input description
34
-
35
- Before rewriting, identify these problems in the original:
36
-
37
- | Problem | Example |
38
- |---|---|
39
- | **Redundancy** | Trigger phrases listed in 3+ places |
40
- | **Filler sections** | "Rationale", "Behavior Summary", "Response Contract" with no routing signal |
41
- | **Orphaned syntax** | Arrows (`→`) or bullets with no target |
42
- | **Overlong examples** | Long prose examples when one-liners suffice |
43
- | **Heavy markdown** | `##` headers for every minor point |
44
- | **Duplicated parameter docs** | Same param described in both a table and prose |
45
-
46
- Call out 2–4 of the most impactful issues before writing the new version.
47
-
48
- ### Step 2 — Rewrite using the standard template
49
-
50
- Use this exact block structure for the output. Omit blocks that don't apply.
51
-
52
- ```
53
- <tool-name> — <one-line purpose>.
54
-
55
- USE when: <comma-separated user intents or trigger phrases>
56
- DO NOT USE for: <comma-separated anti-patterns with → redirect where applicable>
57
-
58
- PARAMETERS
59
- - <name>: <type> (default: <val>) — <one-line purpose>
60
- ...
61
-
62
- ROUTING RULES
63
- - "<trigger phrase>" → { param: value }
64
- - "<trigger phrase>" → { param: value }
65
- - <ambiguous case> → <ask for clarification | default behavior>
66
-
67
- EXAMPLES
68
- - "<user utterance>" → { param: value, ... }
69
- - "<user utterance>" → { param: value, ... }
70
-
71
- NEGATIVE EXAMPLES (do not route here)
72
- - "<user utterance>" → <correct tool>
73
-
74
- PAGINATION (include only if tool is paginated)
75
- If returned count === limit → hint: next start = start + limit.
76
- If start > 1 and result empty → note paging may exceed available items.
77
-
78
- ERRORS
79
- <One or two lines: return structure, hallucination policy>
80
- ```
81
-
82
- ### Step 3 — Apply these rules consistently
83
-
84
- **USE/DO NOT USE block**
85
- - Write as comma-separated inline list, not a bullet list
86
- - DO NOT USE entries should name the redirect tool in parentheses where known
87
-
88
- **ROUTING RULES block**
89
- - One rule per line; quote the trigger phrase; use `→ { }` for param mapping
90
- - Consolidate synonyms on one line: `"cas libs / cas libraries / in cas" → { server: 'cas' }`
91
- - List the default/fallback rule last
92
-
93
- **PARAMETERS block**
94
- - One line per param: `- name: type (default: val) — purpose`
95
- - Skip obvious params (e.g. don't explain what `limit` means if it's standard pagination)
96
-
97
- **EXAMPLES block**
98
- - Each example fits on one line
99
- - For "next page" examples, include the prior call's state inline: `"next" (prev: start:1, limit:10) → { start: 11, limit: 10 }`
100
-
101
- **NEGATIVE EXAMPLES block**
102
- - Only include when mis-routing is a real risk
103
- - Format: `"<utterance>" → <correct-tool-name>`
104
-
105
- **Tone**
106
- - Imperative, terse. No filler words ("Please note that...", "It is important to...")
107
- - Never include a "Rationale" or "Behavior Summary" section — if behavior matters, encode it as a rule
108
-
109
- ### Step 4 — Validate before returning
110
-
111
- Check the rewritten description against this list:
112
-
113
- - [ ] No trigger phrase appears in more than one block
114
- - [ ] No orphaned `→` arrows or dangling bullets
115
- - [ ] Parameter defaults are stated explicitly
116
- - [ ] Negative examples cover the tool's most common mis-routing risks
117
- - [ ] Total length is ≤ 50% of the original (target: 30–40% reduction)
118
-
119
- ---
120
-
121
- ## Output format
122
-
123
- Always return:
124
-
125
- 1. **Analysis** — 2–4 bullet points naming the key issues found in the original
126
- 2. **Rewritten description** — inside a JavaScript code block (matching the user's original code style)
127
- 3. **Change summary** — a short table or bullet list of what changed and why
128
-
129
- See `references/examples.md` for before/after examples of real tool descriptions.
@@ -1,123 +0,0 @@
1
- # Before / After Examples
2
-
3
- ## Example 1 — list-libraries (SAS Viya MCP)
4
-
5
- ### BEFORE (~620 tokens)
6
-
7
- ```
8
- ## list-libraries — enumerate CAS or SAS libraries
9
-
10
- LLM Invocation Guidance (critical)
11
- Use THIS tool when the user asks for: "list libs", "list libraries", "show cas libs", "show sas libs",
12
- "what libraries are available", "list caslib(s)", "enumerate libraries", "libraries in cas", "libraries in sas".
13
- DO NOT use this tool when the user asks for: tables inside a specific library (choose listTables),
14
- columns/metadata of a table, job/program execution, models, or scoring.
15
-
16
- Trigger Phrase → Parameter Mapping
17
- - "cas libs" / "in cas" / "cas libraries" → { server: 'cas' }
18
- - "sas libs" / "in sas" / "base sas libraries" → { server: 'sas' }
19
- - "all libs" / "all libs" -> {server: 'all'}
20
- → { server: 'all' }
21
- - "next" (after prior call) → { start: previous.start + previous.limit }
22
- - "first 20 cas libs" → { server: 'cas', limit: 20 }
23
- - If server unspecified: default to all.
24
-
25
- Parameters
26
- - server (cas|sas|all, default 'all')
27
- - limit (integer > 0, default 10)
28
- - start (1-based offset, default 1)
29
- - where (optional filter expression, default '')
30
-
31
- Response Contract
32
- Return JSON-like structure from helper; consumers may extract an array of library objects/names.
33
- If number of returned items === limit supply a pagination hint: start = start + limit.
34
-
35
- Behavior Summary
36
- - Pure listing; no side effects.
37
- - If ambiguous short request like "list" or "libs" and no prior context: assume { server: 'cas' }.
38
- - If user explicitly asks for ALL (e.g. "all cas libs") and count likely large, honor limit=50 unless
39
- user supplies a value; include note about paging.
40
-
41
- Disambiguation Rules
42
- - If user mentions a singular library name plus desire for tables ("list tables in SASHELP") choose
43
- listTables (not this tool).
44
- - If user mixes "tables" and "libraries" ask for clarification unless clearly about libraries.
45
-
46
- Examples
47
- - "list libraries" → { server: 'all', start:1, limit:10 }
48
- - "list libs" → { server: 'all', start:1, limit:10 }
49
- - "list sas libs" → { server: 'sas' }
50
- - "list cas libraries" → { server: 'cas' }
51
- - "show me 25 cas libraries" → { server:'cas', limit:25 }
52
- - "next" (after prior call {start:1,limit:10}) → { start:11, limit:10 }
53
- - "filter cas libs" (no criterion) → ask: "Provide a filter or continue without one?"
54
-
55
- Negative Examples (do not route here)
56
- - "list tables in public" (route to list-tables)
57
- - "list models, list tables, list jobs, list jobdef and similar request"
58
- - "describe library" (likely list-tables or table-info depending on follow-up)
59
- - "run program to make a lib" (run-sas-program tool)
60
-
61
- Error Handling
62
- - On backend error: return structured error with message field; do not hallucinate libraries.
63
- - Empty result set → return empty list plus (if start>1) a hint that paging may have exceeded available items.
64
-
65
- Rationale
66
- Concise, signal-rich description increases probability this spec is selected for generic library
67
- enumeration intents.
68
- ```
69
-
70
- ### AFTER (~210 tokens)
71
-
72
- ```
73
- list-libraries — enumerate CAS or SAS libraries.
74
-
75
- USE when: list/show/enumerate libraries, caslibs, sas libs, available libraries
76
- DO NOT USE for: listing tables in a library (→ list-tables), column/table metadata, job execution, models, scoring
77
-
78
- PARAMETERS
79
- - server: 'cas' | 'sas' | 'all' (default: 'all')
80
- - limit: integer > 0 (default: 10)
81
- - start: 1-based offset (default: 1)
82
- - where: optional filter expression (default: '')
83
-
84
- ROUTING RULES
85
- - "cas libs / cas libraries / in cas" → { server: 'cas' }
86
- - "sas libs / sas libraries / in sas" → { server: 'sas' }
87
- - "all libs / all libraries" → { server: 'all' }
88
- - "all cas libs" with no limit given → { server: 'cas', limit: 50 } + paging note
89
- - "next" after prior call (start:S, limit:L) → { start: S + L, limit: L }
90
- - "filter cas libs" with no filter given → ask: "What filter expression should I apply?"
91
- - server unspecified / ambiguous "list"/"libs" → { server: 'cas' }
92
-
93
- EXAMPLES
94
- - "list libraries" → { server: 'all', start: 1, limit: 10 }
95
- - "list cas libraries" → { server: 'cas', start: 1, limit: 10 }
96
- - "show me 25 sas libs" → { server: 'sas', limit: 25, start: 1 }
97
- - "next" (prev: start:1,limit:10) → { server: <same>, start: 11, limit: 10 }
98
-
99
- NEGATIVE EXAMPLES (do not route here)
100
- - "list tables in SASHELP" → list-tables
101
- - "list models / jobs / jobdefs" → respective tools
102
- - "run a program to create a lib" → run-sas-program
103
-
104
- PAGINATION
105
- If returned count === limit → hint: next start = start + limit.
106
- If start > 1 and result empty → note paging may exceed available items.
107
-
108
- ERRORS
109
- Return structured error with message field. Never hallucinate library names.
110
- ```
111
-
112
- **Token reduction: ~66%**
113
-
114
- ---
115
-
116
- ## Key patterns illustrated
117
-
118
- - Trigger phrases consolidated from 3 blocks → 1 ROUTING RULES block
119
- - "Rationale", "Behavior Summary", "Response Contract" sections eliminated
120
- - Orphaned `→ { server: 'all' }` arrow removed
121
- - Parameter defaults made explicit inline
122
- - Examples trimmed to one line each
123
- - Negative examples now name the redirect tool explicitly
@@ -1,91 +0,0 @@
1
- ---
2
- name: sas-read-and-score
3
- description: >
4
- Guide the full read → score workflow in SAS Viya: reading records from a table (using read-table
5
- or sas-query) and then scoring them with a MAS model (using model-score). Use this skill whenever
6
- the user wants to score records from a table, run a model against query results, predict outcomes
7
- for a set of rows, or any combination of fetching data and scoring it. Trigger phrases include:
8
- "score these records", "score results of my query", "run the model on this table",
9
- "predict for these customers", "fetch and score", "read and score", "score rows from",
10
- "run model on table data", or any request that combines reading 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
- This skill chains two sub-skills:
19
- 1. **sas-read-strategy** — Choose between `read-table` and `sas-query`
20
- 2. **sas-score-workflow** — Validate model, invoke scoring, present results
21
-
22
- ---
23
-
24
- ## Quick reference
25
-
26
- 1. **Does the user already have data in hand?**
27
- - Yes → skip to Step 2 (scoring)
28
- - No → use `sas-read-strategy` to fetch data
29
-
30
- 2. **Is the model name familiar?**
31
- - Yes → proceed to score
32
- - No → pause and use `find-model` / `model-info`
33
-
34
- 3. **Invoke model-score** with the fetched data
35
-
36
- 4. **Merge results** and present as a table
37
-
38
- ---
39
-
40
- ## Common flows
41
-
42
- **Flow A — Score rows from a table directly**
43
- > "Score the first 10 customers in Public.customers with the churn model"
44
-
45
- 1. Apply `sas-read-strategy` → use `read-table` to fetch 10 rows
46
- 2. Apply `sas-score-workflow` → invoke `model-score` and present results
47
-
48
- **Flow B — Score results of an analytical query**
49
- > "Score high-value customers (spend > 5000) in mylib.sales with the fraud model"
50
-
51
- 1. Apply `sas-read-strategy` → use `sas-query` for aggregation
52
- 2. Apply `sas-score-workflow` → invoke `model-score` and present results
53
-
54
- **Flow C — User supplies scenario data directly**
55
- > "Score age=45, income=60000, region=South with the churn model"
56
-
57
- 1. Skip read strategy
58
- 2. Apply `sas-score-workflow` → invoke `model-score` and present result
59
-
60
- **Flow D — Model unfamiliar**
61
- > "Score Public.applicants with the creditRisk2 model"
62
-
63
- 1. Model unfamiliar → use `find-model` to verify existence
64
- 2. Apply `sas-read-strategy` to fetch data
65
- 3. Apply `sas-score-workflow` to score
66
-
67
- ---
68
-
69
- ## For detailed guidance
70
-
71
- - **Read strategy decisions?** See `sas-read-strategy` skill
72
- - **Scoring validation and presentation?** See `sas-score-workflow` skill
73
-
74
- **Flow D — Model unfamiliar**
75
- > "Score Public.applicants with the creditRisk2 model"
76
-
77
- 1. Pause — "creditRisk2" is new
78
- 2. Suggest: `find-model` to confirm it exists, `model-info` to get input variables
79
- 3. Once confirmed → `read-table` + `model-score`
80
-
81
- ---
82
-
83
- ## Error handling
84
-
85
- | Problem | Action |
86
- |---|---|
87
- | Table not found | Ask for correct lib.tablename |
88
- | Model not found | Suggest find-model |
89
- | Field name mismatch | Show mismatch, ask user to confirm mapping |
90
- | Scoring error | Return structured error, suggest model-info |
91
- | Empty read result | Tell user, ask if they want to adjust the query/filter |
@@ -1,143 +0,0 @@
1
- ---
2
- name: sas-read-strategy
3
- description: >
4
- Guide the user in choosing the right data retrieval tool: read-table (for raw row access with filters)
5
- or 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 `read-table` and `sas-query` based on the user's intent and the nature
14
- of the data operation.
15
-
16
- ---
17
-
18
- ## Determine the server location
19
-
20
- Before retrieving data, check which server(s) contain the table:
21
-
22
- 1. **Check both servers**: Use `find-table` to check if the table exists in CAS and/or SAS
23
- 2. **Decide server placement**:
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 ask which library to search in
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 | `read-table` | "Show me 10 rows from customers where status='active'" |
41
- | Aggregate/summarize, calculate, join tables, analytical question | `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
- read-table({
55
- table: "tablename",
56
- lib: "libraryname",
57
- server: "cas" or "sas", // determined from find-table check
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 `find-table`
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
- - If table exists in both servers, ask user which to use
69
- - Return raw column values; do not transform or aggregate
70
-
71
- ---
72
-
73
- ## Using sas-query
74
-
75
- **When:**
76
- - User asks for aggregation (SUM, AVG, COUNT, GROUP BY)
77
- - User asks for joins, calculations, or analytical insights
78
- - User's question is phrased analytically ("compare", "analyze", "breakdown", "trend")
79
-
80
- **How:**
81
- ```
82
- sas-query({
83
- table: "lib.tablename",
84
- query: "user's natural language question",
85
- sql: "SELECT ... FROM ... WHERE ... GROUP BY ..." // generated from query
86
- })
87
- ```
88
-
89
- **Rules:**
90
- - Check which server(s) contain the table using `find-table` first
91
- - If table exists in both CAS and SAS, ask user which to query from
92
- - Parse the user's natural language question into a PROC SQL SELECT statement
93
- - Ensure SELECT statement is valid SQL syntax
94
- - Do not add trailing semicolons to the SQL string
95
- - If table name is missing, ask: *"Which table should I query? (format: lib.tablename)"*
96
- - If the intent is unclear, ask for clarification: *"Do you want raw rows, or an aggregated summary?"*
97
-
98
- ---
99
-
100
- ## Common patterns
101
-
102
- **Pattern A — Raw row retrieval**
103
- > "Show me the first 5 rows from Public.customers"
104
-
105
- → `read-table({ table: "customers", lib: "Public", limit: 5 })`
106
-
107
- **Pattern B — Filtered retrieval**
108
- > "Get all high-value orders (amount > 5000) from mylib.orders"
109
-
110
- → `read-table({ table: "orders", lib: "mylib", where: "amount > 5000" })`
111
-
112
- **Pattern C — Aggregation**
113
- > "What is the average price by make in Public.cars?"
114
-
115
- → `sas-query({ table: "Public.cars", query: "average price by make", sql: "SELECT make, AVG(msrp) AS avg_price FROM Public.cars GROUP BY make" })`
116
-
117
- **Pattern D — Join + analysis**
118
- > "Show me total sales by customer in the sales and customers tables"
119
-
120
- → `sas-query()` with a JOIN in the generated SQL
121
-
122
- ---
123
-
124
- ## Error handling
125
-
126
- | Problem | Action |
127
- |---|---|
128
- | Table not found in either server | Ask: *"Which library contains the table? (e.g., Public, Samples, mylib)"* |
129
- | Table exists in both CAS and SAS | Ask: *"The table exists in both servers. Which would you prefer: CAS or SAS?"* |
130
- | Table exists only in one server | Use that server automatically in your request |
131
- | Library not found | Ask: *"Which library contains the table? (e.g., Public, Samples, mylib)"* |
132
- | Ambiguous intent (raw vs aggregate) | Ask: *"Do you want individual rows or a summary by some field?"* |
133
- | Empty result | Inform user, ask to adjust filter or query |
134
-
135
- ---
136
-
137
- ## Next steps
138
-
139
- Once data is retrieved, decide the next action based on context:
140
- - If user wants to **score** the data → move to `sas-score-workflow`
141
- - If user wants to **visualize** → present as table or chart
142
- - If user wants to **export** → format and offer download
143
- - If user wants to **analyze further** → ask clarifying questions