Skip to main content
Glama
sassoftware

SAS MCP Server

Official
by sassoftware

query_data

Run FedSQL SELECT queries against CAS or compute tables in SAS Viya and retrieve rows. Query both storage tiers with one SQL dialect, using paging and result 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

Behavior5/5

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

With no annotations provided, the description fully carries the burden of behavioral disclosure. It reveals that nothing is persisted, the session is reused, results are temporarily materialized and dropped, row capping is enforced by the tool ignoring LIMIT, and create_view_name is never executed. These are critical runtime behaviors well beyond what schema provides.

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 serves a purpose, with clear sectioning and front-loaded core purpose. The use of bullets and bold for key terms makes it scannable. Despite its length, it avoids redundancy and is appropriately sized for the tool's complexity.

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?

The description covers all essential context: storage tier selection, dialect limitations, row capping behavior, and session persistence. With an output schema present, not detailing return values is acceptable. The description is complete enough for an agent to correctly select and invoke the tool.

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?

Although schema coverage is 100%, the description adds substantial meaning to each parameter: target is explained with concrete examples (caslib.table vs libref.table), limit is clarified as the only row capping mechanism, and create_view_name is explicitly said to only return SQL. This goes far beyond the schema defaults and 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 begins with a specific verb+resource: 'Run a FedSQL SELECT against CAS or compute data and return the rows.' It explicitly distinguishes itself from siblings like execute_sas_code by focusing on SQL queries over both storage tiers. The scope is clear and unambiguous.

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?

The description explains when to use this tool vs alternatives, including explicit guidance on choosing the target tier, referencing helper tools like list_caslibs/list_castables, and instructing to stage data with execute_sas_code when concatenated librefs are involved. It also provides dialect limitations that inform usage.

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