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

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 (47) hide show
  1. package/cli.js +141 -26
  2. package/package.json +4 -3
  3. package/skills/mcp-tool-description-optimizer/SKILL.md +129 -0
  4. package/skills/mcp-tool-description-optimizer/references/examples.md +123 -0
  5. package/skills/sas-read-and-score/SKILL.md +91 -0
  6. package/skills/sas-read-strategy/SKILL.md +143 -0
  7. package/skills/sas-score-workflow/SKILL.md +282 -0
  8. package/src/createMcpServer.js +1 -0
  9. package/src/expressMcpServer.js +68 -28
  10. package/src/handleGetDelete.js +6 -3
  11. package/src/hapiMcpServer.js +30 -0
  12. package/src/openAPIJson.js +175 -175
  13. package/src/toolHelpers/_jobSubmit.js +2 -0
  14. package/src/toolHelpers/_listLibrary.js +56 -39
  15. package/src/toolHelpers/getLogonPayload.js +9 -7
  16. package/src/toolHelpers/getStoreOpts.js +1 -2
  17. package/src/toolHelpers/getToken.js +0 -1
  18. package/src/toolHelpers/refreshToken.js +48 -45
  19. package/src/toolHelpers/refreshTokenOauth.js +2 -2
  20. package/src/toolHelpers/tlogon.js +9 -0
  21. package/src/toolSet/devaScore.js +30 -38
  22. package/src/toolSet/findJob.js +23 -49
  23. package/src/toolSet/findJobdef.js +24 -54
  24. package/src/toolSet/findLibrary.js +25 -57
  25. package/src/toolSet/findModel.js +31 -53
  26. package/src/toolSet/findTable.js +25 -54
  27. package/src/toolSet/getEnv.js +20 -38
  28. package/src/toolSet/listJobdefs.js +24 -58
  29. package/src/toolSet/listJobs.js +24 -72
  30. package/src/toolSet/listLibraries.js +37 -47
  31. package/src/toolSet/listModels.js +20 -47
  32. package/src/toolSet/listTables.js +29 -58
  33. package/src/toolSet/makeTools.js +3 -0
  34. package/src/toolSet/modelInfo.js +18 -49
  35. package/src/toolSet/modelScore.js +27 -69
  36. package/src/toolSet/readTable.js +25 -62
  37. package/src/toolSet/runCasProgram.js +23 -43
  38. package/src/toolSet/runJob.js +20 -19
  39. package/src/toolSet/runJobdef.js +21 -23
  40. package/src/toolSet/runMacro.js +20 -20
  41. package/src/toolSet/runProgram.js +24 -71
  42. package/src/toolSet/sasQuery.js +23 -70
  43. package/src/toolSet/scrInfo.js +3 -4
  44. package/src/toolSet/setContext.js +22 -48
  45. package/src/toolSet/tableInfo.js +28 -71
  46. package/src/toolHelpers/getOpts.js +0 -51
  47. package/src/toolHelpers/getOptsViya.js +0 -44
@@ -9,68 +9,39 @@ 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
- 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"
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)
21
16
 
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)
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
30
21
 
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.
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
33
29
 
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" }
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" }
54
33
  - "does customers exist in mylib" → { lib: "mylib", name: "customers", server: "cas" }
55
34
  - "verify table orders in Samples" → { lib: "Samples", name: "orders", server: "cas" }
56
35
 
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
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)
67
41
 
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
- `;
42
+ ERRORS
43
+ Returns { tables: [] } if not found; { tables: [name, ...] } if found. Never hallucinate table names.
44
+ `;
74
45
 
75
46
  let spec = {
76
47
  name: 'find-table',
@@ -7,53 +7,35 @@ 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
- 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]"
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)
18
14
 
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)
15
+ PARAMETERS
16
+ - name: string (required) — variable name to retrieve (case-sensitive)
24
17
 
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.
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
27
25
 
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)
26
+ EXAMPLES
43
27
  - "What's the value of myVar" → { name: "myVar" }
44
28
  - "Get me the configuration variable" → { name: "configuration" }
45
29
  - "Show the current server setting" → { name: "server" }
