# SAS Viya MCP Server A Model Context Protocol (MCP) server for executing SAS code, training AutoML projects, scoring models and so much more for SAS Viya environments. ## Features - 140 tools across 12 selectable tiers, spanning the Analytics Life Cycle on SAS Viya - Interactive views (MCP Apps) for data, SAS logs, glossary editing and scoring a decision in clients that render them — Claude, ChatGPT, Microsoft 365 Copilot, VS Code, Cursor - Prompt Templates for improving your SAS Code - OAuth2 authentication with PKCE flow - HTTP-based MCP server compatible with MCP clients ## Articles & Videos Here you can find getting articles on how to use and integrate the SAS MCP Server in different tools and what to build with it: - [From REST APIs to AI Agents: Why the SAS Viya MCP Server Matters](https://communities.sas.com/t5/SAS-Communities-Library/From-REST-APIs-to-AI-Agents-Why-the-SAS-Viya-MCP-Server-Matters/ta-p/992010) - [Connecting GitHub Copilot to SAS Viya with the SAS Viya MCP Server](https://communities.sas.com/t5/SAS-Communities-Library/Connecting-GitHub-Copilot-to-SAS-Viya-with-the-SAS-Viya-MCP/ta-p/987191) - [Bring Your Own Key: SAS Viya MCP Server with GitHub Copilot CLI](https://communities.sas.com/t5/SAS-Communities-Library/Bring-Your-Own-Key-SAS-Viya-MCP-with-GitHub-Copilot-CLI/ta-p/991530) - [Putting the SAS Viya MCP Server to Work in GitHub Copilot](https://communities.sas.com/t5/SAS-Communities-Library/Putting-the-SAS-Viya-MCP-Server-to-Work-in-GitHub-Copilot/ta-p/987193) - [Connecting Claude Code CLI to SAS Viya with the SAS Viya MCP Server](https://communities.sas.com/t5/SAS-Communities-Library/Connecting-Claude-Code-CLI-to-SAS-Viya-with-the-SAS-Viya-MCP/ta-p/988775) - [Putting the SAS Viya MCP Server to Work in Claude Code CLI](https://communities.sas.com/t5/SAS-Communities-Library/Putting-the-SAS-Viya-MCP-Server-to-Work-in-Claude-Code-CLI/ta-p/988922) - [Integration with SAS Retrieval Agent Manager (RAM)](https://github.com/sassoftware/sas-retrieval-agent-manager-examples/tree/main/examples/container_mcp_servers/sas_mcp_server) - [Five Industry Use Cases using the SAS Viya MCP Server as Videos](https://www.youtube.com/playlist?list=PLDjjizeeDc04) ## Getting Started ### Prerequisites - Required - [Python 3.12+](https://www.python.org/downloads) - [uv 0.8+](https://github.com/astral-sh/uv) - [SAS Viya environment](https://www.sas.com/en_us/software/viya.html) with compute service - Which tools work on which Viya release (LTS 2024.09 to Stable 2026.10): see [COMPATIBILITY.md](COMPATIBILITY.md) - Setup the Viya environment for MCP - See [configuration.md](/examples/configuration.md) - Optional - [Docker](https://docs.docker.com/engine/install): refer to [container setup](/deploy/docker.md) - Kubernetes: sample manifests (Contour or nginx) and a Helm chart in [deploy/](/deploy/README.md) ### Installation 1. Clone the repository: ```sh git clone cd sas-mcp-server ``` 2. Install dependencies ```sh uv sync ``` NOTE: This will by default create a virtual environment called .venv in the project's root directory. If for some reason the virtual environment is not created, please run `uv venv` and then re-run `uv sync`. Run `uv sync` again after each `git pull`, with every MCP client that uses this checkout closed. The stdio client configurations below start the server with `uv run --no-sync`, so they never sync `.venv` themselves: on Windows, a sync while another copy of the server is running fails on its locked `.exe` and the server does not start (see [TROUBLESHOOTING.md](TROUBLESHOOTING.md#stdio-server-fails-to-start-with-failed-to-remove-file-venvscriptsapp-stdioexe--os-error-32)). ### Usage 1. Configure environment variables: ```sh cp .env.sample .env ``` Edit `.env` and set ```sh VIYA_ENDPOINT=https://your-viya-server.com ``` To choose the other settings interactively, open the **configuration builder**: online at [sassoftware.github.io/sas-mcp-server](https://sassoftware.github.io/sas-mcp-server/), as [`examples/config-builder.html`](examples/config-builder.html) in a browser from your clone, or at `/mcp/config` on a running HTTP server. It covers every setting the server reads, starts a shared server from safe values, warns about risky combinations, and writes a `.env`, Helm values or an MCP client entry for you to copy. Everything happens in the page: nothing you type is sent anywhere or stored. 2. Start the MCP server (see [Choosing a deployment mode](#choosing-a-deployment-mode) below): **Option A: HTTP mode** (pre-run the server, connect from MCP client) ```sh uv run app ``` The server will be available at `http://localhost:8134/mcp` by default. Authentication is handled via OAuth2 PKCE flow in the browser. **Option B: Stdio mode** (MCP client starts the server on demand) Authenticate once. Two equivalent options: ```sh # Option B1 — if you have the SAS Viya CLI installed: sas-viya auth loginCode # Option B2 — built-in helper, no external CLI needed (Viya 2022.11+): uv run sas-mcp-login ``` Both flows write an access token to a local cache (`~/.sas/credentials.json` and `~/.sas-mcp-server/credentials.json` respectively), and the server refreshes it on its own. Sign in again only when the refresh token has expired too. [Signing in with `sas-mcp-login`](examples/configuration.md#signing-in-with-sas-mcp-login) walks through the login and every option (`--name`, `--list`, `--logout`, the two-step login without a terminal). To use several SAS Viya deployments, configure one stdio server entry per deployment, each with its own `VIYA_ENDPOINT`, and log in to each (`uv run sas-mcp-login --endpoint https://your-viya-server.com`). `sas-mcp-login` stores each token in `~/.sas-mcp-server/credentials.json` under the endpoint it was issued for, so the logins do not overwrite each other, and a server reads only the login stored for its own endpoint. When a server has a login of its own, it uses only that one. Without one it falls back to the `sas-viya` CLI cache and to a `Default` block stored by an earlier version, which carry no endpoint; an untagged `Default` block is used only while the file holds no other endpoint's login. See [examples/configuration.md](examples/configuration.md#several-sas-viya-deployments-stdio). Then configure your MCP client to launch the server directly (see below). **Option C: Docker / Podman** (containerized deployment) Pull the pre-built image from GitHub Container Registry: ```sh docker pull ghcr.io/sassoftware/sas-mcp-server:latest docker run -e VIYA_ENDPOINT=https://your-viya-server.com -p 8134:8134 ghcr.io/sassoftware/sas-mcp-server:latest ``` Or build locally from source: ```sh docker build -t sas-mcp-server . docker run -e VIYA_ENDPOINT=https://your-viya-server.com -p 8134:8134 sas-mcp-server ``` Available image tags: - `latest` — most recent tagged release - `..` (e.g. `1.0.0`) — specific release - `.` (e.g. `1.0`) — latest patch of a minor release - `edge` — tip of `main` (unreleased, for testing) - `sha-` — pinned to a specific commit **Programmatic clients with a pre-existing Viya token** If your caller already holds a Viya access token (e.g. an automation script that obtained one via the SAS Viya CLI), start the HTTP-mode server with `ALLOW_RAW_BEARER=true` and pass the token directly: ```sh curl -H "Authorization: Bearer $VIYA_TOKEN" http://localhost:8134/mcp ... ``` The server validates the token against Viya's JWKS and uses it upstream as-is, bypassing the MCP JWT swap. The default OAuth2 PKCE flow keeps working alongside — both client types share the same `/mcp` endpoint. If your Viya APIs are intentionally exposed without auth (for example, a local/dev Compute API endpoint), set `VIYA_AUTH=false` to bypass all SASLogon/OAuth flows in both HTTP and stdio modes. In this mode the server sends upstream requests without an `Authorization` header. If your compute deployment does not expose `/compute/contexts` and only supports a fixed session, set `COMPUTE_SESSION_ID=`. The compute tools will use that session directly instead of creating context-backed sessions. ### Choosing a deployment mode | | **HTTP** | **Stdio** | **Docker** | **Kubernetes** | |---|---|---|---|---| | **How it runs** | Long-running server you start separately | MCP client spawns it on demand | Containerized HTTP server | Containerized, behind an ingress | | **Authentication** | OAuth2 PKCE flow (browser popup) | Cached token via `sas-viya` CLI or `sas-mcp-login` | OAuth2 PKCE flow (browser popup) | PKCE and/or raw Viya bearer token | | **Best for** | Multi-user or shared setups; production-like environments | Single-user local development; quick experimentation | Team deployments; CI/CD; environments without Python installed | Shared/organisational deployments alongside Viya | | **Requires** | Python + uv | Python + uv (+ optional `sas-viya` CLI) | Docker or Podman only | A cluster, an ingress controller, a TLS secret | | **Credentials stored?** | No — user authenticates interactively | No — only an access token (not a password) is cached | No — user authenticates interactively | No — a signing key in a `Secret`; users authenticate themselves | | **MCP client config** | Point client to `http://localhost:8134/mcp` | Client runs `uv run app-stdio` | Point client to `http://host:8134/mcp` | Point client to `https:///mcp` | **Quick guidance:** - **Starting out or exploring?** Use **stdio** — one `sas-viya auth loginCode` or `uv run sas-mcp-login`, then your MCP client manages the server lifecycle. - **Need secure, interactive auth?** Use **HTTP** — no stored passwords, each user authenticates via browser. - **Deploying for a team or on a server?** Use **Docker** — portable, no Python dependency on the host, easy to integrate with orchestrators. - **Running it for a whole organisation?** Use **Kubernetes** — sample manifests and a Helm chart are in [deploy/](/deploy/README.md), including the routing the OAuth flow needs for either **Contour** (the chart's default, and the only one that can mount the server under a path prefix on an existing hostname) or **ingress-nginx**. - **Your organisation runs Posit Connect?** Deploy it there as MCP content with `deploy/posit-connect/deploy.sh`. Connect handles sign-in and access control, and a Connect OAuth integration for SAS Logon gives each user's tool calls their own Viya identity. See [deploy/POSIT-CONNECT.md](deploy/POSIT-CONNECT.md). - **Using Gemini CLI?** Use **stdio** — Gemini CLI does not support HTTP mode or browser-based OAuth. See [Gemini CLI configuration](examples/configuration.md#gemini-cli). - **Integrating with Microsoft 365 Copilot?** Use **Kubernetes** (or any remote HTTPS deployment) — Copilot declarative agents only reach remotely hosted MCP servers. A ready-to-sideload agent package and walkthrough are in [examples/m365-copilot/](examples/m365-copilot/README.md). - **Adding it to a Microsoft Copilot Studio agent?** Same remote HTTPS deployment, plus `MCP_TOOL_RENAME=catalog_=infocat_` — Copilot Studio's agent runtime fails on tool names that start with `catalog_`. The steps are in [examples/copilot-studio/](examples/copilot-studio/README.md). - **Not sure which Microsoft route fits?** [examples/microsoft-copilot.md](examples/microsoft-copilot.md) compares the declarative agent and the Copilot Studio agent, and shows the settings for one deployment that serves both. - **Installing from a client's server catalogue?** That path runs the published container in **stdio** mode (`app-stdio`), not as an HTTP server, so it authenticates from your `~/.sas` token cache — which has to be mounted into the container at `/app/.sas`. ### Limiting exposed tools (tiers) Tools are grouped into numbered tiers. By default the server exposes all of them; set `MCP_TIERS` to expose only a subset — handy for keeping a client's tool list small and focused, or hiding capabilities a deployment shouldn't offer. Accepts ranges and comma lists (e.g. `MCP_TIERS=0-4` or `MCP_TIERS=0,1,6,7`); unset means all tiers. | Tier | Group | |---|---| | 0 | Compute Contexts & Code Execution | | 1 | Data Discovery | | 2 | Data Operations & Files | | 3 | Reports & Visualization | | 4 | Batch Jobs & Async Execution | | 5 | Automated Machine Learning | | 6 | Model Management & Scoring | | 7 | Decisioning Foundation (SAS Intelligent Decisioning) | | 8 | Workbench (Execute Code Only) | | 9 | Business Glossary (SAS Data Governance) | | 10 | Decisioning Advanced (SAS Intelligent Decisioning) — needs Tier 7 | | 11 | Model Lifecycle (SAS Model Manager) | ```sh # Example: expose only compute/discovery/data-ops and reporting MCP_TIERS=0-3 uv run app ``` ### Read-only mode Set `MCP_READ_ONLY=true` to expose only tools that neither change server-side state nor cause server-side work — 66 of the 140 tools. Withheld tools are never registered, so they are absent from the client's tool list entirely: the model cannot see them, so it cannot attempt them. This is a filter over the tiers, not a tier of its own — the read/write split cuts across every tier (Tier 3 has both `get_report` and `delete_report`). The two settings compose: ```sh # Every read tool, all tiers MCP_READ_ONLY=true uv run app # Read tools of the reporting and decisioning tiers only MCP_TIERS=3,7 MCP_READ_ONLY=true uv run app ``` The definition is strict: a tool qualifies only if it can neither write nor start work. Beyond the obvious create/update/delete tools, that withholds: | Withheld | Why | |---|---| | `execute_sas_code`, `submit_batch_job` | Run arbitrary code — can perform any operation, including deletes | | `score_data`, `catalog_run_agent`, `catalog_run_adhoc_analysis` | Start server-side jobs and leave run records, though they return data | | `promote_table_to_memory` | Mutates CAS in-memory state | | `test_score_model`, `validate_published_model`, `describe_analytic_store` | Run a SAS session or a score job, though they return data and leave nothing behind | | `cancel_job`, `reset_compute_session`, `delete_compute_session` | Destroy something the caller owns | Classification is fail-closed: a tool that is not explicitly classified as read-only is withheld. The list lives in [`src/sas_mcp_server/tools/_access.py`](src/sas_mcp_server/tools/_access.py), and a test asserts it covers every registered tool, so a newly added tool cannot silently land in read-only mode. ### Expected-host check A launcher that runs one server per environment can point it at the wrong one, and a job then runs on a deployment nobody meant to touch. Set `MCP_EXPECT_HOST` to the host the server should reach (`hc-build.example.com`, or a URL). If it does not match the host of `VIYA_ENDPOINT`, every tool that is not read-only returns this instead of running, and asks SAS Viya for nothing: ```json {"status": "refused", "reason": "unexpected_host", "tool": "submit_batch_job", "connected_host": "other.example.com", "expected_host": "hc-build.example.com", "gated_by": "MCP_EXPECT_HOST", "message": "..."} ``` Read tools keep working, so `server_status` and the list and get tools can show what the server is connected to. The check uses the read-only classification above: a tool outside the read-only set is refused. Host names are compared without case, and ports only when the value names one. Unset (the default), nothing is checked. For the check to catch a wrong environment, the launcher has to set the variable from a different source than the one that chose `VIYA_ENDPOINT`, for example from the project's own setting. ### Tool annotations (what clients are told) The same classification is **advertised** to every client as [MCP tool annotations](https://modelcontextprotocol.io/specification/2025-03-26/server/tools#tool-annotations) on each `tools/list` entry — whether or not read-only mode is on: | Hint | Derived from | |---|---| | `readOnlyHint` | exactly the read-only set above — one table, so what a client is told and what `MCP_READ_ONLY` enforces cannot drift | | `destructiveHint` | tools that can remove or overwrite existing state: arbitrary code (`execute_sas_code`, `submit_batch_job`), `delete_*`, `cancel_job`, `reset_compute_session`, `delete_compute_session`, the `update_*` PUTs, `apply_report_operations`, `create_report`/`copy_report` (their `replace` conflict policy), `publish_ml_champion_model`, `register_model`/`publish_model`/`save_castable` (their `replace`), `drop_castable`, `score_table`, `set_project_champion`, `create_performance_definition` (its `replace`), `set_kpi_alert_rule` (updates the rule for the same KPI in place) | | `idempotentHint` | reads, the `update_*` PUTs, deletes, `cancel_job`, `reset_compute_session`, `promote_table_to_memory`, and the tools that report what an earlier call made instead of acting again (`create_folder`, `create_model_project`, `save_castable`, `drop_castable`, `set_project_champion`, `create_performance_definition`, `set_kpi_alert_rule`) | | `openWorldHint` | only tools that can reach beyond Viya: arbitrary code, the upload tools' `url` source, and `publish_model` (Git and container-registry destinations) | Clients use these to shape their approval UX — e.g. Claude groups read-only tools for one-click approval and warns before destructive ones — and to decide when to interrupt the user. They are hints, not enforcement: the spec tells clients to treat them as untrusted unless the server is trusted, and `MCP_READ_ONLY` remains the server-side control. Without annotations a client must assume the spec's pessimistic defaults (writable, destructive, open-world) for every tool, so this only ever reduces friction. The browser landing page marks each tool `read-only` / `write` / `destructive` from the same hints. ### Interactive views (MCP Apps) Some results read badly as text however well the tool shapes them: a hundred rows of a table, a SAS log, a form's worth of typed attributes. Twelve tools therefore also carry a small HTML view, using the [MCP Apps extension](https://modelcontextprotocol.io/extensions/apps/overview), that a supporting client renders in a sandboxed frame beside the result: | View | Tools | What it does | |---|---|---| | Data grid | `query_data`, `get_castable_data`, `get_compute_table_data` | Sort, filter and page through rows. Paging calls the same tool again from the view, so the person can walk a large table while the model holds only the first page. | | SAS log | `execute_sas_code`, `get_job_log`, `submit_batch_job` | Colour-coded `ERROR` / `WARNING` / `NOTE` lines, jump to the next problem, problems-only and hide-notes filters, the listing on its own tab, and SAS's own HTML output on a Results tab (see [HTML results](#html-results)). A submitted batch job is polled from the view until it ends, then its log is fetched. | | Glossary term editor | `get_glossary_term_type`, `get_glossary_term` | A form generated from the term type — a real checkbox for a boolean, a date picker, a multi-select — so attribute values cannot be mistyped. Creates or updates the term and tells the assistant what was saved. A term that is still a draft can be published from here, which is the only way the API allows it. | | Glossary browser | `list_glossary_terms` | The whole glossary as a navigable tree beside a detail pane: search across names, definitions, descriptions and attribute values; filter by term type or "has assets"; breadcrumbs, children cards, attributes, assigned assets, and a sunburst of the hierarchy. The tree pane can be resized by dragging the divider or hidden altogether. The listing's own filters become the starting filters; the rest of the glossary is loaded by the view in pages, so the model still holds only the first page. A draft — invisible to everyone but its author, which is why the tree is where you notice one — can be published from its detail pane. | | Decision scoring | `get_mas_module_step_signature`, `score_data` | A form generated from the published module's inputs, so a person can score one case without spelling out every value in the chat. The result is a card: the outcome highlighted, its reason, the other outputs and the inputs, a link that opens the decision in SAS Intelligent Decisioning when the module was published from one, and, when the deployment turns it on with `MCP_EMAIL_DRAFT` (`outlook` or `mail`), a **Draft email** button that opens a draft of the result in Outlook on the web or the default mail app, for the person to address and send. Nothing is sent from the view. Without it, the card offers Copy summary. When the assistant scores a case itself, the same card shows its result. | | Glossary import | `import_glossary_terms` | With `dry_run=true`, the rows in the order they would be sent, with resolved parent paths and the CSV's own `Definition` and `Description` columns kept apart, and an Import button. After a real import, each row's outcome and the id of the term it became — including whether the term was new or already there, which the import job itself counts as successful either way. | Every view has a ⤢ button that opens it fullscreen where the host offers that (Claude does), which is where a wide table or a long log is meant to be read; the button does not appear on a host without it. Everything about this is additive. The tool's return value is unchanged, so a client without the extension — Claude Code, a script, an older client — sees exactly what it saw before. Every request a view makes travels through the host to this server as an ordinary tool call with the session's token; the browser never talks to Viya, and a tool a deployment withholds through `MCP_TIERS` or `MCP_READ_ONLY` has no view either — nor does any control inside a view that would have called it, so a read-only deployment shows the glossary browser without its Publish button rather than with one that can only fail. The pages are fully inlined — the vendored `@modelcontextprotocol/ext-apps` bridge included — so they render on hosts that ignore CSP declarations and on an air-gapped Viya. `MCP_APPS=false` registers no views. Whether a view is rendered depends on the client and on how it is connected: | Client | Views | |---|---| | ChatGPT, Microsoft 365 Copilot, VS Code with GitHub Copilot, Cursor, Goose | Rendered — these clients implement the extension. | | Claude (web, Desktop, Cowork) connected to the HTTP server as a **custom connector** | Rendered, including the SAS log view's Results tab. The connector speaks the 2026 protocol revision, whose handshake has no session, so the server needs `MCP_STATELESS_HTTP=true` and a URL that Anthropic's servers can reach. | | Claude Desktop with the server in `claude_desktop_config.json` (which accepts stdio servers only) | **Not rendered since Claude Desktop 2.2553 (22 September 2026).** Desktop passes a local server's tools to the chat through a bridge that rebuilds each tool's metadata and drops the view binding, so the chat never asks for the page. The tools work as before; results are text, and `execute_sas_code` still returns its HTML results link. Reported as [anthropics/claude-ai-mcp#1069](https://github.com/anthropics/claude-ai-mcp/issues/1069). | | Microsoft Copilot Studio agents | Not rendered — the agent runtime does not implement the extension (it announces no UI capability and never reads the view). `execute_sas_code` still returns its link to the HTML results. | | Claude Code | Not rendered — text only, by design. | A view's own controls call other tools (the Results tab reads the page through `download_file`, Tier 2), so a deployment that withholds those tiers gets the view without that control. View URIs carry a fingerprint of the page (`ui://sas-viya/sas-log/execute_sas_code..html`) that changes with the server version, the page files and the tier selection, because hosts cache a page by its URI — claude.ai even across a connector being removed and added again; the plain URI is served too, for hosts holding an older tool listing. ### HTML results `execute_sas_code` returns the SAS log and listing as text, which is what the model reads. By default it also produces the page SAS Data and AI Studio would show, with tables styled by ODS and graphs drawn, and returns a link to it: - **How.** The compute context opens no HTML destination of its own, so the server runs the code between an `ods html5` statement and its close. Before the close comes `;*';*";*/;run;quit;`, which ends whatever the code left open (an unterminated statement, quote or comment, or a step without `run;`) so that the close still runs. None of this appears in the log the model reads. `html_results=false` submits the code exactly as given. - **The link.** When the code printed something, the page is saved to the Viya Files service and the result gains `html_results_url`. Opening it in a browser asks you to sign in to SAS Viya; the file sits in no folder, so Viya's default rules let only the person who ran the code (and administrators) open it. Pages are saved without an expiration, the Files service's default, so they stay until someone deletes them. - **In the SAS log view**, the page is the Results tab, shown first when the code ran cleanly. The view fetches it through `download_file`, so a deployment without Tier 2 gets the link but not the tab. - **Cost.** Opening and closing the destination adds about a tenth of a second to a job, and saving the page is one more request. The page itself, 40–70 KB and mostly ODS's stylesheet, never enters the model's context; only the link does. ### Available Tools The headings below match the numbered **tiers** above, so `MCP_TIERS` maps directly to the tools you expose (e.g. `MCP_TIERS=0-3` gives Tiers 0–3). #### Tier 0 — Compute Contexts & Code Execution - **execute_sas_code**: Execute SAS code snippets and retrieve execution results (log and listing output), plus a link to the [HTML results](#html-results) unless `html_results=false`. Runs in a reusable, per-user compute session that is kept warm across calls, so SAS state (WORK tables, macro variables, assigned librefs) persists between successive calls — use **reset_compute_session** to start fresh. The code goes in `sas_code`; `code` is accepted too, here and in `submit_batch_job`, because agents reach for it. The session runs one job at a time, so a long job blocks the next call; `submit_batch_job` runs in a session of its own. Its memory is capped by the deployment's compute pod, and a PROC SQL join or hash object can exhaust it where a sorted DATA step MERGE does not. - **list_compute_contexts**: List available compute contexts - **server_status**: Name the SAS Viya endpoint this server talks to, the environment profile that started it (`MCP_PROFILE`), the user its token belongs to, when the token expires and whether the server can renew it, and the result of the [expected-host check](#expected-host-check). It returns no secrets. Read-only, so it works when the check refuses writes, and registered with every tier selection, so `MCP_TIERS` cannot leave it out - **reset_compute_session**: Delete the cached compute session for a context, discarding its SAS state and forcing a fresh session on the next call - **list_compute_sessions**: List your own compute sessions, with each one's state, the compute context it was started from, and whether this server keeps it warm for `execute_sas_code`. With `all_users=true` it lists every session SAS Viya lets the caller see, which includes other users' sessions only for an administrator. - **delete_compute_session**: End one of your compute sessions and whatever runs in it, a batch job included. Another user's session is refused unless the call passes `all_users=true`. Viya reports `pending` while the session finishes its current work. #### Tier 1 — Data Discovery *SAS Data Governance (metadata discovery & profiling):* - **catalog_search**: Search the catalog for assets (tables, columns, reports, …) using the SAS catalog search grammar (free text, facets like `AssetType:Report`, ranges). Each hit carries a `resource_uri` you can hand to the matching tool (e.g. `get_report`, `get_castable_data`). - **catalog_search_helper**: Discover how to query the catalog — list the available facets, or the valid values for one facet — so you can build precise `catalog_search` queries. - **catalog_find_instance**: Resolve the catalog *instance* for a source-asset `resource_uri`, bridging a search hit to the profiling and download tools without handling an instance id by hand. - **catalog_run_adhoc_analysis**: Submit an ad-hoc profiling job for a table. NLP enrichment (language, sentiment, semantic IDs) is on by default, populating `informationPrivacy`, `nlpTerms`, `nlpTags`, and `mostImportantFields`. - **catalog_get_adhoc_analysis**: Poll a profiling job and cross-check the target instance, reporting `profile_ready` once results have landed on the asset — so a download isn't fired too early. - **catalog_download_table_profile**: Download a table's data dictionary and column profile as CSV, identified by either `instance_id` or `resource_uri`. - **catalog_list_agents**: List the catalog's discovery agents (the crawlers that populate metadata). - **catalog_run_agent**: Start a discovery agent run (asynchronous) to crawl its data source and refresh catalog metadata. - **catalog_get_agent_history**: Inspect an agent's run history — status and how much metadata each run enumerated/added/updated/removed. *CAS data (in-memory):* - **list_cas_servers**: List available CAS servers - **list_caslibs**: List CAS libraries on a server - **list_castables**: List tables in a CAS library - **list_source_tables**: List source tables not yet loaded into memory (candidates for promotion) - **get_castable_info**: Get table metadata (row count, columns, size) - **get_castable_columns**: Get column names, types, labels, formats - **get_castable_data**: Fetch sample rows from a CAS table - **query_data**: Run a FedSQL `SELECT` against CAS or compute data and get the rows back — one SQL surface over both storage tiers. Pick the tier with `target` (`cas` for `caslib.table`, `compute` for `libref.table`); joins, subqueries, aggregation, and `UNION` all work, and the row cap is applied server-side by the tool (a `LIMIT` you write is ignored, since a malformed one is silently discarded by CAS). Optionally returns the query as `CREATE VIEW` text for you to run yourself. Reads only: writes are refused pre-flight, and SAS macro triggers (`%`/`&`) are rejected because the macro processor would expand them outside SQL. Note the two tiers cannot be joined in one statement. *Compute libraries (SAS/Compute, within a compute context):* - **list_compute_libraries**: List the SAS libraries (librefs) assigned in a compute context - **list_compute_tables**: List the tables in a SAS library within a compute context - **list_compute_columns**: List the columns of a table in a SAS library - **get_compute_table_data**: Fetch a page of rows from a table in a SAS library, values formatted as SAS displays them — the compute-tier counterpart of `get_castable_data` #### Tier 2 — Data Operations & Files - **upload_data**: Upload a data file into a CAS table — read **server-side** so the data never passes through the model's context — from `file_path` (the server reads it off disk) or `url` (the server fetches it and converts it to the multipart upload the endpoint requires). Ingests the formats the casManagement `uploadTable` API accepts — csv, tsv (csv + tab delimiter), xls, xlsx (single sheet), sas7bdat, sashdat — auto-detected from the extension or set with `data_format`. parquet is not accepted by that endpoint and is rejected up front with guidance (load via a path-based caslib + `promote_table_to_memory`, or convert to csv/sas7bdat). - **upload_inline_data**: Create a *small* CAS table from inline csv/tsv text passed as a string (a lookup/mapping table the model builds on the fly, or a quick test table). The payload travels through the model's context, so it's for tiny tables only — use **upload_data** for files or anything larger. - **promote_table_to_memory**: Load a source table into memory at global scope (idempotent) - **list_files**: List files in the Viya Files Service - **upload_file**: Upload a file to the Viya Files Service, optionally into a Content folder (`parent_folder_uri`). Content comes from exactly one of `content` (inline text), `file_path` (read **server-side**, binary-safe — xlsx, zip, images — gated by `ALLOW_LOCAL_FILE_UPLOAD`), or `url` (server-side fetch) - **download_file**: Download file content - **find_folder**: Look up a SAS Content folder by path (`/Public/Content/Decisions`, `My Folder`, `My Folder/Risk`), ID or URI, and return its ID, URI, name and full path — for confirming a folder the user named, or getting the URI that `upload_file` and `MCP_DEFAULT_FOLDER` take - **create_folder**: Create a SAS Content folder and any missing folders above it: `/Public/Content/Risk` and `My Folder/Risk` where they say, a relative path such as `Risk/2026` under `MCP_DEFAULT_FOLDER` (refused when that is unset). An existing folder is returned unchanged, so it can be called twice - **save_castable**: Save an in-memory CAS table to a file in a caslib (`sashdat`, `csv`, `parquet` or `sas7bdat`), so it survives a drop or a CAS restart; an existing file is overwritten only with `replace` - **drop_castable**: Drop a table from CAS memory and keep its source file, so `promote_table_to_memory` can load it again. A table with no source file would lose its data, so it is refused unless `allow_unsaved` #### Tier 3 — Reports & Visualization - **list_reports**: List Visual Analytics reports - **get_report**: Get report metadata and definition - **export_report**: export a report (or specific report objects) in any format the VA service supports — `package` (zip), `pdf`, `png`, `svg`, `csv`, `tsv`, `xlsx`, or `summary`. Text formats come back inline, `png` as image content, and binary formats (`package`/`pdf`/`xlsx`) as an embedded file with the right MIME type. - **describe_report_objects**: Discover what a report can contain — the eight report operations and every addable object (bar chart, list table, geo map, key value, …) with a one-line purpose, its data roles, common options, and an example payload. Call with no arguments for the catalog (including an intent→object map, placement guide, layout recipes, and the API's hard limits), `object_type=` for one object's contract (colloquial aliases like `kpi` resolve), `category=` to filter, or `operation=` for one operation's full shape — `operation="addData"` documents `dataItems` (column renames, SAS formats, aggregations, geography classification). Backs the `apply_report_operations` loop. - **create_report**: Create a Visual Analytics report and return its id. Optionally pass an `operations` array to build the whole report in one atomic call; the result carries the created page/object names+labels and a verify hint. - **apply_report_operations**: The authoring workhorse — apply an ordered batch of native VA operations (`addData`, `addPage`, `addObject`, `updateObject`, `setParameterValue`, `updateData`, `changeData`, `applyDataView`) to a report. Give a page a **title** with `addPage`'s `title` field (a text band at the top of the page body — VA headers are controls-only); title every chart at add time via `options.object.title`; arrange objects with **placement** — `page`, `relativeToObject` (left/right/top/bottom for columns, rows, and grids), `container` (group into a `standardContainer`), or `report` (`new_page` creates-and-names a page inline for one-batch multi-page reports). The batch is atomic. Validates every operation, object key, and placement against the catalog first (reporting all errors at once), supports `dry_run`, handles the ETag concurrency handshake, and — with `save_as=true` plus `result_report_name`/`result_folder` — applies the batch **save-as** to a new report, leaving the source untouched. The flag alone decides the mode: without it the report is edited in place, and a name or folder given without it is refused rather than acted on. Typical loop: `describe_report_objects` → `get_castable_columns` → `apply_report_operations` → `get_report_outline` / `export_report` (png, page-by-page) to verify. - **get_report_outline**: Read a report's structure back — pages → objects with the handles the other tools need (object `name` for placement/`updateObject` targets, `label` for `export_report`, page `label` for page placement). - **copy_report**: Copy a report to a new one (optionally renaming/refoldering). Pairs with a `changeData` operation for the copy-and-replace pattern. - **delete_report**: Delete a report and its content. #### Tier 4 — Batch Jobs & Async Execution - **submit_batch_job**: Submit a SAS job for async execution. The result adds `token_lifetime`, which says when the access token expires and how many seconds it has left. Before submitting, the stdio server renews a token with less than 30 minutes left, or less than `expected_runtime_minutes` when the call gives it. It warns when the token may still run out before the job ends. In HTTP mode the MCP client owns the token, so the result reports its lifetime and does not renew it - **get_job_status**: Check job state. A missing record returns `not_found` and the requested job ID - **list_jobs**: List recent/running jobs - **cancel_job**: Delete the job record. Its compute session may still be running - **get_job_log**: Retrieve job log #### Tier 5 — Automated Machine Learning - **list_ml_projects**: List AutoML projects - **create_ml_project**: Create a new AutoML project from a loaded, global-scope CAS table (caslib + table + optional CAS server) - **run_ml_project**: Run pipeline automation - **register_ml_champion_model**: Register an AutoML project's champion model to the Model Repository - **publish_ml_champion_model**: Publish an AutoML project's champion model to a scoring destination (default: `MCP_DEFAULT_PUBLISH_DESTINATION`) #### Tier 6 — Model Management & Scoring - **list_registered_models**: List models in repository - **list_publishing_destinations**: List available scoring/publishing destinations, for use with **publish_model** and **publish_ml_champion_model** - **list_mas_modules**: List published MAS modules - **get_mas_module_step_signature**: Inspect a published MAS module step's input/output variable signature before scoring - **score_data**: Score data against a published model or decision; for a decision published from the Intelligent Decisioning UI, whose inputs carry a trailing underscore, the plain names are accepted and mapped (`inputs_renamed`) - **get_model**: Describe a registered model: project, version, role (champion or not), target, event probability variable, input and output variables, and files - **list_model_versions**: A model's versions, the current one first - **test_score_model**: Score a few rows (default 10, at most 100) with a registered model using Model Manager's own score test, wait, and return the scored rows; the scratch tables and score definition are removed again - **score_table**: Score a whole CAS table with a registered model, straight from the repository (no publishing needed); returns the score execution to follow - **get_score_execution**: State, output table and, when it failed, the log's errors of a score execution; optionally the first scored rows - **list_published_models**: Published models by destination and name, with their state and the registered model they came from #### Tier 7 — Decisioning Foundation (SAS Intelligent Decisioning) Build and run SAS Intelligent Decisioning decisions — rule sets that consult lookup tables, and decision flows that combine them with models, branches, conditions, assignments and sub-decisions — then publish a flow to Micro Analytic Score (MAS) so **score_data** can execute it. The life-cycle tools read, lock, copy and delete every kind of decisioning content. Segmentation trees, code files, value lists and custom functions are written with [Tier 10](#tier-10--decisioning-advanced-sas-intelligent-decisioning); enable both (`MCP_TIERS=...,7,10`) for everything — the server logs a warning when Tier 10 is on without Tier 7. Rule sets and decision flows are always stored in a SAS Content folder. The create tools take a `folder` — a path such as `/Public/Content/Decisions`, `My Folder` or `My Folder/Risk`, a folder ID, or a folder URI — and fall back to the deployment's `MCP_DEFAULT_FOLDER`. With neither, they refuse and the model asks the user where to store the asset. An update leaves an asset in its folder; one created before folders were required is filed by its next update, into the folder given or the default. Every create and update result carries `folder`, with the path the asset is in. *Business rules — rule sets:* - **create_business_ruleset** / **update_business_ruleset** / **get_business_ruleset** / **list_business_rulesets** / **delete_business_ruleset**: Manage rule sets (the input/output signature the rules operate on) - **lock_business_ruleset_revision**: Lock the current rule set state as an immutable revision (what a decision step references) - **list_business_ruleset_revisions**: List a rule set's locked revisions *Business rules — rules:* - **create_business_rule** / **update_business_rule** / **get_business_rule** / **list_business_rules** / **delete_business_rule**: Manage the conditional rules inside a rule set *Decision flows:* - **create_decision_flow** / **update_decision_flow** / **get_decision_flow** / **list_decision_flows** / **delete_decision_flow**: Manage decision flows that chain rule set steps - **get_decision_flow_code**: Retrieve the generated DS2 execution code for a flow - **lock_decision_flow_revision** / **list_decision_flow_revisions** / **get_decision_flow_revision**: Lock, list, and fetch immutable decision revisions - **publish_decision_flow**: Publish a locked decision revision to a MAS destination, polling to completion and returning the server-generated MAS `moduleId` (directly usable with **get_mas_module_step_signature** / **score_data**). The code is generated for MAS, as SAS Intelligent Decisioning publishes it, so lookup tables work; the module's inputs keep the decision's variable names (the UI would add a trailing underscore, `credit_score_`) **create_decision_flow** and **update_decision_flow** take `steps`, in which each step names what it is and the server wires it: `{"type": "rule_set" | "segmentation_tree" | "code_file" | "decision", "id": ...}` (a sub-decision is a `decision`), `{"type": "model", "id": }`, `{"type": "assignment", "assignments": {"band": "GOLD"}}`, `{"type": "condition", "expression": "score >= 630", "on_true": [...], "on_false": [...]}` and `{"type": "branch", "branch_type": "range" | "equals" | "like", ...}`. A referenced object's newest locked revision is used (one is locked if there is none); step terms map to same-named decision variables, and a term the decision has none for is added as a variable of its type and direction, because Intelligent Decisioning validates and publishes a step only when every term is mapped. Mappings never cross type families. Assignments set constants (compute in a rule set or code file); a model is referenced by its model repository ID and its outputs become decision variables; range branches compare inclusively (`>= min`, `<= max`) and their cases must not share a value; steps nest inside branch cases and conditions. The tool's description carries a worked example of each. `rule_set_steps` still works for rule-set-only flows. The result's `steps_report` lists the revisions used, the variables added and anything to check. *Content — one life cycle for every kind:* `asset_type` is `rule_set`, `decision`, `segmentation_tree`, `code_file`, `value_list`, `lookup_table`, `custom_function` or `function_category`. - **list_decisioning_assets** / **get_decisioning_asset** / **delete_decisioning_asset**: List, read (with the folder it is in; a rule set with its rules, a code file with its code, a value list with its entries, a lookup table with its versions and active entries; content over 150,000 characters is summarised) and delete any of them — a lookup table that rule sets use is refused, naming them, because Viya would delete it and leave those rules invalid - **get_decisioning_asset_code**: The DS2 Viya generates for a rule set, decision or segmentation tree, or a code file's source - **list_decisioning_asset_revisions** / **lock_decisioning_asset_revision**: Revisions of rule sets, decisions, segmentation trees and code files. Locking freezes the current state and opens the next revision; the result says which revision was locked - **copy_decisioning_asset**: Copy a rule set (with its rules), decision, segmentation tree, code file, value list or lookup table into a folder - **validate_decision_expression**: Compile a DS2 expression — a rule condition or action, a branch, a condition step — against a signature and return the compiler's error lines, before it goes into a rule set or decision *Lookup tables* — keys and the value stored for each, which rules consult: a `lookup` condition tests whether a variable's value is a key, a `lookupValue` action assigns the value for a key. **create_business_rule** / **update_business_rule** take the lookup table by name and resolve its ID (a reference without one is stored as invalid), and report any condition or action Viya stored as invalid in `problems`. Rules read a lookup table's *active* version, which activation publishes to MAS and CAS; a decision already published uses newly activated entries on its next call, without being published again. - **get_lookup_table**: Versions (which one is active, which failed to activate and why), one version's entries — paged, filtered by key — and the rule sets that use the table - **create_lookup_table**: Create one from `{"key": "value"}` or a list of entries, with optional column labels, in a folder; `activate` publishes it right away - **update_lookup_table**: Add or overwrite entries, remove keys, or replace them all; rename; relabel. An active version is never changed — a new version is started from it — and rules keep the active one until the new one is activated (`activate` does that in the same call) - **activate_lookup_table**: Make a version the active one and wait for the publish to settle (`active`, `running` or `failed` with the reason); an earlier version (a rollback) or one whose activation failed is activated as a new version with its entries; `republish` copies the active version to MAS and CAS again #### Tier 8 — Workbench (Execute Code Only) - **execute_sas_code**: Execute SAS code snippets and retrieve execution results (log and listing output), plus a link to the [HTML results](#html-results) unless `html_results=false`. Runs in a reusable compute session that is kept warm across calls, so SAS state (WORK tables, macro variables, assigned librefs) persists between successive calls #### Tier 9 — Business Glossary (SAS Data Governance) Read and author the SAS Business Glossary, and link its terms to the columns they describe. Tier 1 tells you a column is called `CD_NAC_RSK`; this tier tells you what that means and who says so. Two things about the glossary are worth knowing before you start, because both are invisible in the raw API and both are handled for you here: - **A term has two ids.** It exists as a Glossary object *and* as a Catalog entity, with different identifiers. Every tool returns both — `term_id` (glossary) and `catalog_entity_id` (catalog) — so you never have to work out which one you are holding. - **Custom attributes are stored under UUID keys.** These tools read and write them by the **label** the glossary UI shows (`{"Scope": "Group"}`), validating required attributes and single-select values before the call is made. *Dictionary:* - **search_glossary_terms**: Free-text, ranked search over term names and definitions — the way in when you know a word rather than an id. Reports `assigned_asset_count`, so you can see whether a term is actually in use - **list_glossary_terms**: Exact structural listing — by term type, by parent (the authoritative hierarchy), or by name fragment. `include_attributes` returns each term's attribute values (free — the listing already carries them), and `attribute_filter` keeps only the terms matching, e.g. `{"Used in Risk": true}`. The glossary cannot filter on attributes server-side, so that filter is applied here and the result reports how much of the dictionary it scanned - **get_glossary_term**: One term in full, with its custom attributes named rather than hashed - **list_glossary_term_types** / **get_glossary_term_type**: The term types available, and the attribute contract a term of that type must satisfy — call the latter before authoring. Each attribute reports the one value format Viya accepts for it, which the API itself documents nowhere *Where terms meet data:* - **list_term_assets**: The columns a term is attached to, with their tables. The authoritative answer to "where is this term used?" - **list_table_terms**: The reverse — every column of a table and the term assigned to it, with the term's definition inline. The fastest read on whether a table is governed *Authoring:* - **create_glossary_term**: Create a term. **Publishes by default** — the underlying API creates an invisible draft unless told otherwise; `update_glossary_term(publish=true)` promotes one later - **import_glossary_terms**: Create many terms, and their hierarchy, in one call. Children name their parent instead of needing its id, so rows can be given in any order and no id is threaded between levels; per-row failures are reported individually. Returns the `term_id` of each row's term, so the next step needs no lookup, and separates rows that were genuinely new from rows whose term already existed — the import job counts both as successful. A row is written whole, so `update_existing` *replaces* the term at that path rather than merging into it. `dry_run=true` shows the resolved rows without importing — the interactive view turns that into a table with an Import button - **update_glossary_term**: Change a term's text, parent or attributes. Merges onto the current term, so omitted fields are left alone rather than blanked; `parent_id` moves it in the hierarchy, and `publish` promotes a draft. A draft is a separate resource in the API, so this routes the write accordingly — editing one otherwise fails with a bare 404 - **delete_glossary_term**: Permanently delete a term and every assignment that referenced it. There is no cascade — a term with children is refused, so delete a subtree leaf-first - **assign_glossary_term** / **unassign_glossary_term**: Attach a term to a table column, or detach it. This is the step that makes a term govern data — a term with no assigned assets governs nothing *Designing the vocabulary:* - **create_glossary_term_type** / **update_glossary_term_type** / **delete_glossary_term_type**: Define the template terms are created from — which custom attributes they carry, which are mandatory, and what values each accepts. An edit matches attributes by label and keeps each one's identifier, so terms already carrying a value do not lose it — to *rename* one, give its `attribute_id` alongside the new label, since a new label matches nothing and would otherwise mint a new attribute; delete refuses while terms still use the type Terms assigned this way also become searchable through Tier 1's **catalog_search** using the `Column.term:""` facet on the `datasets` index, which returns the tables carrying a term without resolving individual columns. #### Tier 10 — Decisioning Advanced (SAS Intelligent Decisioning) SAS Intelligent Decisioning content beyond rule sets, for the decision flows of Tier 7: segmentation trees (written, or built from a strategy table), value lists, code files in DS2, Python and SQL, and DS2 custom functions that rule expressions call. Everything is stored in a folder, as in Tier 7. Using what this tier creates — as decision steps, and reading, locking, copying or deleting it — takes Tier 7, so enable the two together; with Tier 10 alone the server logs a warning at startup. *Segmentation trees:* - **create_segmentation_tree** / **update_segmentation_tree**: Write a tree: nodes test a variable against values (`"A;B"`), comparisons (`">=630"`), ranges (`"600<=v<630"`) or `"Other"`, in order; outcomes assign variables or run DS2. An update replaces only the parts given - **create_segmentation_tree_from_table**: Build one tree from a strategy table — one row per branch, a column per decision key — as FICO-style exports (TRIAD, Blaze) describe a strategy. Keys are tested in column order and only where they split; values are range lower bounds (`split="lower_bound"`) or exact values. Reads inline rows, a CSV, or a CAS table (load an Excel sheet with **upload_data**), can create a value list per variable, and reports leaves, outcomes and any rows whose path is identical but whose outcome differs *Value lists, code files and custom functions:* - **create_value_list** / **update_value_list_entries**: Value lists of values or numeric ranges (`"v>=630"`); a version in production is left alone and a new version takes the entries - **create_code_file** / **update_code_file**: DS2, Python or SQL code files; Viya reads the signature from the code, and `signature` supplies the types Python cannot state - **create_custom_function** / **update_custom_function**: DS2 custom functions that rule expressions call, checked to compile first; a category named but missing is created - **validate_custom_function**: Compile a custom function without saving it and return the compiler's error lines #### Tier 11 — Model Lifecycle (SAS Model Manager) The steps after a model is trained: register it, keep it in a project, make it the champion, publish it, check the published copy, and monitor it with KPI alert rules. Projects live in a model repository (`MCP_DEFAULT_MODEL_REPOSITORY`, default `Public`), not in SAS Content. > **Python models are currently not supported.** The tools work with SAS models: analytic stores and DATA step score code. *Registration and projects:* - **describe_analytic_store**: PROC ASTORE DESCRIBE of an analytic store in CAS: its inputs, outputs and algorithm, before registering it - **register_model**: Register a SAS model with PROC REGISTERMODEL, run in a compute session of its own: an analytic store in CAS (downloaded to the session and registered from there, never through the client) or DATA step score code. The procedure writes the variables, properties and score code, and with a data table and target the fit statistics, ROC and lift. Not Python or DS2. A model of the same name in the project is refused unless `replace=true`, which gives it a new ID and loses its score tests, publish history and monitoring - **list_model_repositories**: Model repositories, the default one marked - **list_model_projects**: Projects, by repository and name - **create_model_project**: Create a project, optionally in a folder inside the repository; one of that name is returned instead of a second one - **set_project_champion**: Make a model the champion, first copying the model's target, event and variables to the project where they are missing, as Model Manager's UI does (Model Manager refuses a champion without them, and PROC REGISTERMODEL leaves them empty) *Publishing:* - **publish_model**: Publish any registered model to a destination — MAS, CAS, a container registry, Git (`git_remote_path`) — with `dry_run` to see the destination, the published name and whether it would replace one. Default destination: `MCP_DEFAULT_PUBLISH_DESTINATION` (`maslocal`) - **validate_published_model**: Score a few rows with the published copy in its destination (Model Manager's publish validation) and return them, to compare with **test_score_model** *Monitoring:* - **create_performance_definition**: Define how a project's models are monitored, from one CAS table per period named `__