Skip to main content
Glama

ActivateView

Activate an inactive CDS view after creation or update to make it active.

Instructions

Activate a CDS view. Use after CreateView or UpdateView if the object remains inactive.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
view_nameYesView name (e.g., ZVW_MY_VIEW).
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 for the ActivateView MCP tool. Uses AdtClient to activate a CDS view, parses the activation response, and returns success/error details with warnings and errors.
    export async function handleActivateView(
      context: HandlerContext,
      args: ActivateViewArgs,
    ) {
      const { connection, logger } = context;
      try {
        const { view_name, session_id, session_state } = args as ActivateViewArgs;
    
        // Validation
        if (!view_name) {
          return return_error(new Error('view_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 viewName = view_name.toUpperCase();
    
        logger?.info(`Starting view activation: ${viewName}`);
    
        try {
          // Activate view
          const activateState = await client
            .getView()
            .activate({ viewName: viewName });
          const response = activateState.activateResult;
    
          if (!response) {
            throw new Error(
              `Activation did not return a response for view ${viewName}`,
            );
          }
    
          // Parse activation response
          const activationResult = parseActivationResponse(response.data);
          const success = activationResult.activated && activationResult.checked;
    
          // Get updated session state after activation
    
          logger?.info(`✅ ActivateView completed: ${viewName}`);
          logger?.info(
            `   Activated: ${activationResult.activated}, Checked: ${activationResult.checked}`,
          );
          logger?.info(`   Messages: ${activationResult.messages.length}`);
    
          return return_response({
            data: JSON.stringify(
              {
                success,
                view_name: viewName,
                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
                  ? `View ${viewName} activated successfully`
                  : `View ${viewName} activation completed with ${activationResult.messages.length} message(s)`,
              },
              null,
              2,
            ),
          } as AxiosResponse);
        } catch (error: any) {
          logger?.error(
            `Error activating view ${viewName}: ${error?.message || error}`,
          );
    
          // Parse error message
          let errorMessage = `Failed to activate view: ${error.message || String(error)}`;
    
          if (error.response?.status === 404) {
            errorMessage = `View ${viewName} 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);
      }
    }
  • TypeScript interface defining the input arguments for the ActivateView handler (view_name required, optional session_id and session_state).
    interface ActivateViewArgs {
      view_name: string;
      session_id?: string;
      session_state?: {
        cookies?: string;
        csrf_token?: string;
        cookie_store?: Record<string, string>;
      };
    }
  • Tool definition/schema for the low-level ActivateViewLow tool, containing inputSchema with view_name (required), session_id, and session_state fields.
    export const TOOL_DEFINITION = {
      name: 'ActivateViewLow',
      available_in: ['onprem', 'cloud', 'legacy'] as const,
      description:
        'Operation: Activate, Create, Update. Subject: View. Will be useful for activating, creating, or updating view. [low-level] Activate an ABAP view (CDS view). 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: {
          view_name: {
            type: 'string',
            description: 'View name (e.g., ZVW_MY_VIEW).',
          },
          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: ['view_name'],
      },
    } as const;
  • Registration of the ActivateView tool in the HighLevelHandlersGroup, which reuses the low-level handler but overrides the name to 'ActivateView' and provides a high-level description.
    {
      toolDefinition: {
        ...ActivateView_Tool,
        name: 'ActivateView',
        description:
          'Activate a CDS view. Use after CreateView or UpdateView if the object remains inactive.',
      },
      handler: withContext(handleActivateView),
    },
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', which implies state change but does not explain side effects, prerequisites (beyond session), errors, or whether it can be undone. This is insufficient for a tool with no annotations.

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 extremely concise with two sentences. The first sentence states the action, the second provides a usage hint. No wasted 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?

The tool is simple with 3 parameters and no output schema. The description covers the basic purpose and usage context. However, it does not explain what the tool returns (success, error), leaving the agent uninformed about the response.

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 descriptions for all parameters. The description adds no additional meaning beyond the schema. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Activate a CDS view', which is a specific verb+resource. It is distinguishable from sibling Activate* tools for other object types. However, the concept of activation in SAP CDS is not elaborated.

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 says to use 'after CreateView or UpdateView if the object remains inactive', providing clear when-to-use guidance. No exclusion criteria are given, but the context is sufficient.

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