Skip to main content
Glama

sap_multi_table_query

Join data from multiple SAP tables with proper joins and aggregation, using depends_on to filter master data and avoid timeouts.

Instructions

Execute a multi-table query with proper joins and optional aggregation. Use this when you need data from 2+ tables that must be merged. Provide a JSON query plan with steps for each table, merge configuration, and optional aggregation. SUPPORTS AGGREGATION: For 'top N' queries, use the aggregation section to group, sum, sort, and limit results. IMPORTANT: Use this instead of multiple sap_read_table_data calls when you need joined data! CRITICAL - depends_on: When querying lookup/master data tables (KNA1, LFA1, MARA, etc.), ALWAYS use 'depends_on' and 'filter_field' to filter by keys from the primary table. This avoids querying the ENTIRE master data table. Example: To get customer names for sales orders, set KNA1 step with depends_on='orders', filter_field='KUNNR' — this queries only the customers in your order results. Without depends_on, KNA1 returns ALL customers (100K+) causing timeouts. NOTE: If the query returns more than 1000 rows, you will receive a 'requires_confirmation' response. You MUST ask the user if they want to see all the data. For 'last N' or 'most recent' requests, use sort_by + sort_order + limit instead of confirmed=true. Example: sort_by='WADAT_IST', sort_order='desc', limit=10 returns the 10 most recent deliveries. Fields in WHERE clauses and field lists are validated against table structure. Use sap_get_field_metadata or sap_read_table_structure first to discover correct field names.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoReturn only this many rows after sorting. Use with sort_by for 'last N' / 'top N' queries.
sort_byNoField to sort final results by (e.g., WADAT_IST, ERDAT, NETWR). Applied after merge.
max_rowsNoMaximum rows in final result (minimum 1000 enforced)
confirmedNoSet to true after user confirms they want large results (>1000 rows)
query_planYesQuery plan with steps and merge configuration
sort_orderNoSort direction. Use 'desc' for most recent / highest first.desc

Schema Changelog

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

  1. Addedv0.1.2

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden, and it delivers: it discloses the requires_confirmation flow for >1000 rows, the timeout risk of querying full master tables without depends_on, and that fields are validated against table structure. It even warns against a common failure mode (KNA1 returning 100K+ customers) and prescribes the behavior of asking the user before showing large results.

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

Conciseness4/5

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

The description is long but densely packed and clearly marked (SUPPORTS AGGREGATION, IMPORTANT, CRITICAL, NOTE, Example), front-loading the purpose before operational warnings. Nearly every section earns its place given the tool's complexity, though the aggregation intro slightly duplicates what the schema already documents.

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 highly complex tool with nested query_plan objects and no output schema, the description thoroughly covers query planning pitfalls, confirmation behavior, and field discovery. The main gap is that it never describes the successful response format (structure of merged results), and it doesn't differentiate itself from the similarly named sap_smart_table_query sibling — though the coverage of operational essentials is strong enough that agents can call it correctly.

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?

Schema coverage is 100%, so the baseline is 3, but the description adds strategic meaning beyond the schema's parameter docs: it explains why depends_on/filter_field exist (avoiding timeouts) with a concrete KNA1 example, clarifies when confirmed should be set (only after user consent), and shows the sort_by+sort_order+limit pattern for recency queries. This elevates it to 4, though individual parameter details still live mostly in the schema.

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 states a specific verb-resource pair ('Execute a multi-table query with proper joins and optional aggregation') and a crisp scope criterion ('data from 2+ tables that must be merged'). It explicitly differentiates from the key sibling tool: 'Use this instead of multiple sap_read_table_data calls when you need joined data!'

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 when-to-use guidance ('Use this when you need data from 2+ tables that must be merged'), names the alternative (sap_read_table_data), and gives conditional routing rules: use aggregation for 'top N' queries, use depends_on/filter_field for master data lookups, and use sort_by+sort_order+limit instead of confirmed=true for 'last N' requests. No ambiguity about when this tool applies.

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

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/NicoHern/abapilot-mcp'

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