@sassoftware/sas-score-mcp-serverjs 1.0.1-30 → 1.0.1-32
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/agents/sas-score-mcp-serverjs-agent.md +1 -1
- package/.skills/copilot-instructions.md +57 -26
- package/.skills/skills/detail-strategy/SKILL.md +95 -49
- package/.skills/skills/find-resources/SKILL.md +38 -31
- package/.skills/skills/list-resource/SKILL.md +93 -33
- package/.skills/skills/request-routing/SKILL.md +9 -4
- package/.skills/skills/score-strategy/SKILL.md +21 -3
- package/README.md +62 -43
- package/openApi.yaml +121 -121
- package/package.json +7 -5
- package/scripts/docs/oauth-http-transport.md +2 -2
- package/scripts/plot_msrp_usa.py +49 -0
- package/scripts/refreshtoken.js +57 -57
- package/src/createMcpServer.js +0 -1
- package/src/openApi.yaml +121 -121
- package/src/toolHelpers/_findJob.js +12 -0
- package/src/toolHelpers/_findJobdef.js +10 -0
- package/src/toolHelpers/_findLibrary.js +10 -0
- package/src/toolHelpers/_findMas.js +12 -0
- package/src/toolHelpers/_findTable.js +10 -0
- package/src/toolHelpers/_listJobs.js +2 -2
- package/src/toolHelpers/{_listModels.js → _listMas.js} +4 -4
- package/src/toolSet/devaScore.js +61 -61
- package/src/toolSet/findJob.js +2 -1
- package/src/toolSet/findJobdef.js +2 -2
- package/src/toolSet/findLibrary.js +68 -68
- package/src/toolSet/findMas.js +59 -0
- package/src/toolSet/findTable.js +2 -2
- package/src/toolSet/jobInfo.js +59 -0
- package/src/toolSet/jobdefInfo.js +59 -0
- package/src/toolSet/listJobdefs.js +61 -61
- package/src/toolSet/listJobs.js +61 -61
- package/src/toolSet/listLibraries.js +78 -78
- package/src/toolSet/{listModels.js → listMas.js} +61 -56
- package/src/toolSet/listTables.js +66 -66
- package/src/toolSet/makeTools.js +21 -12
- package/src/toolSet/{modelInfo.js → masInfo.js} +12 -12
- package/src/toolSet/{modelScore.js → masScore.js} +3 -3
- package/src/toolSet/readTable.js +63 -63
- package/src/toolSet/runMacro.js +82 -82
- package/src/toolSet/sasQuery.js +77 -77
- package/src/toolSet/setContext.js +65 -65
- package/src/toolSet/superstat.js +61 -61
- package/src/toolSet/tableInfo.js +58 -58
- package/scripts/optimize_final.py +0 -140
- package/scripts/optimize_tools.py +0 -99
- package/scripts/setup-skills.js +0 -34
- package/scripts/token.txt +0 -1
- package/scripts/update_descriptions.py +0 -46
- package/src/toolSet/findModel.js +0 -60
|
@@ -1,56 +1,61 @@
|
|
|
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
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
let description = `
|
|
11
|
-
list-
|
|
12
|
-
|
|
13
|
-
USE when: list models, show models,
|
|
14
|
-
DO NOT USE for: find model, model metadata, score model, list jobs/tables/libraries
|
|
15
|
-
|
|
16
|
-
PARAMETERS
|
|
17
|
-
- limit: number (default: 10) — page size
|
|
18
|
-
- start: number (default: 1) — 1-based offset
|
|
19
|
-
|
|
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 }
|
|
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
|
-
|
|
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 _listMas from '../toolHelpers/_listMas.js';
|
|
8
|
+
|
|
9
|
+
function listMas(_appContext) {
|
|
10
|
+
let description = `
|
|
11
|
+
list-mas — enumerate models published to MAS.
|
|
12
|
+
|
|
13
|
+
USE when: list models, show models, list mas, show mas next page
|
|
14
|
+
DO NOT USE for: find model, find mas, model metadata, score model, list jobs/tables/libraries
|
|
15
|
+
|
|
16
|
+
PARAMETERS
|
|
17
|
+
- limit: number (default: 10) — page size
|
|
18
|
+
- start: number (default: 1) — 1-based offset
|
|
19
|
+
|
|
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 }
|
|
24
|
+
- "list mas" → { start:1, limit:10 }
|
|
25
|
+
- "list 25 mas" → { start:1, limit:25 }
|
|
26
|
+
- "next mas" → { start: start+limit, limit:10 }
|
|
27
|
+
|
|
28
|
+
EXAMPLES
|
|
29
|
+
- "list models" → { start:1, limit:10 }
|
|
30
|
+
- "list 25 models" → { start:1, limit:25 }
|
|
31
|
+
- "list mas" → { start:1, limit:10 }
|
|
32
|
+
- "list 25 mas" → { start:1, limit:25 }
|
|
33
|
+
|
|
34
|
+
NEGATIVE EXAMPLES (do not route here)
|
|
35
|
+
- "find model X" (use find-model)
|
|
36
|
+
- "describe model X" (use model-info)
|
|
37
|
+
- "score model X" (use model-score)
|
|
38
|
+
- "list jobs" (use list-jobs)
|
|
39
|
+
|
|
40
|
+
ERRORS
|
|
41
|
+
Returns empty array if no models found.
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
let spec = {
|
|
45
|
+
name: 'list-mas',
|
|
46
|
+
description: description,
|
|
47
|
+
inputSchema: z.object({
|
|
48
|
+
limit: z.number().optional(),
|
|
49
|
+
start: z.number().optional()
|
|
50
|
+
}),
|
|
51
|
+
handler: async (params) => {
|
|
52
|
+
let r = await _listMas(params);
|
|
53
|
+
return r;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return spec;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default listMas;
|
|
61
|
+
|
|
@@ -1,66 +1,66 @@
|
|
|
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 debug from 'debug';
|
|
8
|
-
import _listTables from '../toolHelpers/_listTables.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function listTables(_appContext) {
|
|
12
|
-
const log = debug('tools');
|
|
13
|
-
|
|
14
|
-
let description = `
|
|
15
|
-
list-tables — enumerate tables within a library.
|
|
16
|
-
|
|
17
|
-
USE when: list tables in <lib>, show tables in <lib>, next page
|
|
18
|
-
DO NOT USE for: find table, list libraries, get table structure (use table-info), read data (use read-table)
|
|
19
|
-
|
|
20
|
-
PARAMETERS
|
|
21
|
-
- lib: string — library to inspect (required)
|
|
22
|
-
- server: string (default: 'cas') — 'cas' or 'sas'
|
|
23
|
-
- limit: number (default: 10) — page size
|
|
24
|
-
- start: number (default: 1) — 1-based offset
|
|
25
|
-
- where: string — optional filter expression
|
|
26
|
-
|
|
27
|
-
ROUTING RULES
|
|
28
|
-
- "list tables in Samples" → { lib: "Samples", start: 1, limit: 10 }
|
|
29
|
-
- "list 25 tables in sashelp" → { lib: "sashelp", limit: 25, start: 1 }
|
|
30
|
-
- "list cas tables in Public" → { lib: "Public", server: "cas", start: 1, limit: 10 }
|
|
31
|
-
|
|
32
|
-
EXAMPLES
|
|
33
|
-
- "list tables in Samples" → { lib: "Samples", start: 1, limit: 10 }
|
|
34
|
-
- "show 25 tables in sashelp" → { lib: "sashelp", limit: 25, start: 1 }
|
|
35
|
-
|
|
36
|
-
NEGATIVE EXAMPLES (do not route here)
|
|
37
|
-
- "list libs" (use list-libraries)
|
|
38
|
-
- "find lib Public" (use find-library)
|
|
39
|
-
- "describe table cars" (use table-info)
|
|
40
|
-
- "read table cars" (use read-table)
|
|
41
|
-
|
|
42
|
-
ERRORS
|
|
43
|
-
Returns empty array if no tables found.
|
|
44
|
-
`;
|
|
45
|
-
|
|
46
|
-
let spec = {
|
|
47
|
-
name: 'list-tables',
|
|
48
|
-
description: description,
|
|
49
|
-
|
|
50
|
-
inputSchema: z.object({
|
|
51
|
-
lib: z.string(),
|
|
52
|
-
server: z.string().optional(),
|
|
53
|
-
limit: z.number().optional(),
|
|
54
|
-
start: z.number().optional(),
|
|
55
|
-
where: z.string().optional()
|
|
56
|
-
}),
|
|
57
|
-
handler: async (params) => {
|
|
58
|
-
let r = await _listTables(params);
|
|
59
|
-
return r;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return spec;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default listTables;
|
|
66
|
-
|
|
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 debug from 'debug';
|
|
8
|
+
import _listTables from '../toolHelpers/_listTables.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
function listTables(_appContext) {
|
|
12
|
+
const log = debug('tools');
|
|
13
|
+
|
|
14
|
+
let description = `
|
|
15
|
+
list-tables — enumerate tables within a library.
|
|
16
|
+
|
|
17
|
+
USE when: list tables in <lib>, show tables in <lib>, next page
|
|
18
|
+
DO NOT USE for: find table, list libraries, get table structure (use table-info), read data (use read-table)
|
|
19
|
+
|
|
20
|
+
PARAMETERS
|
|
21
|
+
- lib: string — library to inspect (required)
|
|
22
|
+
- server: string (default: 'cas') — 'cas' or 'sas'
|
|
23
|
+
- limit: number (default: 10) — page size
|
|
24
|
+
- start: number (default: 1) — 1-based offset
|
|
25
|
+
- where: string — optional filter expression
|
|
26
|
+
|
|
27
|
+
ROUTING RULES
|
|
28
|
+
- "list tables in Samples" → { lib: "Samples", start: 1, limit: 10 }
|
|
29
|
+
- "list 25 tables in sashelp" → { lib: "sashelp", limit: 25, start: 1 }
|
|
30
|
+
- "list cas tables in Public" → { lib: "Public", server: "cas", start: 1, limit: 10 }
|
|
31
|
+
|
|
32
|
+
EXAMPLES
|
|
33
|
+
- "list tables in Samples" → { lib: "Samples", start: 1, limit: 10 }
|
|
34
|
+
- "show 25 tables in sashelp" → { lib: "sashelp", limit: 25, start: 1 }
|
|
35
|
+
|
|
36
|
+
NEGATIVE EXAMPLES (do not route here)
|
|
37
|
+
- "list libs" (use list-libraries)
|
|
38
|
+
- "find lib Public" (use find-library)
|
|
39
|
+
- "describe table cars" (use table-info)
|
|
40
|
+
- "read table cars" (use read-table)
|
|
41
|
+
|
|
42
|
+
ERRORS
|
|
43
|
+
Returns empty array if no tables found.
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
let spec = {
|
|
47
|
+
name: 'list-tables',
|
|
48
|
+
description: description,
|
|
49
|
+
|
|
50
|
+
inputSchema: z.object({
|
|
51
|
+
lib: z.string(),
|
|
52
|
+
server: z.string().optional(),
|
|
53
|
+
limit: z.number().optional(),
|
|
54
|
+
start: z.number().optional(),
|
|
55
|
+
where: z.string().optional()
|
|
56
|
+
}),
|
|
57
|
+
handler: async (params) => {
|
|
58
|
+
let r = await _listTables(params);
|
|
59
|
+
return r;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return spec;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default listTables;
|
|
66
|
+
|
package/src/toolSet/makeTools.js
CHANGED
|
@@ -3,22 +3,28 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import
|
|
6
|
+
import listMas from './listMas.js';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
import masScore from './masScore.js';
|
|
10
|
+
import masInfo from './masInfo.js';
|
|
11
|
+
import findMas from './findMas.js';
|
|
12
|
+
|
|
10
13
|
import findLibrary from './findLibrary.js';
|
|
11
|
-
import readTable from './readTable.js';
|
|
12
|
-
import tableInfo from './tableInfo.js';
|
|
13
14
|
import listLibraries from './listLibraries.js';
|
|
14
15
|
|
|
16
|
+
import listTables from './listTables.js';
|
|
17
|
+
import findTable from './findTable.js';
|
|
18
|
+
import tableInfo from './tableInfo.js';
|
|
19
|
+
import readTable from './readTable.js';
|
|
20
|
+
|
|
15
21
|
import scrInfo from './scrInfo.js';
|
|
16
22
|
import scrScore from './scrScore.js';
|
|
17
23
|
|
|
18
24
|
import devaScore from './devaScore.js';
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
|
|
27
|
+
|
|
22
28
|
import runProgram from './runProgram.js';
|
|
23
29
|
import runMacro from './runMacro.js';
|
|
24
30
|
import runJob from './runJob.js';
|
|
@@ -27,6 +33,8 @@ import runJobdef from './runJobdef.js';
|
|
|
27
33
|
import findJob from './findJob.js';
|
|
28
34
|
import listJobdefs from './listJobdefs.js';
|
|
29
35
|
import findJobdef from './findJobdef.js';
|
|
36
|
+
import jobInfo from './jobInfo.js';
|
|
37
|
+
import jobdefInfo from './jobdefInfo.js';
|
|
30
38
|
|
|
31
39
|
import sasQuery from './sasQuery.js';
|
|
32
40
|
import setContext from './setContext.js';
|
|
@@ -38,11 +46,11 @@ function makeTools(_appContext) {
|
|
|
38
46
|
|
|
39
47
|
// get the tool definitions and handler
|
|
40
48
|
let list = [
|
|
41
|
-
|
|
49
|
+
listMas(_appContext),
|
|
42
50
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
findMas(_appContext),
|
|
52
|
+
masInfo(_appContext),
|
|
53
|
+
masScore(_appContext),
|
|
46
54
|
|
|
47
55
|
scrInfo(_appContext),
|
|
48
56
|
scrScore(_appContext),
|
|
@@ -63,6 +71,7 @@ function makeTools(_appContext) {
|
|
|
63
71
|
runJob(_appContext),
|
|
64
72
|
listJobdefs(_appContext),
|
|
65
73
|
findJobdef(_appContext),
|
|
74
|
+
jobdefInfo(_appContext),
|
|
66
75
|
runJobdef(_appContext),
|
|
67
76
|
|
|
68
77
|
devaScore(_appContext),
|
|
@@ -8,9 +8,9 @@ import debug from 'debug';
|
|
|
8
8
|
import _masDescribe from '../toolHelpers/_masDescribe.js';
|
|
9
9
|
const log = debug('tools');
|
|
10
10
|
|
|
11
|
-
function
|
|
11
|
+
function masInfo(_appContext) {
|
|
12
12
|
let description = `
|
|
13
|
-
|
|
13
|
+
mas-info — return detailed information about a specific MAS model, including its inputs, outputs, and metadata.
|
|
14
14
|
|
|
15
15
|
USE when: what inputs does model need, describe model, show variables for model, model inputs/outputs
|
|
16
16
|
DO NOT USE for: find model, list models, score model, table/job operations
|
|
@@ -19,26 +19,26 @@ PARAMETERS
|
|
|
19
19
|
- model: string — model name (required, exact match)
|
|
20
20
|
|
|
21
21
|
ROUTING RULES
|
|
22
|
-
- "what inputs does
|
|
23
|
-
- "describe
|
|
24
|
-
- "show variables for Z" → { model: "Z" }
|
|
22
|
+
- "what inputs does mas X need?" → { model: "X" }
|
|
23
|
+
- "describe mas Y" → { model: "Y" }
|
|
24
|
+
- "show variables for mas Z" → { model: "Z" }
|
|
25
25
|
|
|
26
26
|
EXAMPLES
|
|
27
|
-
- "What inputs does
|
|
28
|
-
- "Describe
|
|
27
|
+
- "What inputs does mas churnRisk need?" → { model: "churnRisk" }
|
|
28
|
+
- "Describe mas creditScore" → { model: "creditScore" }
|
|
29
29
|
- "Show variables for myModel" → { model: "myModel" }
|
|
30
30
|
|
|
31
31
|
NEGATIVE EXAMPLES (do not route here)
|
|
32
|
-
- "list
|
|
33
|
-
- "find
|
|
34
|
-
- "score with
|
|
32
|
+
- "list mas" (use list-models)
|
|
33
|
+
- "find mas X" (use find-model)
|
|
34
|
+
- "score with mas X" (use model-score)
|
|
35
35
|
|
|
36
36
|
ERRORS
|
|
37
37
|
Returns model metadata: inputs (name, type, role), outputs (name, type, possible_values), model_type, description.
|
|
38
38
|
`;
|
|
39
39
|
|
|
40
40
|
let spec = {
|
|
41
|
-
name: '
|
|
41
|
+
name: 'mas-info',
|
|
42
42
|
description: description,
|
|
43
43
|
inputSchema: z.object({
|
|
44
44
|
model: z.string()
|
|
@@ -51,5 +51,5 @@ Returns model metadata: inputs (name, type, role), outputs (name, type, possible
|
|
|
51
51
|
return spec;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export default
|
|
54
|
+
export default masInfo;
|
|
55
55
|
|
|
@@ -8,7 +8,7 @@ import debug from 'debug';
|
|
|
8
8
|
import _masScoring from '../toolHelpers/_masScoring.js';
|
|
9
9
|
const log = debug('tools');
|
|
10
10
|
|
|
11
|
-
function
|
|
11
|
+
function masScore(_appContext) {
|
|
12
12
|
let description = `
|
|
13
13
|
mas-score — score data using a deployed model on MAS.
|
|
14
14
|
|
|
@@ -74,7 +74,7 @@ Returns predictions, probabilities, scores merged with input data. Returns error
|
|
|
74
74
|
params.model = params.model.substring(0, params.model.lastIndexOf('.'));
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
log('
|
|
77
|
+
log('masScore params', params);
|
|
78
78
|
// Check if the params.scenario is a string and parse it
|
|
79
79
|
let r = await _masScoring(params)
|
|
80
80
|
return r;
|
|
@@ -83,5 +83,5 @@ Returns predictions, probabilities, scores merged with input data. Returns error
|
|
|
83
83
|
return spec;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export default
|
|
86
|
+
export default masScore;
|
|
87
87
|
|
package/src/toolSet/readTable.js
CHANGED
|
@@ -1,63 +1,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
|
-
|
|
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
|
+
|
|
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;
|