export_impex
Export data from SAP Commerce Cloud to ImpEx format using FlexibleSearch queries for data migration, backup, or system integration.
Instructions
Export data to ImpEx format using a FlexibleSearch query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| flexQuery | Yes | FlexibleSearch query for data to export |
Implementation Reference
- src/hybris-client.ts:570-616 (handler)The core handler function exportImpex in HybrisClient that generates ImpEx export using a FlexibleSearch query executed via Groovy script in HAC.async exportImpex(flexQuery: string): Promise<string> { // Use Groovy script for ImpEx export const escapedQuery = this.escapeGroovyString(flexQuery); const script = ` try { def flexibleSearchService = spring.getBean("flexibleSearchService") def query = "${escapedQuery}" def searchResult = flexibleSearchService.search(query) if (searchResult.result.isEmpty()) { println "No results found for query" return "# No results found" } // Build ImpEx header from first item def firstItem = searchResult.result[0] def itemType = firstItem.itemtype // Use lowercase 'itemtype' property def sb = new StringBuilder() sb.append("# Exported from FlexibleSearch: ").append(query).append("\\n") sb.append("# Result count: ").append(searchResult.totalCount).append("\\n\\n") // Simple export format sb.append("INSERT_UPDATE ").append(itemType).append(";pk[unique=true]\\n") searchResult.result.each { item -> sb.append(";").append(item.PK.toString()).append("\\n") } println "SUCCESS: Exported " + searchResult.result.size() + " items" return sb.toString() } catch (Exception e) { println "ERROR: " + e.getMessage() e.printStackTrace() return "# Error: " + e.getMessage() } `; const result = await this.executeGroovyScript(script); const execResult = String(result.result || ''); // If result looks like ImpEx content, return it if (execResult.includes('INSERT_UPDATE') || execResult.includes('# ')) { return execResult; } return result.output || execResult || '# Export failed'; }
- src/index.ts:247-256 (schema)Input schema for the export_impex tool, defining the required 'flexQuery' string parameter.inputSchema: { type: 'object', properties: { flexQuery: { type: 'string', description: 'FlexibleSearch query for data to export', }, }, required: ['flexQuery'], },
- src/index.ts:245-257 (registration)Registration of the 'export_impex' tool in the MCP tools list.name: 'export_impex', description: 'Export data to ImpEx format using a FlexibleSearch query', inputSchema: { type: 'object', properties: { flexQuery: { type: 'string', description: 'FlexibleSearch query for data to export', }, }, required: ['flexQuery'], }, },
- src/index.ts:428-432 (helper)Dispatcher switch case that handles MCP tool calls for 'export_impex' by invoking the HybrisClient.exportImpex method with validated arguments.case 'export_impex': result = await hybrisClient.exportImpex( validateString(args, 'flexQuery', true) ); break;