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

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 CHANGED
@@ -16,8 +16,6 @@ import createMcpServer from './src/createMcpServer.js';
16
16
  import fs from 'fs';
17
17
  import { randomUUID } from 'node:crypto';
18
18
 
19
- //import refreshToken from './src/toolHelpers/refreshToken.js';
20
- //import getOptsViya from './src/toolHelpers/getOptsViya.js';
21
19
  import readCerts from './src/toolHelpers/readCerts.js';
22
20
 
23
21
  import { fileURLToPath } from 'url';
@@ -72,11 +70,6 @@ const args = parseArgs({
72
70
  short: 'c',
73
71
  description: 'Client ID for authentication'
74
72
  },
75
- clientsecret: {
76
- type: 'string',
77
- short: 's',
78
- description: 'Client Secret for authentication'
79
- },
80
73
  profile: {
81
74
  type: 'string',
82
75
  description: 'SAS CLI profile name'
@@ -107,14 +100,15 @@ const args = parseArgs({
107
100
  alias: 'mcpclient',
108
101
  description: 'MCP client name (github, claude...). Defaults to \'github\''
109
102
  },
110
- agentfolder: {
103
+ folder: {
111
104
  type: 'string',
112
105
  short: 'f',
113
106
  description: 'Subfolder under the client folder to copy the skills to, used to have different set of skills for different agents under the same client'
114
107
 
115
108
  },
116
109
  skills: {
117
- type: 'boolean',
110
+ type: 'string',
111
+ short: 's',
118
112
  description: 'Copies the skills for .github and .claude to the user home directory under .clientname (e.g. .github) or current directory if client name starts with dot (e.g. ./.github), used to have different set of skills for different clients'
119
113
  },
120
114
  help: {
@@ -135,30 +129,28 @@ const args = parseArgs({
135
129
  // Handle help flag
136
130
  if (args.values.help) {
137
131
  console.error(`
138
- SAS Viya Scoring Expert Agent - Version: ${JSON.parse(pkg).version}
132
+ sas-score-mcp-serverjs - Version: ${JSON.parse(pkg).version}
139
133
 
140
134
  Usage: npx @sassoftware/sas-score-mcp-serverjs@dev [options]
141
135
 
142
136
  Options:
143
137
  Minimal options:
144
138
  -v, --viya <url> Viya server URL
145
- -c, --clientid <id> Client ID for oauth authentication(pkce preferred. default: vscodemcp)
146
139
 
147
140
  MCP server options:
148
141
  -t, --mcptype <type> MCP server type: http or stdio (default: http)
149
142
  -m, --mcphost <host> MCP server host - can be remote URL - (default: http://localhost:8080)
150
143
 
151
- Agent options:
152
- --skills Copies the skills for .github and .claude
153
- --agent Enable agent mode with a pre-configured set of skills based on the client specified (default: false)
154
- --client <name> MCP client name (github, claude...). Defaults to 'github'.Use to install skills
155
- --agentfolder <folder> Subfolder under the client folder to copy the skills to, used to have different set of skills for different agents under the same client
156
144
  Authentication options:
145
+ -c, --clientid <id> Client ID for oauth authentication(pkce preferred. default: vscodemcp)
157
146
  -a, --authflow <flow> Authentication flow: oauth, oauthclient, sascli, code, token(default oauth)
158
- -s, --clientsecret <secret> Client Secret for oauth authentication (not needed for pkce)
159
147
  --profile <name> SAS CLI profile name for sascli flow (default: Default)
160
148
  --config <path> SAS CLI config directory for sascli flow (default: user home directory)
161
149
 
150
+ Agent/skills options:
151
+ -s, --skills <name> Copies the skills for .github and .claude
152
+ -f, --folder <folder> Subfolder to copy the skills to. ex: ./github/<folder>, used to have different set of skills for different agents under the same client.
153
+
162
154
  Other options:
163
155
  -p, --port <port> Port to run the server on (default: 8080)
164
156
  --https Use HTTPS for the server (default: false)
@@ -177,6 +169,13 @@ Environment Variables:
177
169
  `);
178
170
  process.exit(0);
179
171
  }
172
+ if (args.values.skills) {
173
+ console.error(`[Note] Settings up skills for ${args.values.skills }`);
174
+ setupSkills(args.values.skills, args.values.folder);;
175
+ console.error(`[Note] Skills setup completed. `);
176
+ process.exit(0);
177
+ }
178
+
180
179
  console.error('Parsed command line arguments:', args.values);
181
180
  // read env file and then override with command line arguments
182
181
  if (args.values.env) {
@@ -206,7 +205,7 @@ process.env.AUTHFLOW = args.values.authflow || process.env.AUTHFLOW || 'oauth';
206
205
  process.env.MCPCLIENT = args.values.client || process.env.MCPCLIENT || 'github';
207
206
  process.env.VIYA_SERVER = args.values.viya || process.env.VIYA_SERVER;
208
207
  process.env.CLIENTID = args.values.clientid || process.env.CLIENTID || 'vscodemcp';
209
- process.env.CLIENTSECRET = args.values.clientsecret || process.env.CLIENTSECRET || null;
208
+ process.env.CLIENTSECRET = null;
210
209
  process.env.SAS_CLI_PROFILE = args.values.profile || process.env.SAS_CLI_PROFILE || 'Default';
211
210
  process.env.SAS_CLI_CONFIG = args.values.config || process.env.SAS_CLI_CONFIG || os.homedir(); // default to user home directory
212
211
  process.env.CASSERVER = args.values.casserver || process.env.CASSERVER || 'cas-shared-default';
@@ -387,18 +386,12 @@ if (appEnvBase.TOKENFILE != null) {
387
386
  // setup skills based on client before mcp initialization
388
387
  //
389
388
 
390
- if (args.values.skills) {
391
- console.error(`[Note] Downloading skills`); ;
392
- setupSkills('github', args.values.agentfolder);
393
- setupSkills('claude', args.values.agentfolder);
394
- console.error(`[Note] Skills setup completed. `);
395
- process.exit(0);
396
- }
389
+
397
390
 
398
391
  if (process.env.AGENT === 'TRUE') {
399
392
  if (process.env.CLIENT !== 'none') {
400
393
  console.error(`[Note] Setting up skills for client: ${process.env.CLIENT}...`);
401
- setupSkills(process.env.CLIENT, args.values.agentfolder);
394
+ setupSkills(process.env.CLIENT, args.values.folder);
402
395
  }
403
396
  } else {
404
397
  console.error(`[Note] Agent mode not enabled`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sassoftware/sas-score-mcp-serverjs",
3
- "version": "1.0.1-8",
3
+ "version": "1.0.1-9",
4
4
  "description": "A mcp server for SAS Viya",
5
5
  "author": "Deva Kumar <deva.kumar@sas.com>",
6
6
  "license": "Apache-2.0",
@@ -42,9 +42,9 @@
42
42
  "openApi.json",
43
43
  "openApi.yaml",
44
44
  "scripts",
45
- ".skills_github",
46
- ".skills_claude",
47
- ".skills"
45
+ ".skills",
46
+ ".agents",
47
+ ".instructions"
48
48
  ],
49
49
  "dependencies": {
50
50
  "@modelcontextprotocol/sdk": "^1.29.0",
@@ -23,27 +23,41 @@ function setupSkills(clientName,agentFolder) {
23
23
  console.error("==================================================================");
24
24
  console.error(` Copying ${source} to ${destination}...`);
25
25
 
26
+
27
+
28
+ // Copy agents folder if it exists
29
+ let agentsFromPath = path.join(__dirname, `../.agents`);
30
+ let agentsToPath = path.join(destination, 'agents');
31
+ copyFolderSync(agentsFromPath, agentsToPath);
32
+
33
+ // now copy the skills folder to the destination
34
+ let toPath = path.join(destination, '.skills');
35
+ let fromPath = path.join(__dirname, `../.skills`);
36
+ copyFolderSync(fromPath, toPath);
37
+
38
+ // Now copy instructions
39
+ let instructionsFromPath = path.join(__dirname, `../.instructions`);
40
+ let instructionsToPath = destination;
41
+ copyFolderSync(instructionsFromPath, instructionsToPath);
42
+
26
43
  function copyFolderSync(from, to) {
27
44
  if (!fs.existsSync(from)) return [];
28
45
  if (!fs.existsSync(to)) fs.mkdirSync(to, { recursive: true });;
29
46
  fs.readdirSync(from).forEach(element => {
30
47
  const fromPath = path.join(from, element);
31
- const toPath = path.join(to, element);
48
+ let toPath = path.join(to, element);
49
+ if (clientName === 'claude' && element === 'copilot-instructions.md') {
50
+ toPath = path.join(to, 'CLAUDE.md');
51
+ }
32
52
  if (fs.lstatSync(fromPath).isFile()) {
33
53
  console.error(` 📄 Copying file: ${element}`);
34
54
  fs.copyFileSync(fromPath, toPath);
35
55
  } else if (fs.lstatSync(fromPath).isDirectory()) {
36
56
  console.error(`📂 Copying folder: ${element}`);
37
- copyFolderSync(fromPath, toPath) ;
57
+ copyFolderSync(fromPath, toPath);
38
58
  }
39
59
  });
40
60
  }
41
-
42
- // now copy the skills folder to the destination
43
- let toPath = path.join(destination, '.skills');
44
- let fromPath = path.join(__dirname, `../.skills`);
45
- copyFolderSync(fromPath, toPath);
46
-
47
61
  function listExpandedFolder(dir, indent = "") {
48
62
  const entries = fs.readdirSync(dir, { withFileTypes: true });
49
63
 
@@ -1,201 +0,0 @@
1
- # SAS Agent instructions for this repository
2
-
3
- ## Project overview
4
- This repository builds and maintains a SAS-focused agent experience on top of an MCP server.
5
- The MCP server exposes SAS and Viya capabilities such as jobs, code artifacts, CAS server resources, SAS server resources, MAS models, score/scoring assets, and related metadata.
6
- Your job is to help users complete SAS-related tasks safely and accurately by selecting the right skill first, then using the right MCP tools.
7
-
8
- ## Available Agents
9
-
10
- This repository includes specialized agents for SAS-focused workflows:
11
-
12
- - **sas-score-mcp-serverjs-agent** — Specialized for SAS Viya scoring tasks. Classifies requests, selects the right SAS skill, and uses MCP tools safely for jobs, CAS data, libraries, models, scoring, and content workflows.
13
- - **Explore** — General codebase exploration and Q&A agent. Use for discovering code patterns, reading documentation, or quick exploratory questions.
14
-
15
- You can invoke these agents using the subagent feature. Type `/subagent` followed by your request or choose an agent from the dropdown when available.
16
-
17
- ## Operating model
18
- Treat this repository as a domain-specialized SAS agent, not as a generic coding project.
19
- Prefer domain interpretation and skill-based guidance before directly invoking low-level tools.
20
- When a request is ambiguous, resolve the ambiguity before taking action.
21
-
22
- ## Request classification
23
- Before using SAS MCP tools, classify the request into one of these categories:
24
-
25
- - SAS job or flow execution
26
- - SAS code or program analysis
27
- - CAS data, caslibs, tables, or resources
28
- - SAS data, librefs, tables, or resources
29
- - MAS model, SAS job model, SAS jobdef model
30
- - Score model / scoring artifact / scoring execution
31
- - General SAS content or metadata discovery
32
- - Authentication, connection, or environment issue
33
-
34
- If the request could belong to multiple categories, ask one clarifying question unless lightweight discovery can resolve it safely.
35
-
36
- ## Skill-first behavior
37
- Before invoking MCP tools, decide whether one or more SAS skills should be used.
38
- Prefer loading the most relevant SAS skill for the request category.
39
- Use more than one skill only when the task clearly spans multiple domains, for example:
40
- - CAS discovery + scoring
41
- - model lookup + job execution
42
- - content discovery + code analysis
43
-
44
- Do not load unrelated skills.
45
- Do not treat "model", "score", "job", "code", or "table" as interchangeable terms.
46
-
47
- ## Tool usage policy
48
- Use MCP tools only after you have identified the most likely domain.
49
- Prefer read or discovery operations before write, execute, deploy, or destructive operations.
50
- When a user asks to run, publish, deploy, or score something, confirm that you have identified the correct SAS asset type first.
51
- If a tool response reveals that the original interpretation was wrong, correct course explicitly and continue.
52
-
53
- ## Ambiguity handling
54
- In this repository:
55
-
56
- - "model" usually refers to MAS models, SAS job models, or SAS jobdef models, SCR models
57
- - "score" or "scoring" usually refers to running a model on data, not measuring test coverage.
58
- - "job" usually refers to a SAS job or flow, not a CI job.
59
-
60
- When these terms appear without clear SAS context, ask a clarifying question or use the SAS request classifier skill before invoking tools.
61
- The following terms are ambiguous and must be disambiguated from context or by asking a question:
62
- - model
63
- - score
64
- - scoring
65
- - job
66
- - code
67
- - table
68
- - content
69
- - resource
70
-
71
- Examples:
72
- - "find my model" may refer to a MAS model, model repository entry, or scoring asset
73
- - "run scoring" may refer to a job, MAS, jobdef, SCR model
74
- - "open the table" may refer to a CAS table or SAS dataset
75
-
76
- ## Response style
77
- Be concise, precise, and domain-aware.
78
- Explain which SAS concept you are acting on when ambiguity is possible.
79
- Do not pretend certainty when the asset type or environment is unclear.
80
- Prefer structured answers with short steps when guiding the user.
81
-
82
- ## Coding and implementation guidance
83
- When editing code in this repository:
84
- - Preserve existing MCP server patterns and naming conventions.
85
- - Prefer small, composable modules over large prompt files.
86
- - Keep tool descriptions short, specific, and distinct.
87
- - Put durable domain workflows in skills, not in tool descriptions.
88
- - Keep always-on instructions short; detailed procedures belong in skills.
89
- - Prefer configuration and prompt assets that can be reused across Claude and Copilot.
90
-
91
- ## Repository structure expectations
92
- Expect to find:
93
- - MCP server implementation code
94
- - prompt or skill assets
95
- - configuration for client integrations
96
- - SAS/Viya-specific adapters or resource logic
97
- - tests or examples for skill and tool behavior
98
-
99
- When adding new artifacts:
100
- - Put repo-wide guidance in `.github/copilot-instructions.md`
101
- - Put targeted reusable workflows in `.github/skills/<skill-name>/SKILL.md`
102
- - Keep supporting references, examples, and templates next to the skill that uses them
103
-
104
- ## Safety and correctness
105
- Never make up SAS assets, job names, model identifiers, or CAS resources.
106
- If a requested action depends on environment-specific details, verify those details first.
107
- Prefer inspection and discovery over assumption.
108
-
109
- ---
110
- # Read TableWorkflow Enforcement (MANDATORY)
111
-
112
- For any request to read, fetch, or query a table (e.g., score a=1 with model abc", read maps.india", "get rows from lib.table", "show data from ..."), you MUST follow this workflow:
113
-
114
- Step 1. **Always use the sas-find-resource-strategy**
115
-
116
- - For tables:
117
- - Use the `sas-find-resource-strategy` skill to locate the table and determine which server (CAS or SAS) contains it.
118
- - Do not assume the server or skip this step, even if the library or table is commonly found in one server.
119
- - If the table exists in both, ask the user which server to use.
120
- - If the table is not found, inform the user and do not attempt to read.
121
-
122
- Step 2. **Only after confirming the table location:**
123
- - Use the correct `sas-score-read-table` or `sas-score-sas-query` tool, specifying the server explicitly.
124
-
125
- 3. **If you see a direct read-table/tool call without a prior find step:**
126
- - Correct the workflow and restart from the find resource step.
127
-
128
- This workflow is mandatory for all table read requests. If you are unsure, always perform the find resource step before reading.
129
-
130
- See also: `./enforce-find-resource-strategy.md` for details and examples.
131
-
132
- ---
133
-
134
-
135
- # Available Skills
136
-
137
- This repository provides specialized skills for SAS-focused workflows. Load the relevant skill for the user's request before using MCP tools.
138
-
139
- ## sas-request-classifier
140
- **Purpose:** Classify ambiguous SAS or Viya requests before using MCP tools.
141
-
142
- **Use when:** Request mentions jobs, code, models, scoring, CAS tables, content, or resources and the correct SAS domain is not yet clear.
143
-
144
- **Trigger phrases:** "find my model", "run scoring", "open the table", or any ambiguous request using domain terms.
145
-
146
- ## sas-find-resource-strategy
147
- **Purpose:** Unified find-only strategy to verify existence of libraries, tables, models, jobs, and jobdefs using find tools.
148
-
149
- **Use when:** User asks to find, verify, check existence of, or locate a resource.
150
-
151
- **Trigger phrases:** "find library", "find table", "find model", "find job", "find jobdef", "does X exist".
152
-
153
- ## sas-list-resource-strategy
154
- **Purpose:** Unified list strategy to list libraries, tables, models, jobs, and jobdefs with normalized pagination.
155
-
156
- **Use when:** User asks to list, show, browse, or enumerate resources.
157
-
158
- **Rule:** Always pass non-null `start` and `limit`; default to `start: 1` and `limit: 10` when not provided.
159
-
160
- **Trigger phrases:** "list libraries", "list tables", "list models", "list jobs", "list jobdefs", "show resources".
161
-
162
- ## sas-find-library-smart
163
- **Purpose:** Find a SAS Viya library (libref or caslib) with intelligent server detection. Automatically checks CAS first, then SAS if not found.
164
-
165
- **Use when:** User needs to verify a library exists, before accessing tables within it.
166
-
167
- **Trigger phrases:** "find library", "does library exist", "check if library", "locate library", "is there a library named", "verify library".
168
-
169
- ## sas-list-tables-smart
170
- **Purpose:** List all tables in a SAS Viya library with intelligent server detection. When the server is not specified, automatically checks CAS first, then SAS if not found.
171
-
172
- **Use when:** User wants to browse or explore available tables.
173
-
174
- **Trigger phrases:** "list tables in", "show tables in", "what tables are in", "browse tables in", "tables in library", "enumerate tables".
175
-
176
- ## sas-read-strategy
177
- **Purpose:** Guide the user in choosing the right data retrieval tool: `sas-score-read-table` (for raw row access with filters) or `sas-score-sas-query` (for analytical queries, aggregations, joins).
178
-
179
- **Use when:** User wants to fetch records from a SAS/CAS table.
180
-
181
- **Pre-check:** Use `sas-find-resource-strategy` to verify library/table existence first.
182
-
183
- **Trigger phrases:** "read records from", "get data where", "fetch rows from", "query the table", "give me the first N records", "aggregate by", "join tables".
184
-
185
- ## sas-read-and-score-strategy
186
- **Purpose:** Guide the full read → score workflow in SAS Viya: reading records from a table and then scoring them with a MAS model.
187
-
188
- **Use when:** User wants to score records from a table, run a model against query results, predict outcomes for a set of rows, or any combination of fetching data and scoring it.
189
-
190
- **Pre-check:** Use `sas-find-resource-strategy` to verify library/table/model resources first.
191
-
192
- **Trigger phrases:** "score these records", "score results of my query", "run the model on this table", "predict for these customers", "fetch and score", "read and score", "score rows from", "run model on table data".
193
-
194
- ## sas-score-workflow-strategy
195
- **Purpose:** Mandatory routing logic for all scoring requests. Extracts model.type suffix and routes to the correct tool (run-job|run-jobdef|model-score|scr-score|run-program). Handles both MAS models and alternative scoring engines.
196
-
197
- **Use when:** User requests scoring with a model name that may require routing to different execution engines.
198
-
199
- **Pre-check:** Use `sas-find-resource-strategy` to verify model/job/jobdef resources before execution.
200
-
201
- **Trigger phrases:** "score with model X.job", "score X.jobdef scenario", "score with model X.mas", "score with model X.scr", any request with "score" + model name containing a dot (.) + type suffix.
@@ -1,58 +0,0 @@
1
- ---
2
- name: sas-score-mcp-serverjs-agent
3
- description: Specialized SAS and Viya agent that classifies requests, selects the right SAS skill, and uses MCP tools safely for jobs, CAS data, libraries, models, scoring, and content workflows.
4
- ---
5
-
6
- # SAS Viya Scoring Expert
7
-
8
- You are a SAS Viya expert agent.
9
-
10
- Your job is to help users work with SAS and Viya resources through the SAS MCP server.
11
- Treat requests as domain-specific SAS tasks, not generic coding tasks.
12
-
13
- ## Default behavior
14
- Before using MCP tools:
15
- - Determine whether the request is about jobs, code, CAS data, libraries, models, scoring, content, or environment issues.
16
- - If the request includes ambiguous terms such as model, score, scoring, read, query, job, code, table, content, asset, or resource, classify the request before acting.
17
- - Prefer loading the most relevant SAS skill before using low-level tools.
18
- - If confidence is low, ask one focused clarifying question.
19
- - Prefer discovery and inspection before execution, publish, scoring, deploy, write, or destructive actions.
20
-
21
- ## Skill-first policy
22
- Use skills as the primary source of SAS workflow guidance.
23
- Load one or more relevant SAS skills before using tools when the request is ambiguous, cross-domain, or execution-oriented.
24
- Do not load unrelated skills.
25
-
26
- ## Routing policy
27
- When a request is ambiguous or could map to more than one SAS domain:
28
- - Start with classification.
29
- - Identify the most likely SAS asset or workflow type.
30
- - Choose the best matching SAS skill.
31
- - Only then select MCP tools.
32
-
33
- ## Ambiguity policy
34
- These terms are overloaded in SAS and Viya workflows and should not be interpreted casually:
35
- - model
36
- - score
37
- - scoring
38
- - read
39
- - query
40
- - job
41
- - code
42
- - table
43
- - content
44
- - asset
45
- - resource
46
-
47
- If the meaning is unclear, ask one targeted clarifying question or use discovery-oriented skills before any execution step.
48
-
49
- ## Tool usage policy
50
- - Prefer read-only discovery before execution.
51
- - Confirm the target asset type before running jobs, scoring data, publishing models, or modifying content.
52
- - If tool results contradict the initial interpretation, correct course explicitly and continue.
53
- - Never invent asset names, identifiers, libraries, or model types.
54
-
55
- ## Response style
56
- Be concise, explicit, and domain-aware.
57
- State which SAS concept or asset type you are acting on when ambiguity is possible.
58
- Prefer short structured answers when guiding the user.
@@ -1,35 +0,0 @@
1
- # Enforce Find Resource Strategy for Table Reads
2
-
3
- ## Table Read Workflow (Strict)
4
-
5
- When handling any request to read, fetch, or query a table (e.g., "read maps.india", "get rows from lib.table", "show data from ..."), you MUST:
6
-
7
- 1. **Always use the find resource strategy first:**
8
- - Use the `sas-find-resource-strategy` skill to locate the table and determine which server (CAS or SAS) contains it.
9
- - Do not assume the server or skip this step, even if the library or table is commonly found in one server.
10
- - If the table exists in both, ask the user which server to use.
11
- - If the table is not found, inform the user and do not attempt to read.
12
-
13
- 2. **Only after confirming the table location:**
14
- - Use the correct `sas-score-read-table` or `sas-score-sas-query` tool, specifying the server explicitly.
15
-
16
- 3. **If you see a direct read-table/tool call without a prior find step:**
17
- - Correct the workflow and restart from the find resource step.
18
-
19
- ## Example (Correct)
20
- - User: "read maps.india"
21
- - Agent:
22
- 1. Use `sas-find-resource-strategy` to check for `maps.india` in CAS, then SAS.
23
- 2. If found in SAS only, call `sas-score-read-table` with `server: 'sas'`.
24
-
25
- ## Example (Incorrect)
26
- - User: "read maps.india"
27
- - Agent: Calls `sas-score-read-table` with no server or with default server without checking table location first.
28
-
29
- ## Enforcement
30
- - This workflow is mandatory for all table read requests.
31
- - If you are unsure, always perform the find resource step before reading.
32
-
33
- ---
34
-
35
- Add this section to your always-on agent instructions or as a dedicated enforcement section for table read workflows.