Skip to main content
Glama
ethanhan2014

SAP ADT MCP Server

by ethanhan2014

get_data_element

Fetch the complete definition of an SAP DDIC data element, including data type, length, and semantic attributes, using the data element name and optional system ID.

Instructions

Fetch DDIC data element definition from SAP system

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesData element name (e.g. MATNR)
system_idNoSAP system ID (e.g. DEV). Omit to use default system.

Implementation Reference

  • Tool 'get_data_element' is registered in the ListToolsRequestSchema handler with name, description, and input schema (requires 'name' string, optional 'system_id').
    {
      name: "get_data_element",
      description: "Fetch DDIC data element definition from SAP system",
      inputSchema: {
        type: "object" as const,
        properties: { name: { type: "string", description: "Data element name (e.g. MATNR)" }, ...SYSTEM_ID_PROP },
        required: ["name"],
      },
    },
  • Handler for 'get_data_element': parses args with NameSchema, calls client.getSourceOrMetadata() with ADT source and metadata URIs for DDIC data elements, then parses XML via parseDataElementXml() if the result contains '<dtel:dataElement>'.
    case "get_data_element": {
      const { name: dtelName } = NameSchema.parse(args);
      const encoded = encodeURIComponent(dtelName.toUpperCase());
      const result = await client.getSourceOrMetadata(
        `/sap/bc/adt/ddic/dataelements/${encoded}/source/main`,
        `/sap/bc/adt/ddic/dataelements/${encoded}`
      );
      const text = result.includes("<dtel:dataElement")
        ? parseDataElementXml(result)
        : result;
      return { content: [{ type: "text", text }] };
    }
  • Helper method getSourceOrMetadata() on AdtClient: tries to fetch source text first (sourcePath), falls back to metadata XML (metadataPath) if source returns 404.
    async getSourceOrMetadata(sourcePath: string, metadataPath: string): Promise<string> {
      try {
        return await this.getSource(sourcePath);
      } catch (error: unknown) {
        if (axios.isAxiosError(error) && error.response?.status === 404) {
          return await this.getMetadata(metadataPath);
        }
        throw error;
      }
    }
  • Helper module dtel-parser.ts: contains parseDataElementXml() which extracts data element properties from XML (name, description, typeKind, typeName, dataType, length, decimals, field labels, search help, default component name) and formats them as readable text.
    function extract(xml: string, tag: string): string {
      const match = xml.match(new RegExp(`<dtel:${tag}>(.*?)</dtel:${tag}>`));
      return match?.[1] ?? "";
    }
    
    function extractAttr(xml: string, attr: string): string {
      const match = xml.match(new RegExp(`adtcore:${attr}="([^"]+)"`));
      return match?.[1] ?? "";
    }
    
    export function parseDataElementXml(xml: string): string {
      const name = extractAttr(xml, "name");
      const description = extractAttr(xml, "description");
      const typeKind = extract(xml, "typeKind");
      const typeName = extract(xml, "typeName");
      const dataType = extract(xml, "dataType");
      const length = extract(xml, "dataTypeLength").replace(/^0+/, "") || "0";
      const decimals = extract(xml, "dataTypeDecimals").replace(/^0+/, "") || "0";
      const shortLabel = extract(xml, "shortFieldLabel");
      const mediumLabel = extract(xml, "mediumFieldLabel");
      const longLabel = extract(xml, "longFieldLabel");
      const headingLabel = extract(xml, "headingFieldLabel");
      const searchHelp = extract(xml, "searchHelp");
      const defaultComp = extract(xml, "defaultComponentName");
    
      const lines = [
        `Data Element: ${name}`,
        `Description:  ${description}`,
        ``,
        `Type:         ${typeKind} → ${typeName}`,
        `Data Type:    ${dataType}(${length}${parseInt(decimals) > 0 ? `, ${decimals}` : ""})`,
        ``,
        `Field Labels:`,
        `  Short:      ${shortLabel}`,
        `  Medium:     ${mediumLabel}`,
        `  Long:       ${longLabel}`,
        `  Heading:    ${headingLabel}`,
      ];
    
      if (searchHelp) lines.push(``, `Search Help:  ${searchHelp}`);
      if (defaultComp) lines.push(`Default Comp: ${defaultComp}`);
    
      return lines.join("\n");
    }
  • Input schema NameSchema used by get_data_element handler: validates that 'name' is a required string.
    const NameSchema = z.object({ name: z.string() });
    const FunctionModuleSchema = z.object({
Behavior3/5

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

The description characterizes the tool as a fetch operation, implying read-only and non-destructive behavior. However, without annotations, it fails to disclose what happens if the element does not exist (error? empty response?) or any performance implications. The description is neutral but minimally informative.

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 a single, efficient sentence that conveys the core purpose. It front-loads the action and object. However, some might argue brevity sacrifices useful context like output format.

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

Completeness2/5

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

No output schema exists, and the description does not outline what the definition contains (e.g., domain, data type, length). For a fetch tool, knowing the response structure is important for agent decision-making. The description is incomplete for practical use.

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?

Schema coverage is 100% with clear param descriptions. The tool description adds no extra parameter semantics beyond restating 'data element definition'. Baseline of 3 is appropriate since schema already describes the parameters adequately.

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 'Fetch DDIC data element definition from SAP system' clearly states the action (fetch), the specific resource (DDIC data element), and the domain (SAP system). It distinguishes itself from sibling tools like get_table or get_domain by naming a distinct object type.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. For example, it does not mention that the data element is an ABAP Dictionary concept, nor does it contrast with other get_* tools for different object types.

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/ethanhan2014/sap-adt-mcp'

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