Skip to main content
Glama

execute_groovy

Execute Groovy scripts in SAP Commerce Cloud to automate tasks, manage data, and configure system settings through the Hybris scripting console.

Instructions

Execute a Groovy script in the Hybris scripting console

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scriptYesGroovy script to execute
commitNoWhether to commit database changes (default: false)

Implementation Reference

  • The core implementation of the Groovy script execution logic using the Hybris HAC API.
    async executeGroovyScript(script: string, commit = false): Promise<{ output: string; result: unknown }> {
      const formData = new URLSearchParams({
        script,
        scriptType: 'groovy',
        commit: commit.toString(),
      });
    
      const response = await this.hacRequest<{
        outputText?: string;
        executionResult?: unknown;
        stacktraceText?: string;
      }>(
        `${this.hacPrefix}/console/scripting/execute`,
        {
          method: 'POST',
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
          },
          body: formData,
        }
      );
    
      // Map HAC response fields to our expected format
      return {
        output: response.outputText || '',
        result: response.executionResult,
      };
    }
    
    async importImpex(impexContent: string): Promise<ImpexResult> {
      // Use Groovy script for ImpEx import with ImportService
  • src/index.ts:212-225 (registration)
    Tool definition for 'execute_groovy' registered in the MCP tool list.
    {
      name: 'execute_groovy',
      description: 'Execute a Groovy script in the Hybris scripting console',
      inputSchema: {
        type: 'object',
        properties: {
          script: {
            type: 'string',
            description: 'Groovy script to execute',
          },
          commit: {
            type: 'boolean',
            description: 'Whether to commit database changes (default: false)',
          },
  • The tool execution handler that processes requests by calling the hybrisClient.
    case 'execute_groovy':
      result = await hybrisClient.executeGroovyScript(
        validateString(args, 'script', true),
        validateBoolean(args, 'commit', false)
      );

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/mcieunic/hybris-mcp-main'

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