Skip to main content
Glama

import_impex

Import data into SAP Commerce Cloud using ImpEx format to manage products, orders, and configurations.

Instructions

Import data using ImpEx format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
impexContentYesImpEx content to import

Implementation Reference

  • The importImpex handler, implemented in HybrisClient, which executes a Groovy script on the Hybris server to import data using the ImportService.
      async importImpex(impexContent: string): Promise<ImpexResult> {
        // Use Groovy script for ImpEx import with ImportService
        const escapedContent = this.escapeGroovyString(impexContent);
    
        const script = `
    import de.hybris.platform.servicelayer.impex.ImportService
    import de.hybris.platform.servicelayer.impex.ImportConfig
    import de.hybris.platform.servicelayer.impex.impl.StreamBasedImpExResource
    
    try {
        def impexContent = "${escapedContent}"
        def importService = spring.getBean("importService")
    
        def config = new ImportConfig()
        def resource = new StreamBasedImpExResource(
            new ByteArrayInputStream(impexContent.getBytes("UTF-8")),
            "UTF-8"
        )
        config.setScript(resource)
        config.setEnableCodeExecution(true)
    
        def importResult = importService.importData(config)
    
        if (importResult.hasUnresolvedLines()) {
            println "WARNING: Import completed with unresolved lines"
            importResult.unresolvedLines.allLines.each { line ->
                println "  Unresolved: " + line
            }
        }
    
        if (importResult.isError()) {
            println "ERROR: Import failed"
            if (importResult.unresolvedLines?.allLines) {
                importResult.unresolvedLines.allLines.each { line ->
                    println "  Error: " + line
                }
            }
            return "ERROR"
        }
    
        println "SUCCESS: ImpEx import completed"
        return "SUCCESS"
    } catch (Exception e) {
        println "ERROR: " + e.getMessage()
        e.printStackTrace()
        return "ERROR: " + e.getMessage()
    }
    `;
        const result = await this.executeGroovyScript(script, true); // commit=true for imports
        const output = result.output || '';
        const execResult = String(result.result || '');
        const success = output.includes('SUCCESS:') || execResult === 'SUCCESS';
        const errors: string[] = [];
    
        // Extract unresolved lines as errors
        const unresolvedMatch = output.match(/Unresolved: (.+)/g);
        if (unresolvedMatch) {
          errors.push(...unresolvedMatch);
        }
    
        const errorMatch = output.match(/ERROR: (.+)/);
        if (errorMatch) {
          errors.push(errorMatch[1]);
        }
    
        return {
          success,
          message: output || execResult,
          errors: errors.length > 0 ? errors : undefined,
        };
      }
  • src/index.ts:430-434 (registration)
    Registration and invocation of the import_impex tool in the main MCP server request handler.
    case 'import_impex':
      result = await hybrisClient.importImpex(
        validateString(args, 'impexContent', true)
      );
      break;

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