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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/.skills/.claude-plugin/plugin.json +59 -0
  2. package/.skills/agents/sas-score-mcp-serverjs-agent.md +26 -0
  3. package/.skills/copilot-instructions.md +62 -0
  4. package/.skills/skills/README.md +204 -0
  5. package/.skills/skills/detail-strategy/SKILL.md +316 -0
  6. package/.skills/skills/find-library-server/SKILL.md +62 -0
  7. package/.skills/skills/find-resources/SKILL.md +66 -0
  8. package/.skills/skills/list-library/SKILL.md +30 -0
  9. package/.skills/skills/list-mas-job-jobdef/SKILL.md +31 -0
  10. package/.skills/skills/list-tables/SKILL.md +30 -0
  11. package/.skills/skills/read-strategy/SKILL.md +87 -0
  12. package/.skills/skills/request-routing/SKILL.md +112 -0
  13. package/.skills/skills/score-cas/SKILL.md +95 -0
  14. package/.skills/skills/score-job-jobdef/SKILL.md +58 -0
  15. package/.skills/skills/score-mas-scr/SKILL.md +58 -0
  16. package/.skills/skills/score-program/SKILL.md +59 -0
  17. package/.skills/skills/score-strategy/SKILL.md +39 -0
  18. package/README.md +96 -54
  19. package/cli.js +11 -13
  20. package/openApi.yaml +121 -121
  21. package/package.json +16 -14
  22. package/scripts/docs/SCORE_SKILL_REFERENCE.md +17 -16
  23. package/scripts/docs/TOOL_DESCRIPTION_TEMPLATE.md +3 -3
  24. package/scripts/docs/TOOL_UPDATES_SUMMARY.md +65 -63
  25. package/scripts/docs/oauth-http-transport.md +2 -2
  26. package/scripts/docs/sas-mcp-tools-reference.md +43 -32
  27. package/scripts/plot_msrp_usa.py +49 -0
  28. package/scripts/refreshtoken.js +58 -0
  29. package/scripts/runListScr.mjs +16 -0
  30. package/src/createMcpServer.js +4 -1
  31. package/src/expressMcpServer.js +47 -49
  32. package/src/oauthHandlers/authorize.js +4 -1
  33. package/src/oauthHandlers/baseUrl.js +4 -0
  34. package/src/oauthHandlers/callback.js +4 -0
  35. package/src/oauthHandlers/getMetadata.js +4 -0
  36. package/src/oauthHandlers/index.js +4 -0
  37. package/src/oauthHandlers/token.js +4 -0
  38. package/src/openApi.yaml +121 -121
  39. package/src/processHeaders.js +10 -7
  40. package/src/setupSkills.js +1 -18
  41. package/src/toolHelpers/_casScore.js +32 -0
  42. package/src/toolHelpers/_desc.js +14 -0
  43. package/src/toolHelpers/_findJob.js +12 -0
  44. package/src/toolHelpers/_findJobdef.js +10 -0
  45. package/src/toolHelpers/_findLibrary.js +11 -0
  46. package/src/toolHelpers/_findMas.js +13 -0
  47. package/src/toolHelpers/_findScr.js +36 -0
  48. package/src/toolHelpers/_findTable.js +11 -0
  49. package/src/toolHelpers/_listJobdefs.js +12 -2
  50. package/src/toolHelpers/_listJobs.js +19 -8
  51. package/src/toolHelpers/{_listModels.js → _listMas.js} +4 -4
  52. package/src/toolHelpers/_listScr.js +13 -0
  53. package/src/toolHelpers/{_scrInfo.js → _scrDescribe.js} +4 -4
  54. package/src/toolHelpers/_scrScore.js +2 -2
  55. package/src/toolHelpers/_submitCasl.js +19 -17
  56. package/src/toolHelpers/{_tableInfo.js → _tableDescribe.js} +2 -2
  57. package/src/toolHelpers/getLogonPayload.js +2 -2
  58. package/src/toolSet/casModelScore.js +93 -0
  59. package/src/toolSet/casProgramScore.js +105 -0
  60. package/src/toolSet/devaScore.js +66 -61
  61. package/src/toolSet/findJob.js +24 -9
  62. package/src/toolSet/findJobdef.js +22 -19
  63. package/src/toolSet/findLibrary.js +73 -68
  64. package/src/toolSet/findMas.js +72 -0
  65. package/src/toolSet/findScr.js +69 -0
  66. package/src/toolSet/findTable.js +34 -27
  67. package/src/toolSet/getEnv.js +6 -6
  68. package/src/toolSet/jobDescribe.js +65 -0
  69. package/src/toolSet/jobScore.js +90 -0
  70. package/src/toolSet/jobdefDescribe.js +67 -0
  71. package/src/toolSet/jobdefScore.js +85 -0
  72. package/src/toolSet/listJobdefs.js +70 -61
  73. package/src/toolSet/listJobs.js +68 -61
  74. package/src/toolSet/listLibraries.js +84 -78
  75. package/src/toolSet/listMas.js +71 -0
  76. package/src/toolSet/listScr.js +62 -0
  77. package/src/toolSet/listTables.js +78 -66
  78. package/src/toolSet/{runMacro.js → macroScore.js} +86 -82
  79. package/src/toolSet/makeTools.js +39 -25
  80. package/src/toolSet/masDescribe.js +67 -0
  81. package/src/toolSet/masScore.js +95 -0
  82. package/src/toolSet/{runProgram.js → programScore.js} +21 -18
  83. package/src/toolSet/readTable.js +80 -63
  84. package/src/toolSet/sasQuery.js +83 -77
  85. package/src/toolSet/scrDescribe.js +55 -0
  86. package/src/toolSet/scrScore.js +63 -70
  87. package/src/toolSet/searchAssets.js +1 -1
  88. package/src/toolSet/setContext.js +70 -65
  89. package/src/toolSet/superstat.js +61 -61
  90. package/src/toolSet/tableDescribe.js +65 -0
  91. package/.agents/sas-score-mcp-serverjs-agent.md +0 -58
  92. package/.instructions/copilot-instructions.md +0 -201
  93. package/.instructions/enforce-find-resource-strategy.md +0 -35
  94. package/.skills/sas-find-library-smart/SKILL.md +0 -155
  95. package/.skills/sas-find-resource-strategy/SKILL.md +0 -105
  96. package/.skills/sas-list-resource-strategy/SKILL.md +0 -124
  97. package/.skills/sas-list-tables-smart/SKILL.md +0 -128
  98. package/.skills/sas-read-and-score-strategy/SKILL.md +0 -113
  99. package/.skills/sas-read-strategy/SKILL.md +0 -154
  100. package/.skills/sas-request-classifier/SKILL.md +0 -74
  101. package/.skills/sas-score-workflow-strategy/SKILL.md +0 -314
  102. package/scripts/optimize_final.py +0 -140
  103. package/scripts/optimize_tools.py +0 -99
  104. package/scripts/setup-skills.js +0 -34
  105. package/scripts/update_descriptions.py +0 -46
  106. package/src/authpkce.js +0 -219
  107. package/src/handleGetDelete.js +0 -34
  108. package/src/handleRequest.js +0 -112
  109. package/src/hapiMcpServer.js +0 -241
  110. package/src/toolSet/findModel.js +0 -60
  111. package/src/toolSet/listModels.js +0 -56
  112. package/src/toolSet/modelInfo.js +0 -55
  113. package/src/toolSet/modelScore.js +0 -89
  114. package/src/toolSet/runCasProgram.js +0 -98
  115. package/src/toolSet/runJob.js +0 -81
  116. package/src/toolSet/runJobdef.js +0 -82
  117. package/src/toolSet/scrInfo.js +0 -52
  118. package/src/toolSet/tableInfo.js +0 -58
