Skip to main content
Glama

Run ABAP-SQL Query

sap_sql_query
Read-onlyIdempotent

Execute read-only ABAP SQL SELECT statements, including joins, against SAP S/4HANA and retrieve results in markdown or JSON. Designed for queries beyond standard table reads.

Instructions

Run a freestyle, read-only ABAP-SQL SELECT (including joins) via the ADT Data Preview. Use this when sap_read_table is not expressive enough.

Args:

  • sql (string): a SELECT statement. Only SELECT is permitted.

  • max_rows (number): 1-1000 (default 100).

  • response_format ('markdown' | 'json').

Returns (json): same shape as sap_read_table.

Examples:

  • "Join BKPF and BSEG for company 1000" -> sql="SELECT kbelnr, kgjahr, bhkont, bdmbtr FROM bkpf AS k INNER JOIN bseg AS b ON kbukrs = bbukrs AND kbelnr = bbelnr AND kgjahr = bgjahr WHERE k~bukrs = '1000'". Error Handling:

  • Rejects anything that is not a SELECT.

  • SAP syntax errors are returned with the server message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesA read-only ABAP-SQL SELECT statement (no trailing period needed). Joins are supported.
max_rowsNoMaximum rows to return (1-1000, default 100).
response_formatNoOutput format: 'markdown' (human-readable, default) or 'json' (structured).markdown
Install Server

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint, but the description adds useful behavioral details beyond those: execution via ADT Data Preview, rejection of anything that is not a SELECT, and propagation of SAP syntax error messages. This gives an agent a clearer picture of how the tool behaves at runtime, though it doesn't discuss edge cases like timeouts or very broad queries.

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 well-organized into Args, Returns, Examples, and Error Handling sections. The first sentence front-loads the purpose and usage condition, and each section earns its place. The long example SQL is justified because it illustrates exactly the complexity this tool is meant to handle.

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

Completeness4/5

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

For a complex, freestyle SQL tool with no output schema, the description covers the essential needs: purpose, usage guidance, parameters, an example, output shape via 'same shape as sap_read_table', and error behavior. Combined with full schema coverage and safety annotations, it is nearly complete; minor missing details such as response size limits or authorization requirements are not critical given the read-only constraint.

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

Parameters4/5

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

The input schema already covers all three parameters at 100%, so the baseline is 3. The description adds plain-language restatements plus a concrete SQL example for the 'sql' parameter, demonstrating join syntax, aliases, and table references—value beyond the schema's property 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 clear, specific verb and resource: 'Run a freestyle, read-only ABAP-SQL SELECT (including joins) via the ADT Data Preview.' It also explicitly contrasts with a sibling tool, saying to use this when 'sap_read_table is not expressive enough', which makes the tool's distinct role obvious.

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?

It states exactly when to choose this tool over the most relevant alternative: 'Use this when sap_read_table is not expressive enough.' It reinforces the boundary by emphasizing 'read-only' and 'Only SELECT is permitted,' signaling it is not for writes or arbitrary commands.

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

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/appmaster3000/sap-abap-mcp-server'

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