@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.
- package/.skills/.claude-plugin/plugin.json +59 -0
- package/.skills/agents/sas-score-mcp-serverjs-agent.md +26 -0
- package/.skills/copilot-instructions.md +62 -0
- package/.skills/skills/README.md +204 -0
- package/.skills/skills/detail-strategy/SKILL.md +316 -0
- package/.skills/skills/find-library-server/SKILL.md +62 -0
- package/.skills/skills/find-resources/SKILL.md +66 -0
- package/.skills/skills/list-library/SKILL.md +30 -0
- package/.skills/skills/list-mas-job-jobdef/SKILL.md +31 -0
- package/.skills/skills/list-tables/SKILL.md +30 -0
- package/.skills/skills/read-strategy/SKILL.md +87 -0
- package/.skills/skills/request-routing/SKILL.md +112 -0
- package/.skills/skills/score-cas/SKILL.md +95 -0
- package/.skills/skills/score-job-jobdef/SKILL.md +58 -0
- package/.skills/skills/score-mas-scr/SKILL.md +58 -0
- package/.skills/skills/score-program/SKILL.md +59 -0
- package/.skills/skills/score-strategy/SKILL.md +39 -0
- package/README.md +96 -54
- package/cli.js +11 -13
- package/openApi.yaml +121 -121
- package/package.json +16 -14
- package/scripts/docs/SCORE_SKILL_REFERENCE.md +17 -16
- package/scripts/docs/TOOL_DESCRIPTION_TEMPLATE.md +3 -3
- package/scripts/docs/TOOL_UPDATES_SUMMARY.md +65 -63
- package/scripts/docs/oauth-http-transport.md +2 -2
- package/scripts/docs/sas-mcp-tools-reference.md +43 -32
- package/scripts/plot_msrp_usa.py +49 -0
- package/scripts/refreshtoken.js +58 -0
- package/scripts/runListScr.mjs +16 -0
- package/src/createMcpServer.js +4 -1
- package/src/expressMcpServer.js +47 -49
- package/src/oauthHandlers/authorize.js +4 -1
- package/src/oauthHandlers/baseUrl.js +4 -0
- package/src/oauthHandlers/callback.js +4 -0
- package/src/oauthHandlers/getMetadata.js +4 -0
- package/src/oauthHandlers/index.js +4 -0
- package/src/oauthHandlers/token.js +4 -0
- package/src/openApi.yaml +121 -121
- package/src/processHeaders.js +10 -7
- package/src/setupSkills.js +1 -18
- package/src/toolHelpers/_casScore.js +32 -0
- package/src/toolHelpers/_desc.js +14 -0
- package/src/toolHelpers/_findJob.js +12 -0
- package/src/toolHelpers/_findJobdef.js +10 -0
- package/src/toolHelpers/_findLibrary.js +11 -0
- package/src/toolHelpers/_findMas.js +13 -0
- package/src/toolHelpers/_findScr.js +36 -0
- package/src/toolHelpers/_findTable.js +11 -0
- package/src/toolHelpers/_listJobdefs.js +12 -2
- package/src/toolHelpers/_listJobs.js +19 -8
- package/src/toolHelpers/{_listModels.js → _listMas.js} +4 -4
- package/src/toolHelpers/_listScr.js +13 -0
- package/src/toolHelpers/{_scrInfo.js → _scrDescribe.js} +4 -4
- package/src/toolHelpers/_scrScore.js +2 -2
- package/src/toolHelpers/_submitCasl.js +19 -17
- package/src/toolHelpers/{_tableInfo.js → _tableDescribe.js} +2 -2
- package/src/toolHelpers/getLogonPayload.js +2 -2
- package/src/toolSet/casModelScore.js +93 -0
- package/src/toolSet/casProgramScore.js +105 -0
- package/src/toolSet/devaScore.js +66 -61
- package/src/toolSet/findJob.js +24 -9
- package/src/toolSet/findJobdef.js +22 -19
- package/src/toolSet/findLibrary.js +73 -68
- package/src/toolSet/findMas.js +72 -0
- package/src/toolSet/findScr.js +69 -0
- package/src/toolSet/findTable.js +34 -27
- package/src/toolSet/getEnv.js +6 -6
- package/src/toolSet/jobDescribe.js +65 -0
- package/src/toolSet/jobScore.js +90 -0
- package/src/toolSet/jobdefDescribe.js +67 -0
- package/src/toolSet/jobdefScore.js +85 -0
- package/src/toolSet/listJobdefs.js +70 -61
- package/src/toolSet/listJobs.js +68 -61
- package/src/toolSet/listLibraries.js +84 -78
- package/src/toolSet/listMas.js +71 -0
- package/src/toolSet/listScr.js +62 -0
- package/src/toolSet/listTables.js +78 -66
- package/src/toolSet/{runMacro.js → macroScore.js} +86 -82
- package/src/toolSet/makeTools.js +39 -25
- package/src/toolSet/masDescribe.js +67 -0
- package/src/toolSet/masScore.js +95 -0
- package/src/toolSet/{runProgram.js → programScore.js} +21 -18
- package/src/toolSet/readTable.js +80 -63
- package/src/toolSet/sasQuery.js +83 -77
- package/src/toolSet/scrDescribe.js +55 -0
- package/src/toolSet/scrScore.js +63 -70
- package/src/toolSet/searchAssets.js +1 -1
- package/src/toolSet/setContext.js +70 -65
- package/src/toolSet/superstat.js +61 -61
- package/src/toolSet/tableDescribe.js +65 -0
- package/.agents/sas-score-mcp-serverjs-agent.md +0 -58
- package/.instructions/copilot-instructions.md +0 -201
- package/.instructions/enforce-find-resource-strategy.md +0 -35
- package/.skills/sas-find-library-smart/SKILL.md +0 -155
- package/.skills/sas-find-resource-strategy/SKILL.md +0 -105
- package/.skills/sas-list-resource-strategy/SKILL.md +0 -124
- package/.skills/sas-list-tables-smart/SKILL.md +0 -128
- package/.skills/sas-read-and-score-strategy/SKILL.md +0 -113
- package/.skills/sas-read-strategy/SKILL.md +0 -154
- package/.skills/sas-request-classifier/SKILL.md +0 -74
- package/.skills/sas-score-workflow-strategy/SKILL.md +0 -314
- package/scripts/optimize_final.py +0 -140
- package/scripts/optimize_tools.py +0 -99
- package/scripts/setup-skills.js +0 -34
- package/scripts/update_descriptions.py +0 -46
- package/src/authpkce.js +0 -219
- package/src/handleGetDelete.js +0 -34
- package/src/handleRequest.js +0 -112
- package/src/hapiMcpServer.js +0 -241
- package/src/toolSet/findModel.js +0 -60
- package/src/toolSet/listModels.js +0 -56
- package/src/toolSet/modelInfo.js +0 -55
- package/src/toolSet/modelScore.js +0 -89
- package/src/toolSet/runCasProgram.js +0 -98
- package/src/toolSet/runJob.js +0 -81
- package/src/toolSet/runJobdef.js +0 -82
- package/src/toolSet/scrInfo.js +0 -52
- package/src/toolSet/tableInfo.js +0 -58
package/src/toolSet/readTable.js
CHANGED
|
@@ -1,63 +1,80 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
|
package/src/toolSet/sasQuery.js
CHANGED
|
@@ -1,77 +1,83 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- "
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
- "
|
|
33
|
-
- "table
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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;
|
package/src/toolSet/scrScore.js
CHANGED
|
@@ -1,70 +1,63 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- When
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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'.
|