BookmarkSubscribeRSS Feed

A ModelContextProtocol Server(mcp) for Scoring with SAS Viya

Started ‎07-08-2025 by
Modified ‎07-08-2025 by
Views 751

 

If you are a SAS programmer who wants to part of the agentic-ai world this article is for you.

 

MCP servers based on the Model Context Protocol (MCP) from Anthropic is one of the popular additions to the agentic-ai world.

  • 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 on any MCP enabled client

The brilliance of MCP is its simplicity.  Since its introduction in November 2024 its adoption has been nothing short of amazing. 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. 

viya-scoring-mcp-server.png


MCP Server in Action


 


MCP server capabilities


 

The MCP server has the following tools for scoring. 

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

Contributors
Version history
Last update:
‎07-08-2025 01:22 PM
Updated by:

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

SAS AI and Machine Learning Courses

The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

Get started

Article Tags