@sassoftware/sas-score-mcp-serverjs 0.4.0 → 0.4.1

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.
Files changed (39) hide show
  1. package/cli.js +9 -127
  2. package/package.json +2 -3
  3. package/src/createMcpServer.js +0 -1
  4. package/src/expressMcpServer.js +27 -53
  5. package/src/handleGetDelete.js +3 -6
  6. package/src/hapiMcpServer.js +18 -10
  7. package/src/toolHelpers/_jobSubmit.js +0 -2
  8. package/src/toolHelpers/_listLibrary.js +39 -56
  9. package/src/toolHelpers/getLogonPayload.js +1 -3
  10. package/src/toolSet/devaScore.js +36 -28
  11. package/src/toolSet/findJob.js +49 -23
  12. package/src/toolSet/findJobdef.js +54 -24
  13. package/src/toolSet/findLibrary.js +57 -25
  14. package/src/toolSet/findModel.js +53 -31
  15. package/src/toolSet/findTable.js +54 -25
  16. package/src/toolSet/getEnv.js +38 -20
  17. package/src/toolSet/listJobdefs.js +58 -24
  18. package/src/toolSet/listJobs.js +72 -24
  19. package/src/toolSet/listLibraries.js +47 -37
  20. package/src/toolSet/listModels.js +47 -20
  21. package/src/toolSet/listTables.js +58 -29
  22. package/src/toolSet/makeTools.js +0 -3
  23. package/src/toolSet/modelInfo.js +49 -18
  24. package/src/toolSet/modelScore.js +69 -27
  25. package/src/toolSet/readTable.js +62 -25
  26. package/src/toolSet/runCasProgram.js +43 -23
  27. package/src/toolSet/runJob.js +19 -20
  28. package/src/toolSet/runJobdef.js +23 -21
  29. package/src/toolSet/runMacro.js +20 -20
  30. package/src/toolSet/runProgram.js +71 -24
  31. package/src/toolSet/sasQuery.js +70 -23
  32. package/src/toolSet/scrInfo.js +4 -3
  33. package/src/toolSet/setContext.js +48 -22
  34. package/src/toolSet/tableInfo.js +71 -28
  35. package/skills/mcp-tool-description-optimizer/SKILL.md +0 -129
  36. package/skills/mcp-tool-description-optimizer/references/examples.md +0 -123
  37. package/skills/sas-read-and-score/SKILL.md +0 -91
  38. package/skills/sas-read-strategy/SKILL.md +0 -143
  39. package/skills/sas-score-workflow/SKILL.md +0 -282
