Applicability
When to Use
✓When external systems use different terminology or data models
✓When you want to prevent leaking external concepts into your codebase
✓When migrating between systems incrementally
Overview
How It Works
The Anti-Corruption Layer (ACL) translates between your internal domain model and external MCP server data formats. Instead of letting Salesforce field names or Stripe charge structures leak into your business logic, the ACL translates at the boundary.
This keeps your code clean and insulated from changes in external systems. If Salesforce renames a field, only the ACL needs updating, not every piece of business logic that uses customer data.
Implementation
Code Example
typescript
// Anti-corruption layer for Salesforce
const salesforceACL = {
async getCustomer(customerId) {
const sfContact = await salesforce.getContact({ id: customerId });
// Translate Salesforce model to our domain model
return {
id: sfContact.Id,
name: `${sfContact.FirstName} ${sfContact.LastName}`,
email: sfContact.Email,
company: sfContact.Account?.Name,
tier: mapSalesforceTier(sfContact.Customer_Tier__c),
signupDate: new Date(sfContact.CreatedDate)
};
}
};
function mapSalesforceTier(sfTier) {
const map = { "Enterprise": "enterprise", "Professional": "pro", "Starter": "free" };
return map[sfTier] || "free";
}
// Business logic uses clean domain model
const customer = await salesforceACL.getCustomer(id);
if (customer.tier === "enterprise") grantPremiumAccess(customer);Quick Info
Categoryintegration
ComplexityMedium