Skip to main content
Glama

GetLocalMacros

Retrieve local macros source code from an ABAP class, supporting active or inactive version reading.

Instructions

Retrieve local macros source code from a class (macros include). Supports reading active or inactive version. Note: Macros are supported in older ABAP versions but not in newer ones.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
class_nameYesParent class name (e.g., ZCL_MY_CLASS).
versionNoVersion to read: "active" (default) for deployed version, "inactive" for modified but not activated version.active

Implementation Reference

  • The main handler function that executes the GetLocalMacros tool logic. Creates an ADT client, reads local macros source code for a given class name and version, and returns the result.
    export async function handleGetLocalMacros(
      context: HandlerContext,
      args: GetLocalMacrosArgs,
    ) {
      const { connection, logger } = context;
      try {
        const { class_name, version = 'active' } = args as GetLocalMacrosArgs;
    
        if (!class_name) {
          return return_error(new Error('class_name is required'));
        }
    
        const client = createAdtClient(connection, logger);
        const className = class_name.toUpperCase();
    
        logger?.info(`Reading local macros for ${className}, version: ${version}`);
    
        try {
          const localMacros = client.getLocalMacros();
          const readResult = await localMacros.read(
            { className },
            version as 'active' | 'inactive',
          );
    
          if (!readResult || !readResult.readResult) {
            throw new Error(`Local macros for ${className} not found`);
          }
    
          const sourceCode =
            typeof readResult.readResult.data === 'string'
              ? readResult.readResult.data
              : JSON.stringify(readResult.readResult.data);
    
          logger?.info(`✅ GetLocalMacros completed successfully: ${className}`);
    
          return return_response({
            data: JSON.stringify(
              {
                success: true,
                class_name: className,
                version,
                macros_code: sourceCode,
                status: readResult.readResult.status,
              },
              null,
              2,
            ),
          } as AxiosResponse);
        } catch (error: any) {
          logger?.error(
            `Error reading local macros for ${className}: ${error?.message || error}`,
          );
    
          let errorMessage = `Failed to read local macros: ${error.message || String(error)}`;
    
          if (error.response?.status === 404) {
            errorMessage = `Local macros for ${className} not found.`;
          } else if (error.response?.status === 423) {
            errorMessage = `Class ${className} is locked by another user.`;
          }
    
          return return_error(new Error(errorMessage));
        }
      } catch (error: any) {
        return return_error(error);
      }
    }
  • TOOL_DEFINITION constant defining the tool name, availability, description, and inputSchema with required class_name and optional version parameter.
    export const TOOL_DEFINITION = {
      name: 'GetLocalMacros',
      available_in: ['onprem', 'cloud', 'legacy'] as const,
      description:
        'Retrieve local macros source code from a class (macros include). Supports reading active or inactive version. Note: Macros are supported in older ABAP versions but not in newer ones.',
      inputSchema: {
        type: 'object',
        properties: {
          class_name: {
            type: 'string',
            description: 'Parent class name (e.g., ZCL_MY_CLASS).',
          },
          version: {
            type: 'string',
            enum: ['active', 'inactive'],
            description:
              'Version to read: "active" (default) for deployed version, "inactive" for modified but not activated version.',
            default: 'active',
          },
        },
        required: ['class_name'],
      },
    } as const;
  • Registration of the GetLocalMacros tool in the HighLevelHandlersGroup, mapping the tool definition to its handler with context.
    {
      toolDefinition: GetLocalMacros_Tool,
      handler: withContext(handleGetLocalMacros),
    },
  • Registration in the compact router, mapping 'LOCAL_MACROS' -> 'get' to the handleGetLocalMacros handler.
    LOCAL_MACROS: {
      get: handleGetLocalMacros as unknown as CompactHandler,
      update: handleUpdateLocalMacros as unknown as CompactHandler,
      delete: handleDeleteLocalMacros as unknown as CompactHandler,
  • Import of the tool definition and handler from the implementation file into the HighLevelHandlersGroup.
    import {
      TOOL_DEFINITION as GetLocalMacros_Tool,
      handleGetLocalMacros,
    } from '../../../handlers/class/high/handleGetLocalMacros';
Behavior3/5

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

With no annotations, the description carries full burden. It adds a note that macros are supported in older ABAP versions but not newer ones, which is helpful. However, it does not disclose behavior for errors like non-existent class or empty macros.

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 concise, using only two sentences to convey the essential purpose and a usage note. No extraneous information.

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

Completeness3/5

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

The description covers the basic operation but lacks information about the return format (what the source code output looks like) and prerequisites (e.g., class must exist). For a simple tool with few parameters, it is adequately complete but could be improved.

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 description coverage is 100%, so baseline is 3. The description repeats the version parameter details already present in the schema, adding no new meaning beyond what the schema provides.

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 the tool retrieves local macros source code from a class, with the ability to read active or inactive versions. It distinguishes from sibling tools like GetLocalDefinitions by being specific to macros.

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?

The description implies usage for macros in older ABAP versions, but does not explicitly state when to use or when to avoid this tool. No alternatives are mentioned, leaving the agent to infer from context.

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