@@ -7,36 +7,49 @@ import {z} from 'zod';
7
7
  function devaScore(_appContext) {
8
8
 
9
9
  let description = `
10
- deva-score — compute a numeric score based on two input values.
10
+ ## deva-score — compute a numeric score based on two input values
11
11
 
12
- USE when: calculate deva score, score these values, compute score for numbers
13
- DO NOT USE for: model scoring (use model-score), statistical calculations, data lookup
12
+ LLM Invocation Guidance (When to use)
13
+ Use THIS tool when:
14
+ - User wants to calculate the deva score: "Calculate deva score for 5 and 10"
15
+ - User provides two numbers for scoring: "Score these values: 3 and 7"
16
+ - User wants to compute a score in a series: "Calculate scores for [list of numbers]"
14
17
 
15
- PARAMETERS
16
- - a: number (required) — first input value
17
- - b: number (required) second input value
18
+ Do NOT use this tool for:
19
+ - Scoring models (use model-score)
20
+ - Statistical calculations beyond deva scoring
21
+ - Looking up data or metadata
18
22
 
19
- FORMULA: (a + b) * 42
23
+ Purpose
24
+ Compute a numeric deva score by applying the formula (a + b) * 42 to two input numbers. For scoring more than two numbers, call this tool multiple times using the previous result as the first input (left-to-right fold).
20
25
 
21
- ROUTING RULES
22
- - "calculate deva score for 5 and 10" → { a: 5, b: 10 }
23
- - "score 1 and 2" → { a: 1, b: 2 }
24
- - "deva score a=3, b=7" → { a: 3, b: 7 }
25
- - Multiple numbers → chain calls left-to-right: call(first, second), then call(result, third)
26
+ Parameters
27
+ - a (number, required): First numeric input value
28
+ - b (number, required): Second numeric input value
26
29
 
27
- EXAMPLES
30
+ Response Contract
31
+ Returns a numeric result: (a + b) * 42
32
+ The result is always a number representing the computed deva score.
33
+
34
+ Disambiguation & Clarification
35
+ - If user provides more than two numbers without clear instructions: "Do you want to calculate the deva score by combining these numbers left-to-right?"
36
+ - If user provides non-numeric input: "Please provide numeric values"
37
+
38
+ Examples (→ mapped params)
28
39
  - "Calculate deva score for 5 and 10" → { a: 5, b: 10 } returns 630
29
40
  - "Score 1 and 2" → { a: 1, b: 2 } returns 126
30
- - "Deva score 20 and 30"{ a: 20, b: 30 } returns 2100
41
+ - For multiple numbers, chain calls: devaScore(1,2)126, then devaScore(126,3)→5418
42
+
43
+ Negative Examples (should NOT call deva-score)
44
+ - "Score this customer with the credit model" (use model-score instead)
45
+ - "Calculate the mean of these values" (use run-sas-program or sas-query instead)
31
46
 
32
- NEGATIVE EXAMPLES (do not route here)
33
- - "Score this customer with credit model" (use model-score)
34
- - "Calculate the mean of these values" (use run-sas-program or sas-query)
35
- - "Statistical analysis of numbers" (use sas-query)
47
+ Related Tools
48
+ - None directly related (this is a specialized scoring tool)
36
49
 
37
- RESPONSE
38
- Returns { score: (a + b) * 42 }
39
- `;
50
+ Notes
51
+ For sequences of numbers, use a left-to-right fold: call devaScore(first, second), then use that result as the first parameter for devaScore(result, third), and so on.
52
+ `;
40
53
  let spec = {
41
54
  name: 'deva-score',
42
55
  aliases: ['devaScore','deva score','deva_score'],
@@ -47,15 +60,10 @@ Returns { score: (a + b) * 42 }
47
60
  },
48
61
  handler: async ({ a, b }) => {
49
62
  console.error( a, b);
50
- let r = {score: (a + b) * 42};
51
- console.error('deva score result', r);
52
- return {
53
- content: [{type: 'text', text: 'deva score result: ' + JSON.stringify(r)}],
54
- structuredContent: r
55
- };
56
- }
63
+ return `MagicScore ${ (a + b) * 42 }`;
57
64
  }
58
65
 
66
+ }
59
67
  return spec;
60
68
  }
61
69
  export default devaScore;
@@ -16,35 +16,61 @@ function findJob(_appContext) {
16
16
  "behavior": "Return only JSON matching response_schema when invoked by an LLM. If no matches, return { jobs: [] }"
17
17
  };
18
18
  let description = `
19
- find-job — locate a specific SAS Viya job.
19
+ ## find-job — locate a specific SAS Viya job
20
20
 
21
- USE when: find job, does job exist, is there a job named, lookup job, verify job exists
22
- DO NOT USE for: list jobs (use list-jobs), run job (use run-job), execute jobdef (use run-jobdef), find lib/table/model (use respective tools)
21
+ LLM Invocation Guidance
22
+ Use THIS tool when the user intent is to check if ONE job exists or retrieve its metadata:
23
+ - "find job cars_job_v4"
24
+ - "does job sales_summary exist"
25
+ - "is there a job named churnScorer"
26
+ - "lookup job forecast_monthly"
27
+ - "verify job ETL_Daily"
23
28
 
24
- PARAMETERS
25
- - name: string (required) job name to locate; if multiple supplied, use first
29
+ Do NOT use this tool when the user asks for:
30
+ - A list or browse of many jobs (use listJobs)
31
+ - Do not use this tool if the user want to find lib, find table, find model and similar requests
32
+ - Executing a job (use job)
33
+ - Running a job definition (use jobdef)
34
+ - Submitting arbitrary code (use program)
26
35
 
27
- ROUTING RULES
28
- - "find job <name>" { name: "<name>" }
29
- - "does job <name> exist" → { name: "<name>" }
30
- - "is there a job named <name>" → { name: "<name>" }
31
- - "lookup/verify job <name>" → { name: "<name>" }
32
- - "find job" with no name → ask "Which job name would you like to find?"
33
- - "find all jobs / list jobs" → use list-jobs instead
34
- - "run job <name>" → use run-job instead
36
+ Purpose
37
+ Quickly determine whether a named job asset is present in the Viya environment and return its entry (or an empty result if not found).
35
38
 
36
- EXAMPLES
37
- - "find job cars_job_v4" { name: "cars_job_v4" }
38
- - "does job ETL exist" → { name: "ETL" }
39
- - "is there a job named metricsRefresh" → { name: "metricsRefresh" }
39
+ Parameters
40
+ - name (string, required): Exact job name (case preserved). If multiple tokens/names supplied, take the first and ignore the rest; optionally ask for a single name.
40
41
 
41
- NEGATIVE EXAMPLES (do not route here)
42
- - "list jobs" (use list-jobs)
43
- - "run job cars_job_v4" (use run-job)
44
- - "execute jobdef cars_job_v4" (use run-jobdef)
42
+ Behavior & Matching
43
+ - Attempt exact match first (backend determines sensitivity).
44
+ - Returns { jobs: [...] } where array length is 0 (not found) or 1+ (if backend returns multiple with the same display name).
45
+ - No fuzzy guesses—never fabricate a job.
46
+ - If no name provided: ask "Which job name would you like to find?".
45
47
 
46
- ERRORS
47
- Returns { jobs: [] } if not found; { jobs: [name, ...] } if found. Never hallucinate job names.
48
+ Response Contract
49
+ - Always: { jobs: Array<string|object> }
50
+ - On error: propagate structured server error (do not wrap in prose when invoked programmatically).
51
+
52
+ Disambiguation Rules
53
+ - Input only "find job" → ask for missing name.
54
+ - Input contains verbs like "run" or "execute" → use run-job or run-jobdef instead.
55
+ - Input requesting many (e.g., "find all jobs") → use list-jobs.
56
+
57
+ Examples (→ mapped params)
58
+ - "find job cars_job_v4" → { name: "cars_job_v4" }
59
+ - "does job ETL exist" → { name: "ETL" }
60
+ - "is there a job named metricsRefresh" → { name: "metricsRefresh" }
61
+
62
+ Negative Examples (should NOT call find-job)
63
+ - "list jobs" (list-jobs)
64
+ - "run job cars_job_v4" (run-job)
65
+ - "execute jobdef cars_job_v4" (run-jobdef)
66
+
67
+ Clarifying Question Template
68
+ - Missing name: "Which job name would you like to find?"
69
+ - Multiple names: "Please provide just one job name (e.g. 'cars_job_v4')."
70
+
71
+ Notes
72
+ - For bulk existence checks loop over names and call find-job per name.
73
+ - Combine with run-job tool if user wants to execute after confirming existence.
48
74
  `;
49
75
 
50
76
  let spec = {
@@ -15,36 +15,66 @@ function findJobdef(_appContext) {
15
15
  "behavior": "Return only JSON matching response_schema when invoked by an LLM. If no matches, return { jobs: [] }"
16
16
  };
17
17
  let description = `
18
- find-jobdef — locate a specific SAS Viya job definition.
18
+ ## find-jobdef — locate a specific SAS Viya job
19
19
 
20
- USE when: find jobdef, does jobdef exist, is there a jobdef named, lookup jobdef, verify jobdef exists
21
- DO NOT USE for: list jobdefs (use list-jobdefs), run jobdef (use run-jobdef), find job/lib/table/model (use respective tools)
20
+ LLM Invocation Guidance
21
+ Use THIS tool when the user intent is to check if ONE job exists or retrieve its metadata:
22
+ - "find jobdef cars_job_v4"
23
+ - "does jobdef sales_summary exist"
24
+ - "is there a jobdef named churnScorer"
25
+ - "lookup jobdef forecast_monthly"
26
+ - "verify jobdef ETL_Daily"
22
27
 
23
- PARAMETERS
24
- - name: string (required) — jobdef name to locate; if multiple supplied, use first
28
+ Do NOT use this tool when the user asks for:
29
+ - find job (use find-job)
30
+ - find table (use find-table
31
+ - find model (use find-model)
32
+ - find lib (use find-library)
33
+ - Executing a job (use job)
34
+ - Running a job definition (use jobdef)
35
+ - Submitting arbitrary code (use program)
25
36
 
26
- ROUTING RULES
27
- - "find jobdef <name>" { name: "<name>" }
28
- - "does jobdef <name> exist" → { name: "<name>" }
29
- - "is there a jobdef named <name>" → { name: "<name>" }
30
- - "lookup/verify jobdef <name>" → { name: "<name>" }
31
- - "find jobdef" with no name → ask "Which jobdef name would you like to find?"
32
- - "find all jobdefs / list jobdefs" → use list-jobdefs instead
33
- - "run jobdef <name>" → use run-jobdef instead
37
+ Purpose
38
+ Quickly determine whether a named jobdef asset is present in the Viya environment and return its entry (or an empty result if not found).
34
39
 
35
- EXAMPLES
36
- - "find jobdef cars_job_v4" { name: "cars_job_v4" }
37
- - "does jobdef ETL exist" → { name: "ETL" }
38
- - "is there a jobdef named metricsRefresh" → { name: "metricsRefresh" }
40
+ Parameters
41
+ - name (string, required): Exact jobdef name (case preserved). If multiple tokens/names supplied, take the first and ignore the rest; optionally ask for a single name.
39
42
 
40
- NEGATIVE EXAMPLES (do not route here)
41
- - "list jobdefs" (use list-jobdefs)
42
- - "run jobdef cars_job_v4" (use run-jobdef)
43
- - "find job ETL" (use find-job)
44
- - "find table cars" (use find-table)
43
+ Behavior & Matching
44
+ - Attempt exact match first (backend determines sensitivity).
45
+ - Returns { jobdefs: [...] } where array length is 0 (not found) or 1+ (if backend returns multiple with the same display name).
46
+ - No fuzzy guesses—never fabricate a job.
47
+ - If no name provided: ask "Which jobdef name would you like to find?".
45
48
 
46
- ERRORS
47
- Returns { jobdefs: [] } if not found; { jobdefs: [name, ...] } if found. Never hallucinate jobdef names.
49
+ Response Contract
50
+ - Always: { jobdefs: Array<string|object> }
51
+ - On error: propagate structured server error (do not wrap in prose when invoked programmatically).
52
+
53
+ Disambiguation Rules
54
+ - Input only "find job" → ask for missing name.
55
+ - Input contains verbs like "run" or "execute" → use run-job or run-jobdef instead.
56
+ - Input requesting many (e.g., "find all jobs") → use list-jobs.
57
+
58
+ Examples (→ mapped params)
59
+ - "find jobdef cars_job_v4" → { name: "cars_job_v4" }
60
+ - "does jobdef ETL exist" → { name: "ETL" }
61
+ - "is there a jobdef named metricsRefresh" → { name: "metricsRefresh" }
62
+
63
+ Negative Examples (should NOT call find-jobdef)
64
+ - find lib (use find-library)
65
+ - find table (use find-table)
66
+ - find model (use find-model)
67
+ - "list job" (list-jobdefs)
68
+ - "run job cars_job_v4" (run-job)
69
+ - "execute jobdef cars_job_v4" (run-jobdef)
70
+
71
+ Clarifying Question Template
72
+ - Missing name: "Which jobdef name would you like to find?"
73
+ - Multiple names: "Please provide just one jobdef name (e.g. 'cars_job_v4')."
74
+
75
+ Notes
76
+ - For bulk existence checks loop over names and call find-jobdef per name.
77
+ - Combine with run-jobdef tool if user wants to execute after confirming existence.
48
78
  `;
49
79
 
50
80
  let spec = {
@@ -7,37 +7,69 @@ import _listLibrary from '../toolHelpers/_listLibrary.js';
7
7
  function findLibrary(_appContext) {
8
8
 
9
9
  let description = `
10
- find-library — locate a specific CAS or SAS library.
10
+ ## find-library — locate a specific CAS or SAS library
11
11
 
12
- USE when: find library, find lib, does library exist, is library available, lookup library
13
- DO NOT USE for: list libraries (use list-libraries), find table/job/jobdef/model (use respective tools), table structure (use table-info), create library (use run-sas-program)
12
+ LLM Invocation Guidance
13
+ Use THIS tool when the user asks any of the following (intent = existence / lookup of ONE library):
14
+ - "find library Public"
15
+ - "find lib Public"
16
+ - "does library SASHELP exist"
17
+ - "is PUBLIC library available in cas"
18
+ - "lookup library sasuser in sas"
19
+ - "show me library metadata for Models"
14
20
 
15
- PARAMETERS
16
- - name: string (required) — library/caslib name; if multiple supplied, use first
17
- - server: 'cas' | 'sas' (default: 'cas') target environment
21
+ Aliases for lib are: library, caslib, libref
22
+
23
+ Do NOT use this tool when the user wants:
24
+ - find model -> use find-model
25
+ - find table -> use find-table
26
+ - find job -> use find-job
27
+ - find jobdef -> use find-jobdef
28
+ - Columns or schema of a table (use table-info)
29
+ - Creating/assigning libraries (use run-sas-program or another admin tool)
30
+
31
+ Purpose
32
+ Quickly verify whether a single named library exists on CAS or SAS and return its entry (or empty if not found).
33
+
34
+ Parameters
35
+ - name (string, required) : Exact library (caslib) name to locate. If multiple names provided (comma/space separated), use the first and ignore the rest; optionally ask for one name.
36
+ - server (cas|sas, default 'cas') : Target environment. If omitted or ambiguous default to 'cas'.
37
+
38
+ Behavior & Matching
39
+ - Performs an exact name match (case-insensitive where backend supports it).
40
+ - Returns an object: { libraries: [...] } where the array contains zero or one items (backend may still return richer metadata).
41
+ - If no match: { libraries: [] } (do NOT fabricate suggestions).
42
+ - If user supplies no name: ask a clarifying question: "Which library name would you like to find?".
43
+ - If user clearly wants a list ("list", "show all", "enumerate") route to listLibrary instead.
44
+
45
+ Response Contract
46
+ - Always: { libraries: Array<string|object> }
47
+ - Never include prose when invoked programmatically; only the JSON structure.
48
+
49
+ Disambiguation Rules
50
+ - Input only "find library" → ask for the missing name.
51
+ - Input with both library name and words like "tables" → prefer listTables.
52
+ - Input like "find libraries" (plural) → prefer listLibrary unless user clarifies to a single name.
18
53
 
19
- ROUTING RULES
20
- - "find lib <name>" → { name: "<name>", server: "cas" }
21
- - "find lib <name> in cas" → { name: "<name>", server: "cas" }
22
- - "find library <name> in sas" → { name: "<name>", server: "sas" }
23
- - "does library <name> exist" → { name: "<name>", server: "cas" }
24
- - "find lib" with no name → ask "Which library name would you like to find?"
25
- - "list libraries / list libs" → use list-libraries instead
26
- - "tables in <lib>" → use list-tables instead
54
+ Examples (→ mapped params)
55
+ - "find lib Public" → { name: "Public", server: "cas" }
56
+ - "find library sasuser in sas" → { name: "sasuser", server: "sas" }
57
+ - "does library Formats exist" → { name: "Formats", server: "cas" }
58
+ - "is SystemData library in cas" → { name: "SystemData", server: "cas" }
27
59
 
28
- EXAMPLES
29
- - "find lib Public" → { name: "Public", server: "cas" }
30
- - "find library sasuser in sas" { name: "sasuser", server: "sas" }
31
- - "does library Formats exist" → { name: "Formats", server: "cas" }
60
+ Negative Examples (should NOT call find-library)
61
+ - "list libs" (list-libraries)
62
+ - Do not use this tool if the user want to find table, find job, find model, find job, find jobdef and similar requests
63
+ - "show tables in Public" (list-tables)
64
+ - "describe table cars in sashelp" (table-info)
32
65
 
33
- NEGATIVE EXAMPLES (do not route here)
34
- - "list libs" (use list-libraries)
35
- - "show tables in Public" (use list-tables)
36
- - "find table cars in sashelp" (use find-table)
37
- - "find job cars_job" (use find-job)
66
+ Clarifying Question Template
67
+ - Missing name: "Which library name would you like to find?"
68
+ - Multiple names: "Please provide just one library name to look up (e.g. 'Public')."
38
69
 
39
- ERRORS
40
- Returns { libraries: [] } if not found; { libraries: [name, ...] } if found. Never hallucinate library names.
70
+ Notes
71
+ - For bulk validation of many names, call this tool repeatedly per name.
72
+ - For pagination or discovery, switch to list-libraries.
41
73
  `;
42
74
 
43
75
  let spec = {
@@ -9,37 +9,59 @@ import _listModels from '../toolHelpers/_listModels.js';
9
9
 
10
10
  function findModel(_appContext) {
11
11
  let description = `
12
- find-model — locate a specific model deployed to MAS (Model Aggregation Service).
13
-
14
- USE when: find model, does model exist, is model deployed, lookup model, verify model exists
15
- DO NOT USE for: list models (use list-models), model info/variables (use model-info), score model (use model-score), find table/job/lib (use respective tools), scr models (use scr-info/scr-score)
16
-
17
- PARAMETERS
18
- - name: string (required) — model name to locate; if multiple supplied, use first
19
-
20
- ROUTING RULES
21
- - "find model <name>" → { name: "<name>" }
22
- - "does model <name> exist" → { name: "<name>" }
23
- - "is model <name> deployed" { name: "<name>" }
24
- - "lookup/verify model <name>" { name: "<name>" }
25
- - "find model" with no name ask "Which model name would you like to find?"
26
- - "find all models / list models" use list-models instead
27
- - "score model <name>" use model-score instead
28
- - "describe model / model info" → use model-info instead
29
-
30
- EXAMPLES
31
- - "find model myModel" → { name: "myModel" }
32
- - "does model churn_score exist" { name: "churn_score" }
33
- - "is model riskModel deployed" → { name: "riskModel" }
34
- - "lookup model claims_fraud_v1" → { name: "claims_fraud_v1" }
35
-
36
- NEGATIVE EXAMPLES (do not route here)
37
- - "list models" (use list-models)
38
- - "score model myModel" (use model-score)
39
- - "model info for churnRisk" (use model-info)
40
-
41
- ERRORS
42
- Returns { models: [] } if not found; { models: [name, ...] } if found. Never hallucinate model names.
12
+ ## find-model — locate a specific model deployed to MAS (Model Publish / Scoring service)
13
+
14
+ LLM Invocation Guidance (When to use)
15
+ Use THIS tool when the user wants to know whether ONE model exists or is deployed:
16
+ - "find model cancerRisk"
17
+ - "does model churn_tree exist"
18
+ - "is model sales_forecast deployed"
19
+ - "lookup model claimFraud"
20
+ - "verify model credit_score_v2 exists"
21
+
22
+ Do NOT use this tool for:
23
+ - Listing many / browsing models (use list-models)
24
+ - Retrieving detailed input/output variable metadata (use model-info)
25
+ - Scoring or running a model (use model-score)
26
+ - Searching model execution containers or SCR endpoints (use scr-info / scr-score if appropriate)
27
+ - Finding a table (use find-table)
28
+ - Finding a library (use find-library)
29
+ - Finding a job or jobdef (use find-job / find-jobdef)
30
+
31
+ Purpose
32
+ Quick existence / lookup check for a MAS‑published model. Returns a list with zero or more matches (typically 0 or 1 for an exact name).
33
+
34
+ Parameters
35
+ - name (string, required): Exact model name. If user supplies phrases like "model named X" extract X. If multiple names are given (comma or space separated), prefer the first and (optionally) ask for a single name.
36
+
37
+ Matching Rules
38
+ - Attempt exact match first. If backend supports partial search, a substring match MAY return multiple models; preserve order.
39
+ - Do not fabricate models. Empty array means not found.
40
+
41
+ Response Contract
42
+ - Always: { models: Array<object|string> }
43
+ - Never return prose when invoked programmatically; only the JSON structure.
44
+ - On error: surface backend error object directly (no rewriting) so the caller can display/log it.
45
+
46
+ Disambiguation & Clarification
47
+ - Missing name (e.g., "find model") → ask: "Which model name would you like to find?"
48
+ - Plural intent (e.g., "find models" / "list models") → use list-models instead.
49
+ - If user requests scoring ("score model X") → route to model-score not find-model.
50
+
51
+ Examples (→ mapped params)
52
+ - "find model myModel" → { name: "myModel" }
53
+ - "does model churn_score exist" → { name: "churn_score" }
54
+ - "is model riskModel deployed" → { name: "riskModel" }
55
+ - "lookup model claims_fraud_v1" → { name: "claims_fraud_v1" }
56
+
57
+ Negative Examples (should NOT call find-model)
58
+ - "list models" (list-models)
59
+ - "score model myModel" (model-score)
60
+ - "describe model myModel" (model-info)
61
+
62
+ Notes
63
+ - Chain usage: find-model → model-info → model-score.
64
+ - For batch existence checks iterate over a list and call find-model per entry.
43
65
  `;
44
66
 
45
67
  let spec = {
@@ -9,39 +9,68 @@ import _listTables from '../toolHelpers/_listTables.js';
9
9
 
10
10
  function findTable(_appContext) {
11
11
  let description = `
12
- find-table — locate a specific table in a CAS or SAS library.
12
+ ## find-table — locate a specific table in a CAS or SAS library
13
13
 
14
- USE when: find table, does table exist, is table in library, verify table exists, locate table
15
- DO NOT USE for: list tables (use list-tables), table schema/columns (use table-info), read table data (use read-table), find lib/job/model (use respective tools)
14
+ LLM Invocation Guidance (When to use)
15
+ Use THIS tool when the user wants to find or verify a table in a specific library:
16
+ - "find table iris in Public library in cas"
17
+ - "find table cars in sashelp in sas server"
18
+ - "does table customers exist in mylib?"
19
+ - "is there a table named sales in the Samples library?"
20
+ - "verify table orders exists in Public"
16
21
 
17
- PARAMETERS
18
- - lib: string (required) library name (e.g., 'Public', 'sashelp')
19
- - name: string (required) table name to locate
20
- - server: 'cas' | 'sas' (default: 'cas') — target environment
22
+ Do NOT use this tool when the user wants:
23
+ - find lib -> use find-library
24
+ - find model -> use find-model
25
+ - find job -> use find-job
26
+ - find jobdef -> use find-jobdef
27
+ - Columns or schema of a table (use table-info)
28
+ - Reading data from a table (use read-table)
29
+ - Listing all tables in a library (use list-tables)
21
30
 
22
- ROUTING RULES
23
- - "find table <name> in <lib>" { lib: "<lib>", name: "<name>", server: "cas" }
24
- - "find table <name> in <lib> in sas" → { lib: "<lib>", name: "<name>", server: "sas" }
25
- - "does table <name> exist in <lib>" → { lib: "<lib>", name: "<name>", server: "cas" }
26
- - "find table" with missing lib → ask "Which library contains the table?"
27
- - "find table" with missing name → ask "Which table name would you like to find?"
28
- - "list tables in <lib>" → use list-tables instead
31
+ Purpose
32
+ Locate a table contained in a specified library (caslib or libref) on a CAS or SAS server. Returns matching table names or empty array if not found.
29
33
 
30
- EXAMPLES
31
- - "find table iris in Public" { lib: "Public", name: "iris", server: "cas" }
32
- - "find table cars in sashelp in sas" { lib: "sashelp", name: "cars", server: "sas" }
34
+ Parameters
35
+ - lib (string, required): The library to search in (e.g., 'Public', 'sashelp', or a caslib name)
36
+ - name (string, required): Table name or substring to search for. Matching is case-insensitive.
37
+ - server (string, default 'cas'): Either 'cas' or 'sas'. Defaults to 'cas' when omitted.
38
+
39
+ Response Contract
40
+ Returns a JSON object with:
41
+ - tables: Array of matching table names (strings)
42
+ - Empty array { tables: [] } when no matches found
43
+ - Do not fabricate table names; only return actual matches
44
+
45
+ Disambiguation & Clarification
46
+ - Missing library: ask "Which library do you want to search in?"
47
+ - Missing table name: ask "Which table name would you like to find?"
48
+ - Server ambiguous: ask "Do you mean CAS or SAS?"
49
+ - If user wants multiple tables: suggest "Use list-tables to see all tables in a library"
50
+
51
+ Examples (→ mapped params)
52
+ - "find table iris in Public library in cas" → { lib: "Public", name: "iris", server: "cas" }
53
+ - "find table cars in sashelp in sas server" → { lib: "sashelp", name: "cars", server: "sas" }
33
54
  - "does customers exist in mylib" → { lib: "mylib", name: "customers", server: "cas" }
34
55
  - "verify table orders in Samples" → { lib: "Samples", name: "orders", server: "cas" }
35
56
 
36
- NEGATIVE EXAMPLES (do not route here)
37
- - "list tables in Public" (use list-tables)
38
- - "find library Public" (use find-library)
39
- - "what columns in cars?" (use table-info)
40
- - "read data from customers" (use read-table)
57
+ Negative Examples (should NOT call find-table)
58
+ - "list tables in Public" (use list-tables instead)
59
+ - "find library Public" (use find-library instead)
60
+ - "what columns in cars table?" (use table-info instead)
61
+ - "read data from customers" (use read-table instead)
62
+
63
+ Usage Tips
64
+ - Use this tool to verify table existence before reading or querying
65
+ - For discovery of multiple tables, use list-tables instead
66
+ - After finding a table, use table-info for schema or read-table for data
41
67
 
42
- ERRORS
43
- Returns { tables: [] } if not found; { tables: [name, ...] } if found. Never hallucinate table names.
44
- `;
68
+ Related Tools
69
+ - find-table table-info read-table (typical workflow)
70
+ - list-tables — to discover all tables in a library
71
+ - find-library — to verify library exists
72
+ - table-info — to inspect table structure after finding it
73
+ `;
45
74
 
46
75
  let spec = {
47
76
  name: 'find-table',
@@ -7,35 +7,53 @@ import {z} from 'zod';
7
7
  import _getEnv from '../toolHelpers/_getEnv.js';
8
8
  function getEnv(_appContext) {
9
9
  let description = `
10
- get-env — retrieve a variable value from the runtime environment.
10
+ ## get-env — retrieve a variable value from the runtime environment
11
11
 
12
- USE when: what is the value of, get me, show current, what's the, retrieve environment variable
13
- DO NOT USE for: read table data (use read-table), model info (use model-info), find/run job (use find-job/run-job), set context (use set-context)
12
+ LLM Invocation Guidance (When to use)
13
+ Use THIS tool when:
14
+ - The user wants to access a specific environment variable or context value
15
+ - "What is the value of [variable name]?"
16
+ - "Get me the [variable] value"
17
+ - "Show the current [variable]"
14
18
 
15
- PARAMETERS
16
- - name: string (required) — variable name to retrieve (case-sensitive)
19
+ Do NOT use this tool for:
20
+ - Retrieving table data (use read-table)
21
+ - Getting model information (use model-info)
22
+ - Looking up job status (use find-job or run-job)
23
+ - Setting environment variables (use set-context to set CAS/SAS contexts)
17
24
 
18
- ROUTING RULES
19
- - "what is the value of <var>" { name: "<var>" }
20
- - "get me <var>" → { name: "<var>" }
21
- - "show <var>" → { name: "<var>" }
22
- - "get" with no variable → ask "Which variable would you like to retrieve?"
23
- - "what context am I using" → use set-context instead (no params)
24
- - "set <var> to <value>" → use set-context or run-sas-program instead
25
+ Purpose
26
+ Retrieve the current value of a named variable from the runtime environment. This is useful for debugging, accessing context information, or verifying current configuration values.
25
27
 
26
- EXAMPLES
28
+ Parameters
29
+ - name (string, required): The name of the variable to retrieve. Variable names are case-sensitive.
30
+
31
+ Response Contract
32
+ Returns a JSON object containing:
33
+ - The requested variable name as a key
34
+ - The current value of that variable
35
+ - If the variable does not exist, returns null or an error message
36
+
37
+ Disambiguation & Clarification
38
+ - If variable name is missing: ask "Which variable would you like to retrieve?"
39
+ - If user says "context" without specifying which variable: clarify "Do you mean the CAS context, SAS context, or a specific variable?"
40
+ - Multiple variable request: handle one at a time or ask for clarification
41
+
42
+ Examples (→ mapped params)
27
43
  - "What's the value of myVar" → { name: "myVar" }
28
44
  - "Get me the configuration variable" → { name: "configuration" }
29
45
  - "Show the current server setting" → { name: "server" }
30
46
 
31
- NEGATIVE EXAMPLES (do not route here)
32
- - "Read rows from customers" (use read-table)
33
- - "Get model details for myModel" (use model-info)
34
- - "Set the CAS server to finance-prod" (use set-context)
47
+ Negative Examples (should NOT call get-env)
48
+ - "Read all rows from the customers table" (use read-table instead)
49
+ - "Get model details for myModel" (use model-info instead)
50
+ - "Set the CAS server to finance-prod" (use set-context instead)
35
51
 
36
- ERRORS
37
- Returns variable name with current value, or null if not found. Return structured error with message field.
38
- `;
52
+ Related Tools
53
+ - setContext to set environment context values (CAS and SAS servers)
54
+ - readTable — to retrieve table data
55
+ - modelInfo — to retrieve model metadata
56
+ `;
39
57
 
40
58
  let spec = {
41
59
  name: 'get-env',