Rise of the Agentic 'Strangler Fig' Strategy
Source: Dev.to
Overview
Stop trying to rewrite your 15‑year‑old monolith from scratch. It won’t work. Instead, use the Model Context Protocol (MCP) to wrap your legacy systems in AI agents—a “Strangler Fig” pattern on steroids. 🚀
The “Big Bang” rewrite is a comforting myth. You stare at a distributed monolith, imagine pausing feature development for 18 months to rewrite everything in Rust/Go/Next.js, and hope for perfection. Spoiler: it won’t happen.
The Problem: Code‑to‑Context Gap
Your legacy system holds decades of implicit business knowledge—edge cases, regulatory hacks, and quirky bug fixes—that exist only in the code, not in Jira or Confluence. Rewriting from scratch discards that context.
The Agentic Strangler Fig Strategy
The classic Martin Fowler Strangler Fig pattern wraps the old system, intercepts calls, and gradually routes them to new microservices. It’s safe but traditionally slow because building facades, mapping dependencies, and writing glue code is manual and soul‑crushing.
New angle: Deploy AI agents equipped with MCP tools to create a dynamic, intelligent Strangler Fig that operates at AI speed.
1. The Universal Adapter (MCP) 🔌
MCP solves the N × M connectivity problem. Instead of building bespoke API wrappers for every legacy database and service, you create a single MCP server. Unlike a stateless REST API, an MCP interface maintains context, allowing an AI agent to understand “User X” across a session and query both a 1980s mainframe and a 2024 cloud SQL database in the same breath.
2. The Agent as the Dynamic Facade 🎭
An MCP‑enabled agent receives a high‑level intent, e.g.:
“Process a refund for User X.”
The agent:
- Checks its available tools.
- Sees
legacy_inventory_update(Monolith) andrefund_service_v2(New Microservice). - Dynamically chains them together.
No manual route configuration is needed. Deploy a new microservice tomorrow, and the agent automatically discovers and starts using it.
Implementation Steps
Step 1: Design for Intent (Anti‑Pattern Alert! 🚨)
Do not map legacy APIs 1:1 to MCP tools. Legacy APIs are littered with junk parameters and odd auth flows that confuse LLMs.
Bad – 1:1 Mapping
{
"name": "get_customer_data",
"description": "Calls GET /api/v1/cust",
"parameters": {
"id": "string",
"include_orders": "boolean",
"sort": "string",
"legacy_flag_23": "boolean"
}
}
Good – Intent‑Based
@mcp.tool()
def get_customer_dashboard(email: str) -> str:
"""
Retrieves a holistic view of the customer, aggregating
data from the legacy CRM and the new Order Service.
"""
# The complexity is hidden here!
legacy_data = legacy_crm.lookup(email)
new_data = order_service.get_latest(email)
return format_dashboard(legacy_data, new_data)
Encapsulate complexity inside the MCP server and expose high‑level “Business Intent” tools to the agent.
Step 2: Port Isolation via Proxying 🛡️
A proxy sits between the agent and your infrastructure, handling dynamic port allocation. The agent interacts through a clean, consistent stdio interface.
Step 3: The “Shadow Write” Pattern 👻
-
Agent receives a “Create Order” request.
-
Writes to the new microservice database.
-
In parallel, writes to the legacy monolith via the MCP wrapper.
-
Compares results:
- Match: ✅ Proceed.
- Mismatch: ❌ Log the diff for engineers to resolve.
This validates the new system with live production traffic without risking data integrity.
Real‑World Examples
- Insurance: Companies like Sure report a 95 % faster quote‑to‑bind time. Their agents not only chat; they use MCP tools to autonomously file claims in the legacy backend.
- Supply Chain: Boomi unifies fragmented WMS and ERP systems. Agents act as glue, checking inventory across siloed systems and triggering restocking workflows that no single legacy app could handle alone.
Benefits
- Decouple Technical Debt from Business Value: Traditional migrations require paying down debt before delivering value. MCP agents let you deliver value first—wrap the monolith, strangle the legacy, and ship modern features immediately.
- Automatic Discovery: New microservices become instantly usable by existing agents.
- Reduced Rewrite Risk: Preserve decades of hidden business logic while modernizing incrementally.
Further Reading
- Migrating legacy services to a modern developer portal: A technical guide to Backstage integration
- Why MCP Shouldn’t Wrap an API One‑to‑One
- Scaling AI Agents with Aspire: The Missing Isolation Layer for Parallel Development
- The Protocol of Doing
Got a monolith horror story? Drop it in the comments. Let’s commiserate. 👇