@sassoftware/mcp-serverjs
Version:
A mcp server for SAS Viya
111 lines (68 loc) • 4.23 kB
HTML
MCP servers based on the Model Context Protocol (MCP) from Anthropic is one of the popular additions to the agentic-ai world. Its brilliance is its simplicity.
Users can mix and match capabilities supplied by multiple vendors from the comfort of a client like GitHub Copilot
Experts can build mcp servers that is guaranteed to work any mcp enabled client
There is a growing collection of mcp servers and mcp clients. You can find many of them listed here.
So what does this mean for SAS developers and users?
SAS developers create models using products like Model Studio and by writing custom SAS code that takes macro variables as input. Typically this is followed by developing some UI for the end users to access these models. The mcp server approach provides a nice alternative to deliver these models to the user.
Terminology:
In the rest of this article, "model" refers to all of these:
Models created with SAS solutions like Model Studio, Intelligent Decisioning etc...
User written SAS programs
Functions that call any SAS products using REST API
Details on the scoring mcp server
This article describes the viya-scoring-mcp-server to score models described above. The source code is this repository It is provided under the Apache-2.0 license.
This diagram shows the flow from a user prompt to the final response.
mcp Server in Action
,,,, insert video here
mcp server capabilities
The mcp server has the following tools for scoring. The LLM decides which tool to call based on the user prompt.
Simple tool
devascore - calculates a special score given two numbers. This is useful for verifying that the server is functioning. Also an easy to follow example of a tool
Data related tools
findLibrary - check if specified library exists
listLibrary - list available libraries in cas or sas
findTable - check if specified table exists in specified library in cas or sas
listTables - list tables in a specified library in cas or sas
readTable - read records from a cas or sas table
Scoring with Models in MAS
findModel - check if specified model exists in MAS server
listModels - list models published to MAS
modelInfo - display the input and output variables for a specified model
modelScore - score using the selected model
Scoring with SCR
scrInfo - display the input and output variables for a specified SCR instance
scrScore - score using the specified SCR instance
Scoring with SAS code
superstat - an example of accessing custom SAS code
Using the default mcp server
Follow these basic steps
Step 1: Start the mcp server
Issue this command from any shell on your desktop
npx @sassoftware/mcp-serverjs@latest
Make sure that you have a node version >=22
Step 2: Enable github copilot for the mcp server
Similar methodologies can be used with other mcp enabled copilots.
Go to the vscode settings and search for mcp. Then select Model Server Context Protocol. Edit its config json
Add the following to the list of mcp servers
{
"viya-scoring-mcp-server": {
"type": "http",
"url": "http://localhost:8080/mcp"
}
}
The name can be anything you like.
Sidebar: Authentication with your Viya Server
This mcp server cli works similar to SAS supplied sas-viya cli commands. Use the following command to create the necessary token and refresh token. You need to do this once every 90 days or whenever the refresh token expires.
Issue this command and follow instruction: sas-viya profile init
Issue this command and follow the instructions: sas-viya auth loginCode
Issuing prompts
Use the copilot prompt area to issue prompts. Here are some sample prompts
list models
sho
Notes
This demo server is "stateless" - it does not cache any values, including any Viya sessions the tools might have created.
In a production system the designer has to make decisions on what needs to be cached and the implications of such caching.
The implication of this design choice is felt most when the tool needs to create a compute session - the requests will take longer than when the compute session is cached.
Useful links
Documentation on modelcontextprotocol(mcp)
mcp sdk