Skip to main content
Glama
sassoftware

SAS MCP Server

Official
by sassoftware

Query Data

query_data

Run FedSQL SELECT queries against CAS or SAS compute tables and retrieve rows. Read-only, with support for joins, aggregations, and paging—ideal for exploring data across both storage tiers.

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.

  1. Addedv1.8.0

TDQS

A5/5.0
Behavior5/5

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

The description discloses behavior far beyond the annotations: queries run in the reusable compute session, results are materialised into session scratch, read back, and dropped, and nothing is persisted. It also reveals tool-side row capping ('any LIMIT you write is ignored'), silent handling of malformed LIMITs, refusal of DDL/DML, and that 'create_view_name' is never executed. These details add rich behavioral context and do not contradict the annotations.

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 it is dense and every section earns its place: purpose, tier selection, dialect constraints, and row-capping behavior. Bold headings, short paragraphs, and a front-loaded 'target' decision make the large amount of necessary information scannable and appropriately structured.

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 tool with six parameters and a complex FedSQL surface, the description covers query constraints, tier behavior, paging, non-persistence, and dialect limitations. Since an output schema exists, the return-value format is already handled elsewhere. Nothing needed for correct invocation is missing.

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 the schema already documents all six parameters, the description adds significant meaning beyond it: target qualification examples for both tiers, the fact that SQL LIMIT is ignored in favor of the 'limit' parameter, and that 'create_view_name' returns SQL for the agent to execute itself rather than executing it. This is exactly the kind of parameter-level insight an agent needs to call the tool correctly.

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 opening sentence states a specific verb and resource: 'Run a FedSQL SELECT against CAS or compute data and return the rows.' It clearly distinguishes the tool from siblings by explaining the two storage tiers and pointing to the relevant list tools for each namespace. This gives an agent an unambiguous idea of what the tool does and how it differs from other data-access tools.

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 explicitly tells the agent to select the tier with 'target', explains that the two tiers cannot be mixed, and directs staging one side with 'execute_sas_code'. It also gives concrete when-not-to-use conditions: concatenated librefs like SASHELP are invisible to FedSQL and must be copied into WORK first, and MERGE/WITH are unavailable with explicit alternatives. This is strong, actionable usage guidance with named alternatives.

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

Deploy Server

Other Tools