@sassoftware/sas-score-mcp-serverjs 0.3.29-0 → 0.4.1-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +118 -3
- package/openApi.yaml +121 -121
- package/package.json +4 -5
- package/skills/mcp-tool-description-optimizer/SKILL.md +129 -0
- package/skills/mcp-tool-description-optimizer/references/examples.md +123 -0
- package/skills/sas-read-and-score/SKILL.md +91 -0
- package/skills/sas-read-strategy/SKILL.md +143 -0
- package/skills/sas-score-workflow/SKILL.md +283 -0
- package/src/createMcpServer.js +11 -4
- package/src/expressMcpServer.js +1 -1
- package/src/handleGetDelete.js +1 -1
- package/src/openApi.yaml +121 -121
- package/src/toolHelpers/_jobSubmit.js +2 -0
- package/src/toolHelpers/_listLibrary.js +56 -39
- package/src/toolHelpers/readCerts.js +4 -4
- package/src/toolSet/devaScore.js +31 -44
- package/src/toolSet/findJob.js +37 -70
- package/src/toolSet/findJobdef.js +27 -58
- package/src/toolSet/findLibrary.js +29 -62
- package/src/toolSet/findModel.js +34 -57
- package/src/toolSet/findTable.js +29 -59
- package/src/toolSet/getEnv.js +26 -45
- package/src/toolSet/listJobdefs.js +30 -65
- package/src/toolSet/listJobs.js +30 -79
- package/src/toolSet/listLibraries.js +43 -55
- package/src/toolSet/listModels.js +25 -52
- package/src/toolSet/listTables.js +36 -66
- package/src/toolSet/makeTools.js +1 -0
- package/src/toolSet/modelInfo.js +21 -53
- package/src/toolSet/modelScore.js +30 -73
- package/src/toolSet/readTable.js +33 -72
- package/src/toolSet/runCasProgram.js +30 -51
- package/src/toolSet/runJob.js +24 -24
- package/src/toolSet/runJobdef.js +26 -29
- package/src/toolSet/runMacro.js +23 -24
- package/src/toolSet/runProgram.js +32 -80
- package/src/toolSet/sasQuery.js +31 -79
- package/src/toolSet/sasQueryTemplate.js +4 -5
- package/src/toolSet/sasQueryTemplate2.js +4 -5
- package/src/toolSet/scrInfo.js +4 -7
- package/src/toolSet/scrScore.js +2 -4
- package/src/toolSet/searchAssets.js +5 -6
- package/src/toolSet/setContext.js +30 -57
- package/src/toolSet/superstat.js +2 -3
- package/src/toolSet/tableInfo.js +32 -77
package/cli.js
CHANGED
|
@@ -22,6 +22,7 @@ import readCerts from './src/toolHelpers/readCerts.js';
|
|
|
22
22
|
|
|
23
23
|
import { fileURLToPath } from 'url';
|
|
24
24
|
import { dirname } from 'path';
|
|
25
|
+
import { parseArgs } from "node:util";
|
|
25
26
|
|
|
26
27
|
import NodeCache from 'node-cache';
|
|
27
28
|
//import getOpts from './src/toolHelpers/getOpts.js';
|
|
@@ -30,16 +31,97 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
30
31
|
|
|
31
32
|
let pkg = fs.readFileSync(__dirname + '/package.json', 'utf8');
|
|
32
33
|
|
|
34
|
+
// Parse command line arguments
|
|
35
|
+
const args = parseArgs({
|
|
36
|
+
options: {
|
|
37
|
+
port: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
short: 'p',
|
|
40
|
+
description: 'Port to run the server on'
|
|
41
|
+
},
|
|
42
|
+
mcptype: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
short: 'm',
|
|
45
|
+
description: 'MCP server type (http or stdio)'
|
|
46
|
+
},
|
|
47
|
+
viya: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
short: 'v',
|
|
50
|
+
description: 'Viya server URL'
|
|
51
|
+
},
|
|
52
|
+
authflow: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
short: 'a',
|
|
55
|
+
description: 'Authentication flow (sascli, code, token)'
|
|
56
|
+
},
|
|
57
|
+
profile: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description: 'SAS CLI profile name'
|
|
60
|
+
},
|
|
61
|
+
config: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: 'SAS CLI config directory'
|
|
64
|
+
},
|
|
65
|
+
envfile: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
short: 'e',
|
|
68
|
+
description: 'Environment file path'
|
|
69
|
+
},
|
|
70
|
+
help: {
|
|
71
|
+
type: 'boolean',
|
|
72
|
+
short: 'h',
|
|
73
|
+
description: 'Show help message'
|
|
74
|
+
},
|
|
75
|
+
version: {
|
|
76
|
+
type: 'boolean',
|
|
77
|
+
short: 'v',
|
|
78
|
+
description: 'Show version'
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
strict: false,
|
|
82
|
+
allowPositionals: false
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Handle help flag
|
|
86
|
+
if (args.values.help) {
|
|
87
|
+
console.log(`
|
|
88
|
+
Usage: sas-score-mcp-serverjs [options]
|
|
89
|
+
|
|
90
|
+
Options:
|
|
91
|
+
-p, --port <port> Port to run the server on (default: 8080)
|
|
92
|
+
-m, --mcptype <type> MCP server type: http or stdio (default: http)
|
|
93
|
+
-v, --viya <url> Viya server URL
|
|
94
|
+
-a, --authflow <flow> Authentication flow: sascli, code, or token
|
|
95
|
+
--profile <name> SAS CLI profile name
|
|
96
|
+
--config <path> SAS CLI config directory
|
|
97
|
+
-e, --envfile <path> Environment file path
|
|
98
|
+
-h, --help Show this help message
|
|
99
|
+
--version Show version
|
|
100
|
+
|
|
101
|
+
Environment Variables:
|
|
102
|
+
Use .env file or set environment variables for configuration.
|
|
103
|
+
See README.md for more information.
|
|
104
|
+
`);
|
|
105
|
+
process.exit(0);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Handle version flag
|
|
109
|
+
if (args.values.version) {
|
|
110
|
+
let pkgJson = JSON.parse(pkg);
|
|
111
|
+
console.log(pkgJson.version);
|
|
112
|
+
process.exit(0);
|
|
113
|
+
}
|
|
114
|
+
|
|
33
115
|
if (process.env.ENVFILE === 'FALSE') {
|
|
34
116
|
//use this when using remote mcp server and no .env file is desired
|
|
35
117
|
console.error('[Note]: Skipping .env file as ENVFILE is set to FALSE...');
|
|
36
118
|
} else {
|
|
37
119
|
console.error('Working Directory', process.cwd());
|
|
38
|
-
let envf = process.cwd() + '\\.env';
|
|
120
|
+
let envf = process.env.ENVFILE || (process.cwd() + '\\.env');
|
|
39
121
|
//__dirname + '\\.env';
|
|
40
122
|
console.error('Env file:', envf);
|
|
41
123
|
if (fs.existsSync(envf)) {
|
|
42
|
-
console.error(`Loading environment variables
|
|
124
|
+
console.error(`Loading environment variables from ${envf}...`);
|
|
43
125
|
let e = iconfig(envf); // avoid dotenv since it writes to console.log
|
|
44
126
|
console.error('[Note]: Environment variables loaded from .env file...');
|
|
45
127
|
console.error('Loaded env variables:', e);
|
|
@@ -51,6 +133,37 @@ if (process.env.ENVFILE === 'FALSE') {
|
|
|
51
133
|
}
|
|
52
134
|
}
|
|
53
135
|
|
|
136
|
+
// Apply command line arguments to override environment variables
|
|
137
|
+
if (args.values.port) {
|
|
138
|
+
process.env.PORT = args.values.port;
|
|
139
|
+
console.error(`[Note] PORT set from command line: ${args.values.port}`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (args.values.mcptype) {
|
|
143
|
+
process.env.MCPTYPE = args.values.mcptype;
|
|
144
|
+
console.error(`[Note] MCPTYPE set from command line: ${args.values.mcptype}`);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (args.values.viya) {
|
|
148
|
+
process.env.VIYA_SERVER = args.values.viya;
|
|
149
|
+
console.error(`[Note] VIYA_SERVER set from command line: ${args.values.viya}`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (args.values.authflow) {
|
|
153
|
+
process.env.AUTHFLOW = args.values.authflow;
|
|
154
|
+
console.error(`[Note] AUTHFLOW set from command line: ${args.values.authflow}`);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (args.values.profile) {
|
|
158
|
+
process.env.SAS_CLI_PROFILE = args.values.profile;
|
|
159
|
+
console.error(`[Note] SAS_CLI_PROFILE set from command line: ${args.values.profile}`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (args.values.config) {
|
|
163
|
+
process.env.SAS_CLI_CONFIG = args.values.config;
|
|
164
|
+
console.error(`[Note] SAS_CLI_CONFIG set from command line: ${args.values.config}`);
|
|
165
|
+
}
|
|
166
|
+
|
|
54
167
|
if (process.env.APPHOST == null) {
|
|
55
168
|
process.env.APPHOST = 'localhost';
|
|
56
169
|
}
|
|
@@ -136,6 +249,8 @@ const appEnvBase = {
|
|
|
136
249
|
process.env.TOOLSETS != null
|
|
137
250
|
? process.env.TOOLSETS.split(',')
|
|
138
251
|
: ['default'],
|
|
252
|
+
// command line arguments
|
|
253
|
+
cliArgs: args.values,
|
|
139
254
|
// user defined tools
|
|
140
255
|
//runtime variables
|
|
141
256
|
tokenRefresh: process.env.TOKENREFRESH === 'FALSE' ? false : true,
|
|
@@ -252,7 +367,7 @@ if (mcpType === 'stdio') {
|
|
|
252
367
|
console.error('[Note] Using HAPI HTTP server...')
|
|
253
368
|
} else {
|
|
254
369
|
await expressMcpServer(mcpServer, sessionCache, appEnvBase);
|
|
255
|
-
console.error('[Note] MCP HTTP server started on port ' + appEnvBase.PORT);
|
|
370
|
+
console.error('[Note] MCP HTTP express server started on port ' + appEnvBase.PORT);
|
|
256
371
|
}
|
|
257
372
|
}
|
|
258
373
|
|
package/openApi.yaml
CHANGED
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
swagger: "2.0"
|
|
2
|
-
info:
|
|
3
|
-
title: SAS Viya Sample MCP Server API
|
|
4
|
-
version: "1.0.0"
|
|
5
|
-
description: API for interacting with the SAS Viya Sample MCP Server.
|
|
6
|
-
host: localhost:8080
|
|
7
|
-
basePath: /
|
|
8
|
-
schemes:
|
|
9
|
-
- http
|
|
10
|
-
- https
|
|
11
|
-
consumes:
|
|
12
|
-
- application/json
|
|
13
|
-
produces:
|
|
14
|
-
- application/json
|
|
15
|
-
paths:
|
|
16
|
-
/health:
|
|
17
|
-
get:
|
|
18
|
-
summary: Health check
|
|
19
|
-
description: Returns health and version information.
|
|
20
|
-
responses:
|
|
21
|
-
200:
|
|
22
|
-
description: Health information
|
|
23
|
-
schema:
|
|
24
|
-
type: object
|
|
25
|
-
properties:
|
|
26
|
-
name:
|
|
27
|
-
type: string
|
|
28
|
-
version:
|
|
29
|
-
type: string
|
|
30
|
-
description:
|
|
31
|
-
type: string
|
|
32
|
-
endpoints:
|
|
33
|
-
type: object
|
|
34
|
-
usage:
|
|
35
|
-
type: string
|
|
36
|
-
/apiMeta:
|
|
37
|
-
get:
|
|
38
|
-
summary: API metadata
|
|
39
|
-
description: Returns the OpenAPI specification for this server.
|
|
40
|
-
responses:
|
|
41
|
-
200:
|
|
42
|
-
description: OpenAPI document
|
|
43
|
-
schema:
|
|
44
|
-
type: object
|
|
45
|
-
/mcp:
|
|
46
|
-
options:
|
|
47
|
-
summary: CORS preflight
|
|
48
|
-
description: CORS preflight endpoint.
|
|
49
|
-
responses:
|
|
50
|
-
204:
|
|
51
|
-
description: No Content
|
|
52
|
-
post:
|
|
53
|
-
summary: MCP request
|
|
54
|
-
description: Handles MCP JSON-RPC requests.
|
|
55
|
-
parameters:
|
|
56
|
-
- name: body
|
|
57
|
-
in: body
|
|
58
|
-
required: true
|
|
59
|
-
schema:
|
|
60
|
-
type: object
|
|
61
|
-
- name: Authorization
|
|
62
|
-
in: header
|
|
63
|
-
required: false
|
|
64
|
-
type: string
|
|
65
|
-
description: Bearer token for authentication
|
|
66
|
-
- name: X-VIYA-SERVER
|
|
67
|
-
in: header
|
|
68
|
-
required: false
|
|
69
|
-
type: string
|
|
70
|
-
description: Override VIYA server
|
|
71
|
-
- name: X-REFRESH-TOKEN
|
|
72
|
-
in: header
|
|
73
|
-
required: false
|
|
74
|
-
type: string
|
|
75
|
-
description: Refresh token for authentication
|
|
76
|
-
- name: mcp-session-id
|
|
77
|
-
in: header
|
|
78
|
-
required: false
|
|
79
|
-
type: string
|
|
80
|
-
description: Session ID
|
|
81
|
-
responses:
|
|
82
|
-
200:
|
|
83
|
-
description: MCP response
|
|
84
|
-
schema:
|
|
85
|
-
type: object
|
|
86
|
-
500:
|
|
87
|
-
description: Server error
|
|
88
|
-
schema:
|
|
89
|
-
type: object
|
|
90
|
-
get:
|
|
91
|
-
summary: Get MCP session
|
|
92
|
-
description: Retrieves information for an MCP session.
|
|
93
|
-
parameters:
|
|
94
|
-
- name: mcp-session-id
|
|
95
|
-
in: header
|
|
96
|
-
required: true
|
|
97
|
-
type: string
|
|
98
|
-
description: Session ID
|
|
99
|
-
responses:
|
|
100
|
-
200:
|
|
101
|
-
description: Session information
|
|
102
|
-
schema:
|
|
103
|
-
type: object
|
|
104
|
-
400:
|
|
105
|
-
description: Invalid or missing session ID
|
|
106
|
-
delete:
|
|
107
|
-
summary: Delete MCP session
|
|
108
|
-
description: Deletes an MCP session.
|
|
109
|
-
parameters:
|
|
110
|
-
- name: mcp-session-id
|
|
111
|
-
in: header
|
|
112
|
-
required: true
|
|
113
|
-
type: string
|
|
114
|
-
description: Session ID
|
|
115
|
-
responses:
|
|
116
|
-
200:
|
|
117
|
-
description: Session deleted
|
|
118
|
-
schema:
|
|
119
|
-
type: object
|
|
120
|
-
400:
|
|
121
|
-
description: Invalid or missing session ID
|
|
1
|
+
swagger: "2.0"
|
|
2
|
+
info:
|
|
3
|
+
title: SAS Viya Sample MCP Server API
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
description: API for interacting with the SAS Viya Sample MCP Server.
|
|
6
|
+
host: localhost:8080
|
|
7
|
+
basePath: /
|
|
8
|
+
schemes:
|
|
9
|
+
- http
|
|
10
|
+
- https
|
|
11
|
+
consumes:
|
|
12
|
+
- application/json
|
|
13
|
+
produces:
|
|
14
|
+
- application/json
|
|
15
|
+
paths:
|
|
16
|
+
/health:
|
|
17
|
+
get:
|
|
18
|
+
summary: Health check
|
|
19
|
+
description: Returns health and version information.
|
|
20
|
+
responses:
|
|
21
|
+
200:
|
|
22
|
+
description: Health information
|
|
23
|
+
schema:
|
|
24
|
+
type: object
|
|
25
|
+
properties:
|
|
26
|
+
name:
|
|
27
|
+
type: string
|
|
28
|
+
version:
|
|
29
|
+
type: string
|
|
30
|
+
description:
|
|
31
|
+
type: string
|
|
32
|
+
endpoints:
|
|
33
|
+
type: object
|
|
34
|
+
usage:
|
|
35
|
+
type: string
|
|
36
|
+
/apiMeta:
|
|
37
|
+
get:
|
|
38
|
+
summary: API metadata
|
|
39
|
+
description: Returns the OpenAPI specification for this server.
|
|
40
|
+
responses:
|
|
41
|
+
200:
|
|
42
|
+
description: OpenAPI document
|
|
43
|
+
schema:
|
|
44
|
+
type: object
|
|
45
|
+
/mcp:
|
|
46
|
+
options:
|
|
47
|
+
summary: CORS preflight
|
|
48
|
+
description: CORS preflight endpoint.
|
|
49
|
+
responses:
|
|
50
|
+
204:
|
|
51
|
+
description: No Content
|
|
52
|
+
post:
|
|
53
|
+
summary: MCP request
|
|
54
|
+
description: Handles MCP JSON-RPC requests.
|
|
55
|
+
parameters:
|
|
56
|
+
- name: body
|
|
57
|
+
in: body
|
|
58
|
+
required: true
|
|
59
|
+
schema:
|
|
60
|
+
type: object
|
|
61
|
+
- name: Authorization
|
|
62
|
+
in: header
|
|
63
|
+
required: false
|
|
64
|
+
type: string
|
|
65
|
+
description: Bearer token for authentication
|
|
66
|
+
- name: X-VIYA-SERVER
|
|
67
|
+
in: header
|
|
68
|
+
required: false
|
|
69
|
+
type: string
|
|
70
|
+
description: Override VIYA server
|
|
71
|
+
- name: X-REFRESH-TOKEN
|
|
72
|
+
in: header
|
|
73
|
+
required: false
|
|
74
|
+
type: string
|
|
75
|
+
description: Refresh token for authentication
|
|
76
|
+
- name: mcp-session-id
|
|
77
|
+
in: header
|
|
78
|
+
required: false
|
|
79
|
+
type: string
|
|
80
|
+
description: Session ID
|
|
81
|
+
responses:
|
|
82
|
+
200:
|
|
83
|
+
description: MCP response
|
|
84
|
+
schema:
|
|
85
|
+
type: object
|
|
86
|
+
500:
|
|
87
|
+
description: Server error
|
|
88
|
+
schema:
|
|
89
|
+
type: object
|
|
90
|
+
get:
|
|
91
|
+
summary: Get MCP session
|
|
92
|
+
description: Retrieves information for an MCP session.
|
|
93
|
+
parameters:
|
|
94
|
+
- name: mcp-session-id
|
|
95
|
+
in: header
|
|
96
|
+
required: true
|
|
97
|
+
type: string
|
|
98
|
+
description: Session ID
|
|
99
|
+
responses:
|
|
100
|
+
200:
|
|
101
|
+
description: Session information
|
|
102
|
+
schema:
|
|
103
|
+
type: object
|
|
104
|
+
400:
|
|
105
|
+
description: Invalid or missing session ID
|
|
106
|
+
delete:
|
|
107
|
+
summary: Delete MCP session
|
|
108
|
+
description: Deletes an MCP session.
|
|
109
|
+
parameters:
|
|
110
|
+
- name: mcp-session-id
|
|
111
|
+
in: header
|
|
112
|
+
required: true
|
|
113
|
+
type: string
|
|
114
|
+
description: Session ID
|
|
115
|
+
responses:
|
|
116
|
+
200:
|
|
117
|
+
description: Session deleted
|
|
118
|
+
schema:
|
|
119
|
+
type: object
|
|
120
|
+
400:
|
|
121
|
+
description: Invalid or missing session ID
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sassoftware/sas-score-mcp-serverjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1-1",
|
|
4
4
|
"description": "A mcp server for SAS Viya",
|
|
5
5
|
"author": "Deva Kumar <deva.kumar@sas.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,10 +39,11 @@
|
|
|
39
39
|
"src",
|
|
40
40
|
"cli.js",
|
|
41
41
|
"openApi.json",
|
|
42
|
-
"openApi.yaml"
|
|
42
|
+
"openApi.yaml",
|
|
43
|
+
"skills"
|
|
43
44
|
],
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
46
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
46
47
|
"@sassoftware/restaf": "^5.6.0",
|
|
47
48
|
"@sassoftware/restafedit": "^3.11.1-10",
|
|
48
49
|
"@sassoftware/restaflib": "^5.6.0",
|
|
@@ -56,10 +57,8 @@
|
|
|
56
57
|
"express-list-endpoints": "^7.1.1",
|
|
57
58
|
"express-rate-limit": "^8.2.1",
|
|
58
59
|
"helmet": "^8.1.0",
|
|
59
|
-
"mcp-framework": "^0.2.16",
|
|
60
60
|
"node-cache": "^5.1.2",
|
|
61
61
|
"open": "^11.0.0",
|
|
62
|
-
"puppeteer": "^24.34.0",
|
|
63
62
|
"selfsigned": "^5.2.0",
|
|
64
63
|
"undici": "^7.16.0",
|
|
65
64
|
"uuid": "^13.0.0",
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mcp-tool-description-optimizer
|
|
3
|
+
description: >
|
|
4
|
+
Optimize MCP (Model Context Protocol) tool descriptions for token efficiency and LLM routing accuracy.
|
|
5
|
+
Use this skill whenever a user shares a raw, verbose, or poorly structured MCP tool description and wants
|
|
6
|
+
it improved, rewritten, or reviewed. Trigger on phrases like: "optimize this tool description",
|
|
7
|
+
"rewrite my MCP tool description", "make this tool description more efficient", "clean up my tool spec",
|
|
8
|
+
"improve how Claude picks my tool", or when a user pastes a JavaScript/TypeScript tool description string
|
|
9
|
+
and asks for help with it. Also trigger when the user mentions token efficiency, tool routing,
|
|
10
|
+
or LLM disambiguation in the context of MCP servers.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# MCP Tool Description Optimizer
|
|
14
|
+
|
|
15
|
+
Rewrites verbose or poorly structured MCP tool descriptions into compact, signal-rich versions that
|
|
16
|
+
improve LLM tool selection accuracy while reducing token usage.
|
|
17
|
+
|
|
18
|
+
## Why this matters
|
|
19
|
+
|
|
20
|
+
Claude and other LLMs select MCP tools based entirely on the `description` field. Descriptions that are
|
|
21
|
+
too long, redundant, or badly structured waste context tokens and reduce routing precision.
|
|
22
|
+
A well-optimized description:
|
|
23
|
+
- States what the tool does and when to use it upfront
|
|
24
|
+
- Eliminates redundancy (same info repeated across sections)
|
|
25
|
+
- Uses a compact, scannable format (labeled blocks, not nested markdown)
|
|
26
|
+
- Includes clear negative examples to prevent mis-routing
|
|
27
|
+
- Keeps parameters terse — name, type, default, one-line purpose
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Optimization Process
|
|
32
|
+
|
|
33
|
+
### Step 1 — Analyze the input description
|
|
34
|
+
|
|
35
|
+
Before rewriting, identify these problems in the original:
|
|
36
|
+
|
|
37
|
+
| Problem | Example |
|
|
38
|
+
|---|---|
|
|
39
|
+
| **Redundancy** | Trigger phrases listed in 3+ places |
|
|
40
|
+
| **Filler sections** | "Rationale", "Behavior Summary", "Response Contract" with no routing signal |
|
|
41
|
+
| **Orphaned syntax** | Arrows (`→`) or bullets with no target |
|
|
42
|
+
| **Overlong examples** | Long prose examples when one-liners suffice |
|
|
43
|
+
| **Heavy markdown** | `##` headers for every minor point |
|
|
44
|
+
| **Duplicated parameter docs** | Same param described in both a table and prose |
|
|
45
|
+
|
|
46
|
+
Call out 2–4 of the most impactful issues before writing the new version.
|
|
47
|
+
|
|
48
|
+
### Step 2 — Rewrite using the standard template
|
|
49
|
+
|
|
50
|
+
Use this exact block structure for the output. Omit blocks that don't apply.
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
<tool-name> — <one-line purpose>.
|
|
54
|
+
|
|
55
|
+
USE when: <comma-separated user intents or trigger phrases>
|
|
56
|
+
DO NOT USE for: <comma-separated anti-patterns with → redirect where applicable>
|
|
57
|
+
|
|
58
|
+
PARAMETERS
|
|
59
|
+
- <name>: <type> (default: <val>) — <one-line purpose>
|
|
60
|
+
...
|
|
61
|
+
|
|
62
|
+
ROUTING RULES
|
|
63
|
+
- "<trigger phrase>" → { param: value }
|
|
64
|
+
- "<trigger phrase>" → { param: value }
|
|
65
|
+
- <ambiguous case> → <ask for clarification | default behavior>
|
|
66
|
+
|
|
67
|
+
EXAMPLES
|
|
68
|
+
- "<user utterance>" → { param: value, ... }
|
|
69
|
+
- "<user utterance>" → { param: value, ... }
|
|
70
|
+
|
|
71
|
+
NEGATIVE EXAMPLES (do not route here)
|
|
72
|
+
- "<user utterance>" → <correct tool>
|
|
73
|
+
|
|
74
|
+
PAGINATION (include only if tool is paginated)
|
|
75
|
+
If returned count === limit → hint: next start = start + limit.
|
|
76
|
+
If start > 1 and result empty → note paging may exceed available items.
|
|
77
|
+
|
|
78
|
+
ERRORS
|
|
79
|
+
<One or two lines: return structure, hallucination policy>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Step 3 — Apply these rules consistently
|
|
83
|
+
|
|
84
|
+
**USE/DO NOT USE block**
|
|
85
|
+
- Write as comma-separated inline list, not a bullet list
|
|
86
|
+
- DO NOT USE entries should name the redirect tool in parentheses where known
|
|
87
|
+
|
|
88
|
+
**ROUTING RULES block**
|
|
89
|
+
- One rule per line; quote the trigger phrase; use `→ { }` for param mapping
|
|
90
|
+
- Consolidate synonyms on one line: `"cas libs / cas libraries / in cas" → { server: 'cas' }`
|
|
91
|
+
- List the default/fallback rule last
|
|
92
|
+
|
|
93
|
+
**PARAMETERS block**
|
|
94
|
+
- One line per param: `- name: type (default: val) — purpose`
|
|
95
|
+
- Skip obvious params (e.g. don't explain what `limit` means if it's standard pagination)
|
|
96
|
+
|
|
97
|
+
**EXAMPLES block**
|
|
98
|
+
- Each example fits on one line
|
|
99
|
+
- For "next page" examples, include the prior call's state inline: `"next" (prev: start:1, limit:10) → { start: 11, limit: 10 }`
|
|
100
|
+
|
|
101
|
+
**NEGATIVE EXAMPLES block**
|
|
102
|
+
- Only include when mis-routing is a real risk
|
|
103
|
+
- Format: `"<utterance>" → <correct-tool-name>`
|
|
104
|
+
|
|
105
|
+
**Tone**
|
|
106
|
+
- Imperative, terse. No filler words ("Please note that...", "It is important to...")
|
|
107
|
+
- Never include a "Rationale" or "Behavior Summary" section — if behavior matters, encode it as a rule
|
|
108
|
+
|
|
109
|
+
### Step 4 — Validate before returning
|
|
110
|
+
|
|
111
|
+
Check the rewritten description against this list:
|
|
112
|
+
|
|
113
|
+
- [ ] No trigger phrase appears in more than one block
|
|
114
|
+
- [ ] No orphaned `→` arrows or dangling bullets
|
|
115
|
+
- [ ] Parameter defaults are stated explicitly
|
|
116
|
+
- [ ] Negative examples cover the tool's most common mis-routing risks
|
|
117
|
+
- [ ] Total length is ≤ 50% of the original (target: 30–40% reduction)
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Output format
|
|
122
|
+
|
|
123
|
+
Always return:
|
|
124
|
+
|
|
125
|
+
1. **Analysis** — 2–4 bullet points naming the key issues found in the original
|
|
126
|
+
2. **Rewritten description** — inside a JavaScript code block (matching the user's original code style)
|
|
127
|
+
3. **Change summary** — a short table or bullet list of what changed and why
|
|
128
|
+
|
|
129
|
+
See `references/examples.md` for before/after examples of real tool descriptions.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Before / After Examples
|
|
2
|
+
|
|
3
|
+
## Example 1 — list-libraries (SAS Viya MCP)
|
|
4
|
+
|
|
5
|
+
### BEFORE (~620 tokens)
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
## list-libraries — enumerate CAS or SAS libraries
|
|
9
|
+
|
|
10
|
+
LLM Invocation Guidance (critical)
|
|
11
|
+
Use THIS tool when the user asks for: "list libs", "list libraries", "show cas libs", "show sas libs",
|
|
12
|
+
"what libraries are available", "list caslib(s)", "enumerate libraries", "libraries in cas", "libraries in sas".
|
|
13
|
+
DO NOT use this tool when the user asks for: tables inside a specific library (choose listTables),
|
|
14
|
+
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
|
+
- "all libs" / "all libs" -> {server: 'all'}
|
|
20
|
+
→ { server: 'all' }
|
|
21
|
+
- "next" (after prior call) → { start: previous.start + previous.limit }
|
|
22
|
+
- "first 20 cas libs" → { server: 'cas', limit: 20 }
|
|
23
|
+
- If server unspecified: default to all.
|
|
24
|
+
|
|
25
|
+
Parameters
|
|
26
|
+
- server (cas|sas|all, default 'all')
|
|
27
|
+
- limit (integer > 0, default 10)
|
|
28
|
+
- start (1-based offset, default 1)
|
|
29
|
+
- where (optional filter expression, default '')
|
|
30
|
+
|
|
31
|
+
Response Contract
|
|
32
|
+
Return JSON-like structure from helper; consumers may extract an array of library objects/names.
|
|
33
|
+
If number of returned items === limit supply a pagination hint: start = start + limit.
|
|
34
|
+
|
|
35
|
+
Behavior Summary
|
|
36
|
+
- Pure listing; no side effects.
|
|
37
|
+
- If ambiguous short request like "list" or "libs" and no prior context: assume { server: 'cas' }.
|
|
38
|
+
- If user explicitly asks for ALL (e.g. "all cas libs") and count likely large, honor limit=50 unless
|
|
39
|
+
user supplies a value; include note about paging.
|
|
40
|
+
|
|
41
|
+
Disambiguation Rules
|
|
42
|
+
- If user mentions a singular library name plus desire for tables ("list tables in SASHELP") choose
|
|
43
|
+
listTables (not this tool).
|
|
44
|
+
- If user mixes "tables" and "libraries" ask for clarification unless clearly about libraries.
|
|
45
|
+
|
|
46
|
+
Examples
|
|
47
|
+
- "list libraries" → { server: 'all', start:1, limit:10 }
|
|
48
|
+
- "list libs" → { server: 'all', start:1, limit:10 }
|
|
49
|
+
- "list sas libs" → { server: 'sas' }
|
|
50
|
+
- "list cas libraries" → { server: 'cas' }
|
|
51
|
+
- "show me 25 cas libraries" → { server:'cas', limit:25 }
|
|
52
|
+
- "next" (after prior call {start:1,limit:10}) → { start:11, limit:10 }
|
|
53
|
+
- "filter cas libs" (no criterion) → ask: "Provide a filter or continue without one?"
|
|
54
|
+
|
|
55
|
+
Negative Examples (do not route here)
|
|
56
|
+
- "list tables in public" (route to list-tables)
|
|
57
|
+
- "list models, list tables, list jobs, list jobdef and similar request"
|
|
58
|
+
- "describe library" (likely list-tables or table-info depending on follow-up)
|
|
59
|
+
- "run program to make a lib" (run-sas-program tool)
|
|
60
|
+
|
|
61
|
+
Error Handling
|
|
62
|
+
- On backend error: return structured error with message field; do not hallucinate libraries.
|
|
63
|
+
- Empty result set → return empty list plus (if start>1) a hint that paging may have exceeded available items.
|
|
64
|
+
|
|
65
|
+
Rationale
|
|
66
|
+
Concise, signal-rich description increases probability this spec is selected for generic library
|
|
67
|
+
enumeration intents.
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### AFTER (~210 tokens)
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
list-libraries — enumerate CAS or SAS libraries.
|
|
74
|
+
|
|
75
|
+
USE when: list/show/enumerate libraries, caslibs, sas libs, available libraries
|
|
76
|
+
DO NOT USE for: listing tables in a library (→ list-tables), column/table metadata, job execution, models, scoring
|
|
77
|
+
|
|
78
|
+
PARAMETERS
|
|
79
|
+
- server: 'cas' | 'sas' | 'all' (default: 'all')
|
|
80
|
+
- limit: integer > 0 (default: 10)
|
|
81
|
+
- start: 1-based offset (default: 1)
|
|
82
|
+
- where: optional filter expression (default: '')
|
|
83
|
+
|
|
84
|
+
ROUTING RULES
|
|
85
|
+
- "cas libs / cas libraries / in cas" → { server: 'cas' }
|
|
86
|
+
- "sas libs / sas libraries / in sas" → { server: 'sas' }
|
|
87
|
+
- "all libs / all libraries" → { server: 'all' }
|
|
88
|
+
- "all cas libs" with no limit given → { server: 'cas', limit: 50 } + paging note
|
|
89
|
+
- "next" after prior call (start:S, limit:L) → { start: S + L, limit: L }
|
|
90
|
+
- "filter cas libs" with no filter given → ask: "What filter expression should I apply?"
|
|
91
|
+
- server unspecified / ambiguous "list"/"libs" → { server: 'cas' }
|
|
92
|
+
|
|
93
|
+
EXAMPLES
|
|
94
|
+
- "list libraries" → { server: 'all', start: 1, limit: 10 }
|
|
95
|
+
- "list cas libraries" → { server: 'cas', start: 1, limit: 10 }
|
|
96
|
+
- "show me 25 sas libs" → { server: 'sas', limit: 25, start: 1 }
|
|
97
|
+
- "next" (prev: start:1,limit:10) → { server: <same>, start: 11, limit: 10 }
|
|
98
|
+
|
|
99
|
+
NEGATIVE EXAMPLES (do not route here)
|
|
100
|
+
- "list tables in SASHELP" → list-tables
|
|
101
|
+
- "list models / jobs / jobdefs" → respective tools
|
|
102
|
+
- "run a program to create a lib" → run-sas-program
|
|
103
|
+
|
|
104
|
+
PAGINATION
|
|
105
|
+
If returned count === limit → hint: next start = start + limit.
|
|
106
|
+
If start > 1 and result empty → note paging may exceed available items.
|
|
107
|
+
|
|
108
|
+
ERRORS
|
|
109
|
+
Return structured error with message field. Never hallucinate library names.
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Token reduction: ~66%**
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Key patterns illustrated
|
|
117
|
+
|
|
118
|
+
- Trigger phrases consolidated from 3 blocks → 1 ROUTING RULES block
|
|
119
|
+
- "Rationale", "Behavior Summary", "Response Contract" sections eliminated
|
|
120
|
+
- Orphaned `→ { server: 'all' }` arrow removed
|
|
121
|
+
- Parameter defaults made explicit inline
|
|
122
|
+
- Examples trimmed to one line each
|
|
123
|
+
- Negative examples now name the redirect tool explicitly
|