@@ -1,63 +1,80 @@
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 _readTable from '../toolHelpers/_readTable.js';
9
- function readTable(_appContext) {
10
-
11
- let describe = `
12
- read-table retrieve rows from a table in a CAS or SAS library.
13
-
14
- USE when: read table, show rows, read from library, filtered data with WHERE
15
- DO NOT USE for: list tables, table structure (use table-info), SQL queries (use sas-query), SAS programs
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
- - start: number (default: 1) — 1-based row index
22
- - limit: number (default: 10) — max rows (1-1000)
23
- - where: string SQL WHERE clause filter
24
- - format: boolean (default: true) — formatted or raw values
25
-
26
- ROUTING RULES
27
- - "read table cars in Samples" → { table: "cars", lib: "Samples", start: 1, limit: 10 }
28
- - "show 25 rows from customers" → { table: "customers", lib: "<lib>", limit: 25, start: 1 }
29
- - "read from mylib.orders where status='shipped'" → { table: "orders", lib: "mylib", where: "status='shipped'", start: 1, limit: 10 }
30
-
31
- EXAMPLES
32
- - "read table cars in Samples" { table: "cars", lib: "Samples", start: 1, limit: 10 }
33
- - "show 25 rows from customers" { table: "customers", lib: "mylib", limit: 25, start: 1 }
34
-
35
- NEGATIVE EXAMPLES (do not route here)
36
- - "list tables in Samples" (use list-tables)
37
- - "what columns are in cars" (use table-info)
38
- - "execute SQL query" (use sas-query)
39
- - "run SAS code" (use run-sas-program)
40
-
41
- ERRORS
42
- Returns rows array, total count, filtered_count, columns metadata. Empty array if no matches.
43
- `;
44
-
45
- let specs = {
46
- name: 'read-table',
47
- description: describe,
48
- inputSchema: z.object({
49
- table: z.string(),
50
- lib: z.string().optional(),
51
- start: z.number().optional(),
52
- limit: z.number().optional(),
53
- server: z.string().optional(),
54
- where: z.string().optional()
55
- }),
56
- handler: async (params) => {
57
- let r = await _readTable(params,'query');
58
- return r;
59
- }
60
- }
61
- return specs;
62
- }
63
- export default readTable;
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 _readTable from '../toolHelpers/_readTable.js';
9
+ function readTable(_appContext) {
10
+ const isAgent = _appContext && _appContext.agent;
11
+
12
+ let describe = isAgent ? `
13
+ read-table — read rows from a CAS or SAS table.
14
+ PARAMS: lib (string, required), table (string, required), server ('cas'|'sas', required), where (string, optional filter), start (number, default 1), limit (number, default 10)
15
+ RETURNS: array of row objects
16
+ ` : `
17
+ read-table - retrieve rows from a table in a CAS or SAS library.
18
+
19
+ USE when: read table, show rows, read from library, filtered data with WHERE
20
+ DO NOT USE for: list tables, table structure (use table-describe), SQL queries (use sas-query), SAS programs
21
+
22
+ PARAMETERS
23
+ - table: string — table name (required)
24
+ - lib: string — caslib or libref (required)
25
+ - server: string (default: 'cas') — 'cas' or 'sas'
26
+ - start: number (default: 1) — 1-based row index
27
+ - limit: number (default: 10) — max rows (1-1000)
28
+ - where: string — SQL WHERE clause filter
29
+ - format: boolean (default: true) — formatted or raw values
30
+
31
+ PARSING ROWS FROM USER INPUT
32
+ "first N rows/records" start: 1, limit: N ("first" = count from beginning, never an offset)
33
+ "top N rows" start: 1, limit: N
34
+ "N rows" / "N records" → start: 1, limit: N
35
+ "read N rows from lib.table" → lib: "lib", table: "table", start: 1, limit: N
36
+ "rows N to M" start: N, limit: M-N+1
37
+ "starting from row N" start: N, limit: 10 (default)
38
+ (no count specified) → start: 1, limit: 10 (default)
39
+
40
+ DOTTED FORMAT: "lib.table" → lib: "lib", table: "table" (split on first dot)
41
+
42
+ ROUTING RULES
43
+ - "read table cars in Samples" → { table: "cars", lib: "Samples", start: 1, limit: 10 }
44
+ - "show 25 rows from customers" → { table: "customers", lib: "<lib>", limit: 25, start: 1 }
45
+ - "read from mylib.orders where status='shipped'" → { table: "orders", lib: "mylib", where: "status='shipped'", start: 1, limit: 10 }
46
+
47
+ EXAMPLES
48
+ - "read table cars in Samples" → { table: "cars", lib: "Samples", start: 1, limit: 10 }
49
+ - "show 25 rows from customers" → { table: "customers", lib: "mylib", limit: 25, start: 1 }
50
+
51
+ NEGATIVE EXAMPLES (do not route here)
52
+ - "list tables in Samples" (use list-tables)
53
+ - "what columns are in cars" (use table-describe)
54
+ - "execute SQL query" (use sas-query)
55
+ - "run SAS code" (use program-score)
56
+
57
+ ERRORS
58
+ Returns rows array, total count, filtered_count, columns metadata. Empty array if no matches.
59
+ `;
60
+
61
+ let specs = {
62
+ name: 'read-table',
63
+ description: describe,
64
+ inputSchema: z.object({
65
+ table: z.string().min(1),
66
+ lib: z.string().min(1).optional(),
67
+ start: z.number().int().min(1).optional(),
68
+ limit: z.number().int().min(1).max(1000).optional(),
69
+ server: z.enum(['cas', 'sas']).optional(),
70
+ where: z.string().min(1).optional()
71
+ }),
72
+ handler: async (params) => {
73
+ let r = await _readTable(params,'query');
74
+ return r;
75
+ }
76
+ }
77
+ return specs;
78
+ }
79
+ export default readTable;
80
+
@@ -1,77 +1,83 @@
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 _jobSubmit from '../toolHelpers/_jobSubmit.js';
7
-
8
- function sasQuery() {
9
-
10
- let description = `
11
- sas-query convert natural language questions into SQL queries and execute them.
12
-
13
- USE when: how many/count/total/average by, aggregated analytics, complex filtering, statistical summaries
14
- DO NOT USE for: raw reads without filtering (use read-table), table structure (use table-info), SAS programs (use run-sas-program), jobs/jobdefs
15
-
16
- PARAMETERS
17
- - table: string — table in lib.table format (required), e.g. "Public.cars" or "sashelp.class"
18
- - query: string natural language question (required)
19
- - sql: string pre-generated SQL SELECT (optional, LLM generates)
20
- - job: string (default: 'program') — job name to execute
21
-
22
- ROUTING RULES
23
- - "how many cars by make in sashelp.cars" → { table: "sashelp.cars", query: "how many cars by make", sql: "SELECT make, COUNT(*) FROM sashelp.cars GROUP BY make" }
24
- - "average salary by department in Public.employees" → { table: "Public.employees", query: "average salary by department", sql: "SELECT department, AVG(salary) FROM Public.employees GROUP BY department" }
25
-
26
- EXAMPLES
27
- - "how many cars by make in sashelp.cars" → { table: "sashelp.cars", query: "how many cars by make", sql: "SELECT make, COUNT(*) FROM sashelp.cars GROUP BY make" }
28
- - "total sales by region from mylib.sales" { table: "mylib.sales", query: "total sales by region", sql: "SELECT region, SUM(amount) FROM mylib.sales GROUP BY region" }
29
-
30
- NEGATIVE EXAMPLES (do not route here)
31
- - "read table cars" (use read-table)
32
- - "show 10 rows" (use read-table)
33
- - "table structure" (use table-info)
34
- - "run SAS code" (use run-sas-program)
35
- - "run job/macro" (use run-job/run-macro)
36
-
37
- ERRORS
38
- Returns rows array, columns metadata, log. Returns error if SQL invalid or table not found.
39
- `;
40
-
41
-
42
- let spec = {
43
- name: 'sas-query',
44
- description: description,
45
- inputSchema: z.object({
46
- query: z.string(),
47
- table: z.string(),
48
- sql: z.string().optional()
49
- }),
50
- handler: async (params) => {
51
- let {table,query, sql, job, _appContext} = params;
52
- let sqlinput = (sql == null) ? ' ' : sql.replaceAll(';', ' ').replaceAll('\n', ' ').replaceAll('\r', ' ');
53
-
54
- let iparams = {
55
- scenario: {
56
- table: table,
57
- prompt: query,
58
- sql: sqlinput
59
- },
60
- name: (job == null) ? 'program' : job,
61
- type: 'job',
62
- query: true,
63
- _appContext: _appContext
64
- };
65
- if (sql == null || sql.trim().length === 0) {
66
- return { content: [{ type: 'text', text: 'Error: The SQL statement generated is blank. Please provide a valid natural language query that can be converted to SQL.' }] };
67
- }
68
-
69
- let r = await _jobSubmit(iparams);
70
- return r;
71
-
72
- }
73
- }
74
- return spec;
75
- }
76
- export default sasQuery;
77
-
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 _jobSubmit from '../toolHelpers/_jobSubmit.js';
7
+
8
+ function sasQuery(_appContext) {
9
+ const isAgent = _appContext && _appContext.agent;
10
+
11
+ let description = isAgent ? `
12
+ sas-query — run a SQL aggregation query against a table.
13
+ PARAMS: table (string as lib.table, required), query (string, SQL WHERE/aggregation clause, required)
14
+ RETURNS: aggregated query result rows
15
+ ` : `
16
+ sas-query - convert natural language questions into SQL queries and execute them.
17
+
18
+ USE when: how many/count/total/average by, aggregated analytics, complex filtering, statistical summaries
19
+ DO NOT USE for: raw reads without filtering (use read-table), table structure (use table-describe), SAS programs (use program-score), jobs/jobdefs
20
+
21
+ PARAMETERS
22
+ - table: string — table in lib.table format (required), e.g. "Public.cars" or "sashelp.class"
23
+ - query: string — natural language question (required)
24
+ - sql: string — pre-generated SQL SELECT (optional, LLM generates)
25
+ - job: string (default: 'program') — job name to execute
26
+
27
+ ROUTING RULES
28
+ - "how many cars by make in sashelp.cars" → { table: "sashelp.cars", query: "how many cars by make", sql: "SELECT make, COUNT(*) FROM sashelp.cars GROUP BY make" }
29
+ - "average salary by department in Public.employees" → { table: "Public.employees", query: "average salary by department", sql: "SELECT department, AVG(salary) FROM Public.employees GROUP BY department" }
30
+
31
+ EXAMPLES
32
+ - "how many cars by make in sashelp.cars" → { table: "sashelp.cars", query: "how many cars by make", sql: "SELECT make, COUNT(*) FROM sashelp.cars GROUP BY make" }
33
+ - "total sales by region from mylib.sales" → { table: "mylib.sales", query: "total sales by region", sql: "SELECT region, SUM(amount) FROM mylib.sales GROUP BY region" }
34
+
35
+ NEGATIVE EXAMPLES (do not route here)
36
+ - "read table cars" (use read-table)
37
+ - "show 10 rows" (use read-table)
38
+ - "table structure" (use table-describe)
39
+ - "run SAS code" (use program-score)
40
+ - "score job/macro" (use job-score/macro-score)
41
+
42
+ ERRORS
43
+ Returns rows array, columns metadata, log. Returns error if SQL invalid or table not found.
44
+ `;
45
+
46
+
47
+ let spec = {
48
+ name: 'sas-query',
49
+ description: description,
50
+ inputSchema: z.object({
51
+ query: z.string(),
52
+ table: z.string(),
53
+ sql: z.string().optional()
54
+ }),
55
+ handler: async (params) => {
56
+ let {table,query, sql, job, _appContext} = params;
57
+ let sqlinput = (sql == null) ? ' ' : sql.replaceAll(';', ' ').replaceAll('\n', ' ').replaceAll('\r', ' ');
58
+
59
+ let iparams = {
60
+ scenario: {
61
+ table: table,
62
+ prompt: query,
63
+ sql: sqlinput
64
+ },
65
+ name: (job == null) ? 'program' : job,
66
+ type: 'job',
67
+ query: true,
68
+ _appContext: _appContext
69
+ };
70
+ if (sql == null || sql.trim().length === 0) {
71
+ return { content: [{ type: 'text', text: 'Error: The SQL statement generated is blank. Please provide a valid natural language query that can be converted to SQL.' }] };
72
+ }
73
+
74
+ let r = await _jobSubmit(iparams);
75
+ return r;
76
+
77
+ }
78
+ }
79
+ return spec;
80
+ }
81
+ export default sasQuery;
82
+
83
+
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import { z } from 'zod';
7
+ import _scrDescribe from '../toolHelpers/_scrDescribe.js';
8
+
9
+ function scrDescribe(_appContext) {
10
+ const isAgent = _appContext && _appContext.agent;
11
+ let description = isAgent ? `
12
+ scr-describe — return input/output schema for a SCR model.
13
+ PARAMS: intent ('describe', required), name (string, required)
14
+ RETURNS: input/output schema and model metadata
15
+ ` : `
16
+ scr-describe - return the input/output schema and metadata for an SCR (Score Code Runtime) model.
17
+
18
+ Inputs
19
+ - intent: must be 'describe' — only pass if user explicitly asked to describe/inspect an SCR model. Do NOT use for find or verify existence.
20
+ - name (string): The SCR model identifier.
21
+ What it returns
22
+ - A JSON object describing the model's interface, typically including:
23
+ - Input variables (names, types, required/optional)
24
+ - Output variables (predictions, probabilities, scores)
25
+
26
+
27
+ Usage notes
28
+ - Ensure network connectivity and credentials for the remote SCR service when needed.
29
+ - Use scr-score to score data after inspecting the schema.
30
+
31
+ Examples
32
+ - describe scr model "loan"
33
+ - info for scr model "loan"
34
+ `;
35
+
36
+ let spec = {
37
+ name: 'scr-describe',
38
+ description: description,
39
+ inputSchema: z.object({
40
+ intent: z.literal('describe'),
41
+ name: z.string()
42
+ }),
43
+ handler: async (params) => {
44
+ const { intent, name, _appContext } = params;
45
+ if (name === null) {
46
+ return { status: { statusCode: 2, msg: `SCR model ${name} not found` }, results: {} };
47
+ }
48
+ let r = await _scrDescribe({name, _appContext});
49
+ return r;
50
+ }
51
+ }
52
+ return spec;
53
+ }
54
+
55
+ export default scrDescribe;
@@ -1,70 +1,63 @@
1
- /*
2
- * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
-
6
- import { z } from 'zod';
7
- import _scrScore from '../toolHelpers/_scrScore.js';
8
-
9
- function scrScore(_appContext) {
10
- let description = `
11
- ## scr-score
12
-
13
- Purpose
14
- Score a scenario using a model deployed as a SCR container in Azure or another host).
15
-
16
- Inputs
17
- - url (string, required): SCR model identifier (URL)
18
- - scenario (string | object | array, optional): Input values to score. Accepts:
19
- - a comma-separated key=value string (e.g. "x=1, y=2"),
20
- - a JSON object with field names and values (recommended for typed inputs),
21
- - an array of objects for batch scoring. If omitted, the tool will return the model's input variable definitions.
22
-
23
- What it returns
24
- - When scoring: the SCR endpoint response (predictions, probabilities, scores) merged with or alongside the supplied inputs.
25
- - When \`scenario\` is omitted: metadata describing the model's input variables (names, types, required/optional).
26
-
27
- Usage notes
28
- - Run \`scr-info\` first to inspect the expected input variables and types.
29
- - Prefer structured objects for numeric/date values to avoid type ambiguity; the simple string parser keeps values as strings.
30
- - Ensure network connectivity and any required credentials for the target SCR service.
31
-
32
- Examples
33
- - scrScore with url="loan" and scenario="age=45, income=60000"
34
- - scrScore with url="https://scr-host/models/loan" and scenario={age:45, income:60000}
35
- `;
36
-
37
- let spec = {
38
- name: 'scr-score',
39
- description: description,
40
- inputSchema: z.object({
41
- url: z.string(),
42
- scenario: z.string().optional()
43
- }),
44
-
45
- handler: async (params) => {
46
- let {url, scenario,_appContext} = params;
47
-
48
- if (url === null) {
49
- return { status: { statusCode: 2, msg: `SCR model ${url} was not specified` }, results: {} };
50
- }
51
-
52
- // Normalize simple string scenarios like "x=1, y=2" into an object
53
- if (typeof scenario === 'string' && scenario.includes('=')) {
54
- scenario = scenario.split(',').reduce((acc, pair) => {
55
- const [k, ...rest] = pair.split('=');
56
- if (!k) return acc;
57
- acc[k.trim()] = rest.join('=').trim();
58
- return acc;
59
- }, {});
60
- }
61
-
62
- let r = await _scrScore({ url: url, scenario: scenario , _appContext: _appContext});
63
- return r;
64
- }
65
- }
66
-
67
- return spec;
68
- }
69
-
70
- export default scrScore;
1
+ /*
2
+ * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import { z } from 'zod';
7
+ import _scrScore from '../toolHelpers/_scrScore.js';
8
+
9
+ function scrScore(_appContext) {
10
+ const isAgent = _appContext && _appContext.agent;
11
+ let description = isAgent ? `
12
+ scr-score — score a scenario using a SCR model endpoint.
13
+ PARAMS: name (string, required), scenario (object, optional)
14
+ RETURNS: SCR endpoint response with predictions merged with inputs
15
+ ` : `
16
+ scr-score - score a scenario using a model deployed as a SCR container in Azure or another host.
17
+
18
+ Inputs
19
+ - name (string, required): SCR model identifier (URL)
20
+ - scenario (object, optional): Input values to score as a JSON object (e.g. {age:45, income:60000}). If omitted, defaults to {} and the tool will return the model's input variable definitions.
21
+
22
+ What it returns
23
+ - When scoring: the SCR endpoint response (predictions, probabilities, scores) merged with or alongside the supplied inputs.
24
+ - When \`scenario\` is omitted: metadata describing the model's input variables (names, types, required/optional).
25
+
26
+ Usage notes
27
+ - Run \`scr-describe\` first to inspect the expected input variables and types.
28
+ - Prefer structured objects for numeric/date values to avoid type ambiguity; the simple string parser keeps values as strings.
29
+ - Ensure network connectivity and any required credentials for the target SCR service.
30
+
31
+ Examples
32
+ - scrScore with name="loan" and scenario={age:45, income:60000}
33
+ `;
34
+
35
+ let spec = {
36
+ name: 'scr-score',
37
+ description: description,
38
+ inputSchema: z.object({
39
+ name: z.string(),
40
+ scenario: z.union([z.record(z.any()), z.string()]).optional()
41
+ }),
42
+
43
+ handler: async (params) => {
44
+ let {name, _appContext} = params;
45
+ let scenario = params.scenario;
46
+ if (typeof scenario === 'string') {
47
+ try { scenario = JSON.parse(scenario); } catch { scenario = {}; }
48
+ }
49
+ if (name === null) {
50
+ return { status: { statusCode: 2, msg: `SCR model ${name} was not specified` }, results: {} };
51
+ }
52
+
53
+ const scenarioObj = (scenario != null && typeof scenario === 'object') ? scenario : {};
54
+
55
+ let r = await _scrScore({ name: name, scenario: scenarioObj, _appContext: _appContext});
56
+ return r;
57
+ }
58
+ }
59
+
60
+ return spec;
61
+ }
62
+
63
+ export default scrScore;
@@ -11,7 +11,7 @@ function searchAssets(_appContext) {
11
11
  const log = debug('tools');
12
12
 
13
13
  let description = `
14
- ## searchAssets: Search the SAS Catalog for assets using a flexible search string.
14
+ search-assets - Search the SAS Catalog for assets using a flexible search string.
15
15
 
16
16
  - Supports searching for various asset types (e.g., datasets, dataflows, models).
17
17
  - the default asset type is 'datasets'.