Skip to main content
Glama
Emenowicz

Hybris MCP Server

by Emenowicz

execute_groovy

Execute Groovy scripts in SAP Commerce Cloud to automate tasks, manage data, and perform system administration 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

  • MCP tool handler for 'execute_groovy': validates input arguments and delegates execution to HybrisClient.executeGroovyScript.
    case 'execute_groovy':
      result = await hybrisClient.executeGroovyScript(
        validateString(args, 'script', true),
        validateBoolean(args, 'commit', false)
      );
      break;
  • Input schema for the 'execute_groovy' tool defining the expected parameters: required 'script' string and optional 'commit' boolean.
    inputSchema: {
      type: 'object',
      properties: {
        script: {
          type: 'string',
          description: 'Groovy script to execute',
        },
        commit: {
          type: 'boolean',
          description: 'Whether to commit database changes (default: false)',
        },
      },
      required: ['script'],
    },
  • src/index.ts:212-229 (registration)
    Registration of the 'execute_groovy' tool in the MCP tools list, including name, description, and input schema.
    {
      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)',
          },
        },
        required: ['script'],
      },
    },
  • Core helper method implementing Groovy script execution by posting to Hybris HAC scripting endpoint and mapping the response.
    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,
      };
    }

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

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