Skip to main content
Glama

ActivateMetadataExtension

Activates a CDS metadata extension that remains inactive after creation or update.

Instructions

Activate a CDS metadata extension. Use after CreateMetadataExtension or UpdateMetadataExtension if the object remains inactive.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesMetadata extension name (e.g., ZC_MY_EXTENSION).
session_idNoSession ID from GetSession. If not provided, a new session will be created.
session_stateNoSession state from GetSession (cookies, csrf_token, cookie_store). Required if session_id is provided.

Implementation Reference

  • Main handler function that activates an ABAP metadata extension using AdtClient.activateMetadataExtension. Validates input, restores session state, calls the ADT client, parses the activation response, and returns success/error details including messages, warnings, and errors.
    export async function handleActivateMetadataExtension(
      context: HandlerContext,
      args: ActivateMetadataExtensionArgs,
    ) {
      const { connection, logger } = context;
      try {
        const { name, session_id, session_state } =
          args as ActivateMetadataExtensionArgs;
    
        // Validation
        if (!name) {
          return return_error(new Error('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 metadataExtensionName = name.toUpperCase();
    
        logger?.info(
          `Starting metadata extension activation: ${metadataExtensionName}`,
        );
    
        try {
          // Activate metadata extension
          const activateState = await client
            .getMetadataExtension()
            .activate({ name: metadataExtensionName });
          const response = activateState.activateResult;
    
          if (!response) {
            throw new Error(
              `Activation did not return a response for metadata extension ${metadataExtensionName}`,
            );
          }
    
          // Parse activation response
          const activationResult = parseActivationResponse(response.data);
          const success = activationResult.activated && activationResult.checked;
    
          // Get updated session state after activation
    
          logger?.info(
            `✅ ActivateMetadataExtension completed: ${metadataExtensionName}`,
          );
          logger?.debug(
            `Activated: ${activationResult.activated}, Checked: ${activationResult.checked}, Messages: ${activationResult.messages.length}`,
          );
    
          return return_response({
            data: JSON.stringify(
              {
                success,
                name: metadataExtensionName,
                activation: {
                  activated: activationResult.activated,
                  checked: activationResult.checked,
                  generated: activationResult.generated,
                },
                messages: activationResult.messages,
                warnings: activationResult.messages.filter(
                  (m) => m.type === 'warning' || m.type === 'W',
                ),
                errors: activationResult.messages.filter(
                  (m) => m.type === 'error' || m.type === 'E',
                ),
                session_id: session_id || null,
                session_state: null, // Session state management is now handled by auth-broker,
                message: success
                  ? `Metadata extension ${metadataExtensionName} activated successfully`
                  : `Metadata extension ${metadataExtensionName} activation completed with ${activationResult.messages.length} message(s)`,
              },
              null,
              2,
            ),
          } as AxiosResponse);
        } catch (error: any) {
          logger?.error(
            `Error activating metadata extension ${metadataExtensionName}: ${error?.message || error}`,
          );
    
          // Parse error message
          let errorMessage = `Failed to activate metadata extension: ${error.message || String(error)}`;
    
          if (error.response?.status === 404) {
            errorMessage = `Metadata extension ${metadataExtensionName} 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);
      }
    }
  • TOOL_DEFINITION constant defining the tool's name ('ActivateMetadataExtensionLow'), description, and inputSchema. The inputSchema specifies 'name' (required string), plus optional 'session_id' and 'session_state'.
    export const TOOL_DEFINITION = {
      name: 'ActivateMetadataExtensionLow',
      available_in: ['onprem', 'cloud'] as const,
      description:
        'Operation: Activate, Create, Update. Subject: MetadataExtension. Will be useful for activating, creating, or updating metadata extension. [low-level] Activate an ABAP metadata extension. Returns activation status and any warnings/errors. Can use session_id and session_state from GetSession to maintain the same session.',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Metadata extension name (e.g., ZC_MY_EXTENSION).',
          },
          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: ['name'],
      },
    } as const;
  • TypeScript interface ActivateMetadataExtensionArgs defining the shape of the handler arguments (name, session_id, session_state).
    interface ActivateMetadataExtensionArgs {
      name: string;
      session_id?: string;
      session_state?: {
        cookies?: string;
        csrf_token?: string;
        cookie_store?: Record<string, string>;
      };
    }
  • Registration of the tool as 'ActivateMetadataExtension' in the HighLevelHandlersGroup. It takes the TOOL_DEFINITION from the low-level handler, overrides the name to 'ActivateMetadataExtension', adds a high-level description, and wires it to handleActivateMetadataExtension wrapped with context.
    {
      toolDefinition: {
        ...ActivateMetadataExtension_Tool,
        name: 'ActivateMetadataExtension',
        description:
          'Activate a CDS metadata extension. Use after CreateMetadataExtension or UpdateMetadataExtension if the object remains inactive.',
      },
      handler: withContext(handleActivateMetadataExtension),
    },
  • Import of the TOOL_DEFINITION (aliased as ActivateMetadataExtension_Tool) and handleActivateMetadataExtension from the low-level handler file.
    import {
      TOOL_DEFINITION as ActivateMetadataExtension_Tool,
      handleActivateMetadataExtension,
    } from '../../../handlers/ddlx/low/handleActivateMetadataExtension';
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It only says 'Activate' without explaining what that entails (e.g., state change, side effects, permissions needed, failure scenarios). Important details are missing.

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 a single concise sentence that immediately conveys the purpose and usage context. No unnecessary words.

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?

Given the simple nature of the tool and no output schema, the description is minimally adequate. However, it lacks details about what activation means technically, error handling, or prerequisites beyond the usage hint. It is sufficient for a straightforward action but not fully complete.

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%, so parameters are already documented. The description adds no extra meaning beyond the schema. It only mentions 'name' implicitly but does not explain session parameters or their roles 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 verb 'Activate' and the resource 'CDS metadata extension'. It also specifies when to use it ('after CreateMetadataExtension or UpdateMetadataExtension if the object remains inactive'), which distinguishes it from other sibling activation tools.

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

Usage Guidelines4/5

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

The description explicitly tells when to use the tool: after Create/Update if the object is inactive. This gives clear context. It does not mention alternatives like CheckMetadataExtension to verify status first, but the guidance is sufficient for an activation step.

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