sas-mcp
v0.2.0MCP server for writing, running, and validating SAS 9.4 code via SASPy
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
sas_doctor
Diagnose SASPy configuration without connecting: config file and connection method, Java runtime for IOM, ~/.authinfo presence and permissions, ODA hostname validity, network reachability, and encoding. Run this first whenever a connection fails.
| Parameter | Type | Description |
|---|---|---|
probe_network | boolean |
session_status
Report whether a SAS session is live, the SAS version and encoding, the assigned librefs, the data sets currently in WORK, and the active write policy. Useful for reorienting after a long conversation.
list_sas_configs
List the SAS configurations available in the user's SASPy setup, with the access method and target server for each. Call this when connecting reports that a configuration must be chosen, or when the user mentions a specific SAS environment by name.
use_sas_config
Select which SAS configuration to connect to, by name. Ends any current SAS session, so WORK data sets and librefs from the previous configuration are lost. Use when the user names a SAS environment, or after list_sas_configs shows several.
| Parameter | Type | Description |
|---|---|---|
name * | string |
run_sas
Submit SAS code to the live session and return a triaged result: status (ok / suspicious / error), extracted errors and warnings, the NOTEs that mean the code ran but the answer may be wrong, per-step row counts, and the listing output. Writes outside WORK are blocked by policy. The session keeps state between calls.
| Parameter | Type | Description |
|---|---|---|
code * | string | |
include_log | boolean |
get_last_log
Return the full raw SAS log from the most recent submit. Use only when the triaged output from run_sas was not enough to diagnose the problem, since logs consume a lot of context.
| Parameter | Type | Description |
|---|---|---|
from_end | boolean | |
max_lines | integer |
reset_session
Delete every data set in WORK to clear accumulated state. Librefs and the connection itself are preserved. Use when earlier intermediate tables are causing confusion.
list_libraries
List assigned SAS libraries with path, engine, whether SAS considers them read-only, and whether this server's policy allows writing to them.
list_datasets
List the data sets in a SAS library, with row counts, column counts, and modification dates.
| Parameter | Type | Description |
|---|---|---|
libref * | string |
describe_dataset
Return the columns of a SAS data set with type, length, format, informat, and label, plus the row count. Call this before writing code against a table you have not already inspected.
| Parameter | Type | Description |
|---|---|---|
libref * | string | |
table * | string |
sample_rows
Return the first N rows of a SAS data set as records, to inspect actual values, coding schemes, and missingness.
| Parameter | Type | Description |
|---|---|---|
libref * | string | |
table * | string | |
n | integer |
download_from_sas
Copy a file from the SAS server's filesystem to this machine, over the SAS connection. Works even when the two share no filesystem -- for example a workbook written by PROC EXPORT on SAS ODA. Returns the local path, which the user can open. Files land in this server's transfer directory; arbitrary local paths are not accepted.
| Parameter | Type | Description |
|---|---|---|
remote_path * | string | |
local_name | ||
overwrite | boolean |
upload_to_sas
Send a file from this server's transfer directory to the SAS server's filesystem, over the SAS connection. Only files already in the transfer directory can be sent; to upload something else, ask the user to copy it there first.
| Parameter | Type | Description |
|---|---|---|
local_name * | string | |
remote_path * | string | |
overwrite | boolean |
list_sas_files
List a directory on the SAS server's filesystem. Use it to confirm where a step actually wrote its output before downloading.
| Parameter | Type | Description |
|---|---|---|
path * | string |
compare_datasets
Run PROC COMPARE between two data sets and return a structured diff: whether they are identical, whether the difference is in the data or only in metadata (labels, formats, lengths), and the specific kinds of difference found. This is the primary way to validate that a rewrite produces the same result as the original.
| Parameter | Type | Description |
|---|---|---|
base * | string | |
compare * | string | |
by | ||
criterion |
run_sas_tests
Run SAS code with the assertion macro library available, and return each assertion's pass/fail result alongside the usual log triage. Available macros: %assert_exists(ds), %assert_rows(ds, n), %assert_not_empty(ds), %assert_no_missing(ds, var), %assert_unique(ds, key), %assert_equal_datasets(base, compare), and %assert_condition(condition, detail=...). Use this to validate code you have written.
| Parameter | Type | Description |
|---|---|---|
code * | string | |
include_log | boolean |