Skip to main content
Glama

CheckDataElement

Perform syntax check on an ABAP data element to identify errors, warnings, and messages.

Instructions

Perform syntax check on an ABAP data element. Returns syntax errors, warnings, and messages.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
data_element_nameYesData element name (e.g., ZDE_MY_ELEMENT).

Implementation Reference

  • High-level handler for CheckDataElement tool. Defines the tool's name ('CheckDataElement'), input schema (requires data_element_name), and delegates to the low-level handler, then normalizes the check response.
    import type { HandlerContext } from '../../../lib/handlers/interfaces';
    import { normalizeCheckResponse } from '../../../lib/normalizeCheckResponse';
    import { handleCheckDataElement as handleCheckDataElementLow } from '../low/handleCheckDataElement';
    
    export const TOOL_DEFINITION = {
      name: 'CheckDataElement',
      available_in: ['onprem', 'cloud'] as const,
      description:
        'Perform syntax check on an ABAP data element. Returns syntax errors, warnings, and messages.',
      inputSchema: {
        type: 'object',
        properties: {
          data_element_name: {
            type: 'string',
            description: 'Data element name (e.g., ZDE_MY_ELEMENT).',
          },
        },
        required: ['data_element_name'],
      },
    } as const;
    
    export async function handleCheckDataElement(
      context: HandlerContext,
      args: { data_element_name: string },
    ) {
      const result = await handleCheckDataElementLow(context, args);
      return normalizeCheckResponse(result, args.data_element_name?.toUpperCase());
    }
  • Low-level handler for CheckDataElement. Performs the actual syntax check on an ABAP data element using AdtClient.checkDataElement, parses the check run response XML, and returns structured results (errors, warnings, info).
    /**
     * CheckDataElement Handler - Syntax check for ABAP DataElement
     *
     * Uses AdtClient.checkDataElement from @mcp-abap-adt/adt-clients.
     * Low-level handler: single method call.
     */
    
    import { parseCheckRunResponse } from '../../../lib/checkRunParser';
    import { createAdtClient } from '../../../lib/clients';
    import type { HandlerContext } from '../../../lib/handlers/interfaces';
    import {
      type AxiosResponse,
      restoreSessionInConnection,
      return_error,
      return_response,
    } from '../../../lib/utils';
    
    export const TOOL_DEFINITION = {
      name: 'CheckDataElementLow',
      available_in: ['onprem', 'cloud'] as const,
      description:
        '[low-level] Perform syntax check on an ABAP data element. Returns syntax errors, warnings, and messages. Can use session_id and session_state from GetSession to maintain the same session.',
      inputSchema: {
        type: 'object',
        properties: {
          data_element_name: {
            type: 'string',
            description: 'DataElement name (e.g., Z_MY_PROGRAM).',
          },
          session_id: {
            type: 'string',
            description:
              'Session ID from GetSession. If not provided, a new session will be created.',
          },
          session_state: {
            type: 'object',
            description:
              'Session state from GetSession (cookies, csrf_token, cookie_store). Required if session_id is provided.',
            properties: {
              cookies: { type: 'string' },
              csrf_token: { type: 'string' },
              cookie_store: { type: 'object' },
            },
          },
        },
        required: ['data_element_name'],
      },
    } as const;
    
    interface CheckDataElementArgs {
      data_element_name: string;
      session_id?: string;
      session_state?: {
        cookies?: string;
        csrf_token?: string;
        cookie_store?: Record<string, string>;
      };
    }
    
    /**
     * Main handler for CheckDataElement MCP tool
     *
     * Uses AdtClient.checkDataElement - low-level single method call
     */
    export async function handleCheckDataElement(
      context: HandlerContext,
      args: CheckDataElementArgs,
    ) {
      const { connection, logger } = context;
      try {
        const { data_element_name, session_id, session_state } =
          args as CheckDataElementArgs;
    
        // Validation
        if (!data_element_name) {
          return return_error(new Error('data_element_name is required'));
        }
    
        const client = createAdtClient(connection, logger);
    
        // Restore session state if provided
        if (session_id && session_state) {
          await restoreSessionInConnection(connection, session_id, session_state);
        } else {
          // Ensure connection is established
        }
    
        const dataElementName = data_element_name.toUpperCase();
    
        logger?.info(`Starting data element check: ${dataElementName}`);
    
        try {
          // Check data element
          const checkState = await client
            .getDataElement()
            .check({ dataElementName: dataElementName });
          const response = checkState.checkResult;
    
          if (!response) {
            throw new Error(
              `Check did not return a response for data element ${dataElementName}`,
            );
          }
    
          // Parse check results
          const checkResult = parseCheckRunResponse(response as AxiosResponse);
    
          // Get updated session state after check
    
          logger?.info(`✅ CheckDataElement completed: ${dataElementName}`);
          logger?.debug(
            `Status: ${checkResult.status} | Errors: ${checkResult.errors.length}, Warnings: ${checkResult.warnings.length}`,
          );
    
          return return_response({
            data: JSON.stringify(
              {
                success: checkResult.success,
                data_element_name: dataElementName,
                check_result: checkResult,
                session_id: session_id || null,
                session_state: null, // Session state management is now handled by auth-broker,
                message: checkResult.success
                  ? `DataElement ${dataElementName} has no syntax errors`
                  : `DataElement ${dataElementName} has ${checkResult.errors.length} error(s) and ${checkResult.warnings.length} warning(s)`,
              },
              null,
              2,
            ),
          } as AxiosResponse);
        } catch (error: any) {
          logger?.error(
            `Error checking data element ${dataElementName}: ${error?.message || error}`,
          );
    
          // Parse error message
          let errorMessage = `Failed to check data element: ${error.message || String(error)}`;
    
          if (error.response?.status === 404) {
            errorMessage = `DataElement ${dataElementName} not found.`;
          } else if (
            error.response?.data &&
            typeof error.response.data === 'string'
          ) {
            try {
              const { XMLParser } = require('fast-xml-parser');
              const parser = new XMLParser({
                ignoreAttributes: false,
                attributeNamePrefix: '@_',
              });
              const errorData = parser.parse(error.response.data);
              const errorMsg =
                errorData['exc:exception']?.message?.['#text'] ||
                errorData['exc:exception']?.message;
              if (errorMsg) {
                errorMessage = `SAP Error: ${errorMsg}`;
              }
            } catch (_parseError) {
              // Ignore parse errors
            }
          }
    
          return return_error(new Error(errorMessage));
        }
      } catch (error: any) {
        return return_error(error);
      }
    }
  • Input validation schema for CheckDataElement. Defines the tool name, availability (onprem/cloud), description, and inputSchema requiring data_element_name as a string.
    export const TOOL_DEFINITION = {
      name: 'CheckDataElement',
      available_in: ['onprem', 'cloud'] as const,
      description:
        'Perform syntax check on an ABAP data element. Returns syntax errors, warnings, and messages.',
      inputSchema: {
        type: 'object',
        properties: {
          data_element_name: {
            type: 'string',
            description: 'Data element name (e.g., ZDE_MY_ELEMENT).',
          },
        },
        required: ['data_element_name'],
      },
    } as const;
  • Import of CheckDataElement_Tool definition and handleCheckDataElement handler from the high-level handler file into the HighLevelHandlersGroup.
    import {
      TOOL_DEFINITION as CheckDataElement_Tool,
      handleCheckDataElement,
    } from '../../../handlers/data_element/high/handleCheckDataElement';
  • Registration of CheckDataElement tool in the high-level handler group's getHandlers() array, mapping toolDefinition to handler.
    {
      toolDefinition: CheckDataElement_Tool,
      handler: withContext(handleCheckDataElement),
    },
Behavior3/5

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

No annotations are provided, so the description bears full burden. It states the tool 'returns syntax errors, warnings, and messages', implying it is read-only and non-destructive, but it does not explicitly confirm that no changes are made to the system. Adding an explicit statement about safety would improve transparency.

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?

A single, well-structured sentence that conveys the action and outputs without unnecessary words. Every element earns its place.

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 simple, single-parameter tool with no output schema, the description is complete: it names the operation, the resource, and the nature of the return values. No additional context is needed.

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

Parameters3/5

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

The input schema covers the single parameter with a description and example. The description adds no further detail beyond what the schema provides (e.g., format, constraints, or default). Given 100% schema coverage, a score of 3 is appropriate.

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 clearly states it performs a syntax check on a specific ABAP resource ('data element'), which distinguishes it from sibling Check* tools (e.g., CheckClass, CheckDomain). The verb-resource pairing is precise and leaves no ambiguity.

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

Usage Guidelines3/5

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

No explicit guidance on when to use this tool versus alternatives (e.g., GetDataElement, ActivateDataElement). The purpose is implied (checking syntax before activation), but no exclusion criteria or context about when it's appropriate compared to other checks.

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/fr0ster/mcp-abap-adt'

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