46
30
 
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)
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)
51
35
 
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
- `;
36
+ ERRORS
37
+ Returns variable name with current value, or null if not found. Return structured error with message field.
38
+ `;
57
39
 
58
40
  let spec = {
59
41
  name: 'get-env',
@@ -7,71 +7,37 @@ import _listJobdefs from '../toolHelpers/_listJobdefs.js';
7
7
  function listJobdefs(_appContext) {
8
8
 
9
9
  let description = `
10
- ## list-jobdefs — enumerate SAS Viya job definitions assets(jobdefs)
10
+ list-jobdefs — enumerate SAS Viya job definitions (jobdefs) assets.
11
11
 
12
- LLM Invocation Guidance (When to use)
13
- jobdef and jobdefs are used interchangeably here to refer to job definitions.
14
- Use THIS tool when the user wants to browse or list many job definitions assets
15
- - "list jobdefs"
16
- - "show jobdefs"
17
- - "list available jobdefs"
18
- - "browse jobdefs"
19
- - "next jobdefs" (after a previous page)
20
- - "list 25 jobdefs" / "list jobdefs limit 25"
21
- Do NOT use this tool for:
22
- - Checking existence of ONE job (use find-job)
23
- - Executing/running a job (use run-job)
24
- - Running a job definition (use run-jobdef)
25
- - Submitting SAS code (use run-sas-program)
12
+ USE when: list jobdefs, show jobdefs, browse jobdefs, list available jobdefs, next page
13
+ DO NOT USE for: find single jobdef (use find-jobdef), execute jobdef (use run-jobdef), find job (use find-job), sas code (use run-sas-program)
26
14
 
15
+ PARAMETERS
16
+ - limit: number (default: 10) — number of jobdefs per page
17
+ - start: number (default: 1) — 1-based page offset
18
+ - where: string (default: '') — optional filter expression
27
19
 
28
- Purpose
29
- Page through jobdef assets deployed/registered in SAS Viya.
20
+ ROUTING RULES
21
+ - list jobdefs { start: 1, limit: 10 }
22
+ - show me 25 jobdefs → { start: 1, limit: 25 }
23
+ - next jobdefs → { start: previousStart + previousLimit, limit: previousLimit }
30
24
 
31
- Parameters
32
- - limit (number, default 10): Number of jobs to return.
33
- - start (number, default 1): 1-based offset for paging.
34
- - where (string, optional): Filter expression (future use / passthrough; empty string by default). If unsupported, it may be ignored gracefully.
25
+ EXAMPLES
26
+ - list jobdefs { start: 1, limit: 10 }
27
+ - list 25 jobdefs → { start: 1, limit: 25 }
28
+ - next jobdefs { start: 11, limit: 10 }
35
29
 
36
- Response Contract
37
- - Returns an array of jobdef names or objects (backend-dependent) inside structuredContent.
38
- - If items.length === limit, caller may request next page using start + limit.
39
- - Provide optional hint start = start + limit when page might continue.
30
+ NEGATIVE EXAMPLES (do not route here)
31
+ - find jobdef abc (use find-jobdef)
32
+ - list jobs (use list-jobs)
33
+ - run jobdef abc (use run-jobdef)
34
+ - list models (use list-models)
40
35
 
41
- Pagination Examples
42
- - First page: { start:1, limit:10 }
43
- - Next page: { start:11, limit:10 }
36
+ PAGINATION
37
+ If returned length === limit, hint: next start = start + limit. Empty result with start > 1 means paged past end.
44
38
 
45
- Disambiguation & Clarification
46
- - Input only "list" ask: "Specify asset to list? (Say 'Please specify what to listlist' to proceed)" unless prior context indicates job definition listing.
47
- - Input contains "run"/"execute" plus job name → route to job/jobdef.
48
-
49
- Negative Examples (should NOT call list-jobdefs)
50
- - "list libraries" (use list-libraries)
51
- - "list tables" (use list-tables)
52
- - "list models" (use list-models)
53
- - "list jobs" (use list-jobs)
54
- - "find job abc" (findJob)
55
- - "run job abc" (job)
56
- - "job abc" (job)
57
- - "find model xyz" (findModel)
58
- - "list models" (listModels)
59
- - "list tables in lib xyz" (listTables)
60
- - "show me libraries" (listLibraries)
61
- - "describe job abc" (findJob then possibly job for execution)
62
-
63
- Error Handling
64
- - On backend error: surface structured error payload (do not fabricate job names).
65
- - Empty page (items.length === 0) with start > 1 may mean caller paged past end.
66
-
67
- Usage Tips
68
- - Increase limit for fewer round trips; keep reasonable to avoid large payloads.
69
- - Combine with findJobdeffor confirmation before execution.
70
-
71
- Examples (→ mapped params)
72
- - "list jobdefs" → { start:1, limit:10 }
73
- - "list 25 jobdefs" → { start:1, limit:25 }
74
- - "next jobdefs" (after prior {start:1,limit:10}) → { start:11, limit:10 }
39
+ ERRORS
40
+ Surface backend error directly; never fabricate jobdef names.
75
41
  `;
76
42
 
77
43
  let spec = {
@@ -5,87 +5,39 @@
5
5
  import { z } from 'zod';
6
6
  import _listJobs from '../toolHelpers/_listJobs.js';
7
7
  function listJobs(_appContext) {
8
- // LLM guidance object retained for potential future consumption; not exported directly.
9
- let llmDescription = {
10
- purpose: "Map natural language requests to listJobs parameters and return a machine-readable response.",
11
- param_mapping: {
12
- limit: "positive integer. if not specified, set limit to 10",
13
- start: "1-indexed offset. if not specified, set start to 1",
14
- where: "optional filter string, default '' (may be ignored)"
15
- },
16
- response_schema: "{ jobs: string[] , start?: number }",
17
- behavior: "Return only JSON matching response_schema. If ambiguous, ask at most one clarifying question. If no results, return { jobs: [] }. Include start when a full page is returned.",
18
- examples: [
19
- { input: "list jobs", mapped_params: { start: 1, limit: 10 } },
20
- { input: "show me jobs, 20 per page", mapped_params: { start: 1, limit: 20 } },
21
- { input: "next jobs", note: "interpret as start = previousStart + previousLimit" }
22
- ],
23
- safety: "Surface backend errors directly; do not hallucinate job names."
24
- };
25
8
 
26
9
  let description = `
27
- ## list-jobs — enumerate SAS Viya job assets
28
-
29
- LLM Invocation Guidance (When to use)
30
- Use THIS tool when the user wants to browse or list many job definitions / job assets:
31
- - "list jobs"
32
- - "show jobs"
33
- - "list available jobs"
34
- - "browse jobs"
35
- - "next jobs" (after a previous page)
36
- - "list 25 jobs" / "list jobs limit 25"
37
-
38
- Do NOT use this tool for:
39
- - Checking existence of ONE job (use find-job)
40
- - Executing/running a job (use run-job)
41
- - Running a job definition (use run-jobdef)
42
- - Submitting SAS code (use run-sas-program)
43
-
44
-
45
- Purpose
46
- Page through job assets deployed/registered in SAS Viya Job Execution service.
47
-
48
- Parameters
49
- - limit (number, default 10): Number of jobs to return.
50
- - start (number, default 1): 1-based offset for paging.
51
- - where (string, optional): Filter expression (future use / passthrough; empty string by default). If unsupported, it may be ignored gracefully.
10
+ list-jobs — enumerate SAS Viya job assets.
52
11
 
53
- Response Contract
54
- - Returns an array of job names or objects (backend-dependent) inside structuredContent.
55
- - If items.length === limit, caller may request next page using start + limit.
56
- - Provide optional hint start = start + limit when page might continue.
12
+ USE when: list jobs, show jobs, browse jobs, list available jobs, next page
13
+ DO NOT USE for: find single job (use find-job), execute job (use run-job), run job def (use run-jobdef), sas code (use run-sas-program)
57
14
 
58
- Pagination Examples
59
- - First page: { start:1, limit:10 }
60
- - Next page: { start:11, limit:10 }
15
+ PARAMETERS
16
+ - limit: number (default: 10) — number of jobs per page
17
+ - start: number (default: 1) — 1-based page offset
18
+ - where: string (default: '') — optional filter expression
61
19
 
62
- Disambiguation & Clarification
63
- - Input only "list" → ask: "List jobs? (Say 'list jobs' to proceed)" unless prior context indicates jobs listing.
64
- - "find job X"route to findJob instead.
65
- - Input contains "run"/"execute" plus job name route to job/jobdef.
20
+ ROUTING RULES
21
+ - list jobs { start: 1, limit: 10 }
22
+ - show me 25 jobs { start: 1, limit: 25 }
23
+ - next jobs { start: previousStart + previousLimit, limit: previousLimit }
66
24
 
67
- Negative Examples (should NOT call list-jobs)
68
- - "find job abc" (find-job)
69
- - "run job abc" (run-job)
70
- - "job abc" (run-job)
71
- - "find model xyz" (find-model)
72
- - "list models" (list-models)
73
- - "list tables in lib xyz" (list-tables)
74
- - "show me libraries" (list-libraries)
75
- - "describe job abc" (find-job then possibly run-job for execution)
25
+ EXAMPLES
26
+ - list jobs { start: 1, limit: 10 }
27
+ - list 25 jobs → { start: 1, limit: 25 }
28
+ - next jobs → { start: 11, limit: 10 }
76
29
 
77
- Error Handling
78
- - On backend error: surface structured error payload (do not fabricate job names).
79
- - Empty page (items.length === 0) with start > 1 may mean caller paged past end.
30
+ NEGATIVE EXAMPLES (do not route here)
31
+ - find job abc (use find-job)
32
+ - run job abc (use run-job)
33
+ - list models (use list-models)
34
+ - list tables in lib xyz (use list-tables)
80
35
 
81
- Usage Tips
82
- - Increase limit for fewer round trips; keep reasonable to avoid large payloads.
83
- - Combine with findJob for confirmation before execution.
36
+ PAGINATION
37
+ If returned length === limit, hint: next start = start + limit. Empty result with start > 1 means paged past end.
84
38
 
85
- Examples (→ mapped params)
86
- - "list jobs" { start:1, limit:10 }
87
- - "list 25 jobs" → { start:1, limit:25 }
88
- - "next jobs" (after prior {start:1,limit:10}) → { start:11, limit:10 }
39
+ ERRORS
40
+ Surface backend error directly; never fabricate job names.
89
41
  `;
90
42
 
91
43
  let spec = {
@@ -5,60 +5,50 @@
5
5
  import { z } from 'zod';
6
6
  import _listLibrary from '../toolHelpers/_listLibrary.js';
7
7
  function listLibraries(_appContext) {
8
-
9
8
  let description = `
10
- ## list-libraries — enumerate CAS or SAS libraries
11
-
12
- LLM Invocation Guidance (critical)
13
- Use THIS tool when the user asks for: "list libs", "list libraries", "show cas libs", "show sas libs", "what libraries are available", "list caslib(s)", "enumerate libraries", "libraries in cas", "libraries in sas".
14
- DO NOT use this tool when the user asks for: tables inside a specific library (choose listTables), 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
- - "next" (after prior call) → { start: previous.start + previous.limit }
20
- - "first 20 cas libs" → { server: 'cas', limit: 20 }
21
- - If server unspecified: default to CAS.
9
+ list-libraries — enumerate CAS or SAS libraries.
22
10
 
23
- Parameters
24
- - server (cas|sas, default 'cas')
25
- - limit (integer > 0, default 10)
26
- - start (1-based offset, default 1)
27
- - where (optional filter expression, default '')
11
+ USE when user asks to: list/show/enumerate libraries, caslibs, sas libs, or available libraries.
12
+ DO NOT USE for: listing tables in a library (→ list-tables), column/table metadata, job execution, models, scoring.
28
13
 
29
- Response Contract
30
- Return JSON-like structure from helper; consumers may extract an array of library objects/names. If number of returned items === limit supply a pagination hint: start = start + limit.
14
+ PARAMETERS
15
+ - server: 'cas' | 'sas' | 'all' (default: 'all')
16
+ - limit: integer > 0 (default: 10)
17
+ - start: 1-based offset (default: 1)
18
+ - where: optional filter expression (default: '')
31
19
 
32
- Behavior Summary
33
- - Pure listing; no side effects.
34
- - If ambiguous short request like "list" or "libs" and no prior context: assume { server: 'cas' }.
35
- - If user explicitly asks for ALL (e.g. "all cas libs") and count likely large, honor limit=50 unless user supplies a value; include note about paging.
20
+ ROUTING RULES
21
+ - "cas libs / cas libraries / in cas" → { server: 'cas' }
22
+ - "sas libs / sas libraries / in sas" { server: 'sas' }
23
+ - "all libs / all libraries" → { server: 'all' }
24
+ - "list tables in <libname>" → route to list-tables, NOT here
25
+ - server unspecified → default { server: 'all' }
26
+ - "all cas libs" with no limit specified → { server: 'cas', limit: 50 } + paging note
27
+ - "next" after prior call (start:S, limit:L) → { start: S + L, limit: L }
28
+ - ambiguous "list" or "libs" with no context → assume { server: 'cas' }
36
29
 
37
- Disambiguation Rules
38
- - If user mentions a singular library name plus desire for tables ("list tables in SASHELP") choose listTables (not this tool).
39
- - If user mixes "tables" and "libraries" ask for clarification unless clearly about libraries.
30
+ EXAMPLES
31
+ - "list libraries" → { server: 'all', start: 1, limit: 10 }
32
+ - "list libs " { server: 'all', start: 1, limit: 10 }
40
33
 
41
- Examples
42
- - "list libraries" → { server: 'cas', start:1, limit:10 }
43
- - "list libs" → { server: 'cas', start:1, limit:10 }
44
- - "list sas libs" → { server: 'sas' }
45
- - "show me 25 cas libraries" { server:'cas', limit:25 }
46
- - "next" (after prior call {start:1,limit:10}) → { start:11, limit:10 }
47
- - "filter cas libs" (no criterion) → ask: "Provide a filter or continue without one?"
34
+ - "list all libs" → { server: 'all', start: 1, limit: 10 }
35
+ - "list cas libraries" → { server: 'cas', start: 1, limit: 10 }
36
+ - "show me 25 sas libs" → { server: 'sas', limit: 25, start: 1 }
37
+ - "next" (prev: start:1,limit:10) → { server: <same>, start: 11, limit: 10 }
38
+ - "filter cas libs" (no filter given) → ask: "What filter expression should I apply?"
48
39
 
49
- Negative Examples (do not route here)
50
- - "list tables in public" (route to list-tables)
51
- - "list models, list tables, list jobs, list jobdef and similar request"
52
- - "describe library" (likely list-tables or table-info depending on follow-up)
53
- - "run program to make a lib" (run-sas-program tool)
40
+ NEGATIVE EXAMPLES (do not route here)
41
+ - "list tables in SASHELP" list-tables
42
+ - "list models / jobs / jobdefs"→ respective tools
43
+ - "run a program to create a lib" run-sas-program
54
44
 
55
- Error Handling
56
- - On backend error: return structured error with message field; do not hallucinate libraries.
57
- - Empty result set return empty list plus (if start>1) a hint that paging may have exceeded available items.
45
+ PAGINATION
46
+ If returned item count === limit, hint: next start = start + limit.
47
+ If start > 1 and result is empty, note paging may have exceeded available items.
58
48
 
59
- Rationale
60
- Concise, signal-rich description increases probability this spec is selected for generic library enumeration intents.
61
- `;
49
+ ERRORS
50
+ Return structured error with a message field. Never hallucinate library names.
51
+ `;
62
52
 
63
53
 
64
54
  // Canonical kebab-case tool name; legacy aliases preserved for compatibility
@@ -69,7 +59,7 @@ function listLibraries(_appContext) {
69
59
  aliases: ['listLibraries','list libraries','list_libraries'],
70
60
  description: description,
71
61
  schema: {
72
- server: z.string().default('cas'),
62
+ server: z.string().default('all'),
73
63
  limit: z.number().default(10),
74
64
  start: z.number().default(1), // added default to match documentation
75
65
  where: z.string().default('')
@@ -78,7 +68,7 @@ function listLibraries(_appContext) {
78
68
  required: [],
79
69
  handler: async (params) => {
80
70
  // normalize server just in case caller sends 'CAS'/'SAS'
81
- params.server = (params.server || 'cas').toLowerCase();
71
+ params.server = (params.server || 'all').toLowerCase();
82
72
 
83
73
  let r = await _listLibrary(params);
84
74
  return r;
@@ -8,59 +8,32 @@ import _listModels from '../toolHelpers/_listModels.js';
8
8
 
9
9
  function listModels(_appContext) {
10
10
  let description = `
11
- ## list-models — enumerate models published to MAS (Model Publish / Scoring service)
11
+ list-models — enumerate models published to MAS.
12
12
 
13
- LLM Invocation Guidance (When to use)
14
- Use THIS tool when the user wants a collection of models, e.g.:
15
- - "list models"
16
- - "show models"
17
- - "list available models"
18
- - "browse models"
19
- - "list 25 models" / "list models limit 25"
20
- - "next models" (after a previous page)
13
+ USE when: list models, show models, browse models, next page
14
+ DO NOT USE for: find model, model metadata, score model, list jobs/tables/libraries
21
15
 
22
- Do NOT use this tool for:
23
- - Checking a single model's existence (use find-model)
24
- - Getting model metadata / variables (use model-info)
25
- - Scoring a model (use model-score)
26
- - list libraries, tables, jobs, or jobdefs (use respective list/find tools)
27
- - Looking up jobs, libraries, tables, or SCR endpoints (route to respective tools)
16
+ PARAMETERS
17
+ - limit: number (default: 10) page size
18
+ - start: number (default: 1) 1-based offset
28
19
 
29
- Purpose
30
- Provide a paginated view of MAS-registered models so the caller can then drill into one via modelInfo or score it.
20
+ ROUTING RULES
21
+ - "list models" { start:1, limit:10 }
22
+ - "list 25 models" → { start:1, limit:25 }
23
+ - "next models" → { start: start+limit, limit:10 }
31
24
 
32
- Parameters
33
- - limit (number, default 10): Number of models to return for this page.
34
- - start (number, default 1): 1-based offset. For paging: start = start + limit.
25
+ EXAMPLES
26
+ - "list models" { start:1, limit:10 }
27
+ - "list 25 models" → { start:1, limit:25 }
35
28
 
36
- Response Contract
37
- - Returns an array of model entries (names or metadata objects). Empty array if no models.
38
- - If returned length === limit, caller may request the next page.
29
+ NEGATIVE EXAMPLES (do not route here)
30
+ - "find model X" (use find-model)
31
+ - "describe model X" (use model-info)
32
+ - "score model X" (use model-score)
33
+ - "list jobs" (use list-jobs)
39
34
 
40
- Pagination Examples
41
- - First page: { start:1, limit:10 }
42
- - Next page: { start:11, limit:10 }
43
-
44
- Disambiguation & Clarification
45
- - Input only "list" → ask: "List models? (Say 'list models' to proceed)" unless prior context strongly indicates models.
46
- - "find model X" → use find-model instead.
47
- - "score model X" → use model-score.
48
- - "describe model X" → use model-info.
49
-
50
- Negative Examples (should NOT call list-models)
51
- - "find model churn" (find-model)
52
- - "model info customerRisk" (model-info)
53
- - "score model sales_pred" (model-score)
54
- - "list jobs" (list-jobs)
55
-
56
- Usage Tips
57
- - Combine with findModel for narrowing down after a broad list.
58
- - Increase limit judiciously; very large pages can impact latency.
59
-
60
- Examples (→ mapped params)
61
- - "list models" → { start:1, limit:10 }
62
- - "list 25 models" → { start:1, limit:25 }
63
- - "next models" (after prior {start:1,limit:10}) → { start:11, limit:10 }
35
+ ERRORS
36
+ Returns empty array if no models found.
64
37
  `;
65
38
 
66
39
  let spec = {