Skip to main content
Glama
sassoftware

SAS MCP Server

Official
by sassoftware

query_data

Run FedSQL SELECT statements to fetch rows from either CAS or compute tables in SAS Viya, with paging and row limits.

Instructions

Run a FedSQL SELECT against CAS or compute data and return the rows.

One SQL surface over both storage tiers, so exploring a caslib table and a SAS library table use the same tool and the same dialect. The query runs in the reusable compute session; nothing is persisted — the result is materialised into session scratch, read back, and dropped.

Pick the tier with target — it selects the namespace, and the two cannot be mixed in one statement (a caslib table and a libref table cannot be joined; stage one side first with execute_sas_code):

  • target='cas' (default) — qualify as caslib.table (e.g. Public.HMEQ); see list_caslibs / list_castables.

  • target='compute' — qualify as libref.table (e.g. WORK.SALES); see list_compute_libraries / list_compute_tables. Concatenated librefs — several directories under one name, which is what SASHELP and MAPS are — are invisible to FedSQL, because its BASE driver maps one schema to one directory. Copy such a table into WORK first (data work.cars; set sashelp.cars; run;) and query WORK.CARS.

Dialect notes (FedSQL, not PROC SQL): joins (inner/left/right/full/ cross), subqueries, UNION, GROUP BY/HAVING/ORDER BY, and scalar functions work. There is no WITH/CTE — use a derived table (select ...) "t" — and no MERGE; express a merge as a join (a full join with COALESCE gives upsert semantics). Double-quote identifiers that are reserved words or contain spaces; SAS name literals ('x'n) are not FedSQL.

Row capping is done by this tool, not by your SQL: any LIMIT you write is ignored in favour of limit (a malformed LIMIT is silently discarded by CAS and would return the whole table). Add ORDER BY for stable paging.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum rows to return, 1..10000 (default 100).
queryYesA single FedSQL SELECT statement. DDL/DML is refused — this tool only reads rows.
startNoRow offset for paging (default 0).
targetNoWhich tier the identifiers refer to — ``cas`` (default) or ``compute``.cas
create_view_nameNoIf set, the result includes ``create_view_sql`` — the ``CREATE VIEW <name> AS <query>`` text for this query. It is returned for you to run yourself, never executed here.
compute_context_nameNoCompute context to run in; defaults to the server's configured execution context.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Addedv1.8.0

TDQS

A5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Although annotations are all false, the description fully discloses behavior beyond structured fields: it states 'nothing is persisted—the result is materialised into session scratch, read back, and dropped,' explicitly refuses DDL/DML, and explains that a malformed LIMIT is silently discarded by CAS and that create_view_sql is never executed here. This is comprehensive transparency that exceeds what annotations alone provide.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but every sentence earns its place, using bold headings for tier selection and dialect notes. It front-loads the core purpose, then progressively adds necessary nuance without fluff. Markdown formatting aids scanning, and the structure mirrors the user's decision flow (which tier, what dialect, how paging works).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool spanning two storage tiers with a non-standard dialect, the description covers all critical aspects: tier selection, identifier qualification, dialect unsupported features (CTE, MERGE), concatenated libref invisibility, row capping, and stable paging. Given the existing output schema, this is exceptionally complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, but the description adds substantial meaning: target is explained with namespace distinctions and examples, limit behavior is clarified (the tool enforces it, SQL LIMIT is ignored), and create_view_name is detailed as returning SQL text rather than executing. This goes far beyond the schema's short descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a precise verb-resource statement: 'Run a FedSQL SELECT against CAS or compute data and return the rows.' It immediately clarifies it handles both storage tiers with a single SQL surface, which distinguishes it from sibling tools like list_castables or execute_sas_code. The scope is unambiguous and unique.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit tier-selection guidance via 'target' with concrete qualification examples (Public.HMEQ, WORK.SALES). It details when NOT to use it (concatenated librefs like SASHELP/MAPS) and instructs to copy to WORK first, even suggesting alternative tool execute_sas_code for staging. Also covers dialect limitations (no CTE, no MERGE) and row-capping behavior, making usage conditions crystal clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sassoftware/sas-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server