Legacy system modernisation AI works best when you do not connect an agent directly to an ERP database. Instead, put controlled APIs, a semantic layer and an agent-facing tool interface between the model and the system of record. This tutorial walks through a small, reversible implementation, from choosing a read-only use case to testing permissions, data quality and rollback.
The goal is not to make an agent autonomous across your ERP. It is to let it answer one useful business question using trusted records, then, if needed, prepare a narrowly defined action for a person to approve. If you are assessing where to start, our AI strategy and solutioning service can help identify a suitable first use case and its controls.
What legacy system modernisation AI will build, and what it will not
For this walkthrough, imagine a distributor whose staff check an old ERP to answer: “Can we fulfil order 48217, and what is holding it up?” The ERP contains the customer order, lines, inventory and shipment status. Staff currently switch between several screens and interpret internal field names.
You will build a read-only assistant that can:
- Look up an order through a controlled endpoint.
- Read a small, clearly defined set of order and stock facts.
- Explain the result in plain language, with the source fields or record identifiers available for verification.
- Refuse to guess when records are missing, conflicting or outside the user’s access.
You will not let the model run SQL, update ERP tables, release inventory or promise a delivery date. Those are separate capabilities with separate controls. The first integration should reduce effort without granting authority to change business records.
The architecture has four main boundaries:
| Layer | Responsibility | Example in this tutorial |
|---|---|---|
| Legacy ERP | Remains the system of record | Existing order and inventory records |
| Read interface | Retrieves only approved facts | A service endpoint or reporting replica |
| Semantic layer | Gives fields and metrics business meaning | order_status, available_to_promise |
| Agent tool interface | Makes safe functions discoverable to the model | An MCP server exposing get_order_status |
A semantic layer is a governed description of business concepts, such as what counts as available stock or an overdue invoice. It keeps that meaning out of individual prompts and agent code. Cube’s overview of semantic layer architecture describes how this layer can provide consistent definitions and controlled access to data.
The Model Context Protocol documentation explains MCP as a protocol for connecting AI applications to external tools and context. In this design, MCP is the interface the agent uses. It is not the security boundary by itself. Your service, identity controls and data policies still need to enforce permissions.
What you need before you start
You need an ERP owner, an engineer who can inspect the integration options, and a business owner who can define the meaning of the answer. Understanding how to prepare legacy systems for AI integration requires aligning these stakeholders around data accessibility before writing software. Include security and operations early if the system supports a regulated or business-critical process.
Prepare the following:
- A bounded use case. Pick one question, one user group and one process. Avoid “chat with the ERP” as a goal. It is too broad to test or secure.
- A data dictionary or field map. It can be incomplete. You need enough to identify the order key, customer reference, line status, quantities, inventory location and update timestamps.
- A safe read path. Prefer an existing supported API, a reporting replica or a change-data-capture (CDC) copy. CDC is a way to copy database changes into another system as they occur. Do not assume the ERP can tolerate new agent-driven queries against its live database.
- A service boundary. The boundary should authenticate callers, check authorisation, validate input and return only approved fields. It can be a small service in your existing stack.
- A semantic contract. Write down what each returned concept means. For example, “available to promise” might subtract reserved units from usable stock, but your operations team must confirm the actual rule.
- A test set. Ask process owners for representative cases, including normal orders, cancelled orders, partial shipments, missing records and users who should not see a customer’s data.
- An environment and logging plan. Start in a non-production environment or use synthetic and masked records. Decide what you will log, how long logs are retained and which fields must never enter a prompt or trace.
You can use a simple API service and an MCP server, or a platform that combines some of these functions. The tool choice matters less than the separation of duties. An agent should not inherit broad database credentials just because the first prototype is easier that way.
Step 1: Choose one question that can be checked
Turn the business request into a testable task. “Help the service desk with orders” is not testable. “For an order ID supplied by an authenticated service agent, return current line status, the latest shipment event and whether recorded stock is sufficient” is much closer.
Write the expected answer as facts, not as a piece of polished prose. For example:
- Order exists: yes or no.
- Order status: the approved status value from the ERP mapping.
- Ordered quantity: number of units on the order line.
- Available quantity: the value defined by the stock rule.
- Shipment event: most recent event and its recorded time.
- Data freshness: when the source was last updated or synchronised.
- Permission result: whether this caller may access this order.
Set explicit exclusions. If the system cannot calculate a delivery estimate from a trusted source, the assistant must say it cannot confirm the delivery date. If inventory is not current enough for an operational decision, it should disclose that or refuse to answer, rather than turning stale data into a confident recommendation.
Write acceptance tests before building the interface. A useful test is not “the answer sounds right.” It is “the response identifies the correct order, uses the approved status mapping, shows the stock calculation inputs, and does not reveal another customer’s records.” Include cases where the correct result is a refusal.
What you should see: a one-page use-case definition, a list of allowed inputs and outputs, and test cases that a business owner can judge without reading code.
How to check it worked: give the definition to someone who did not write it. Ask them to identify what the agent may do, what it must not do and how they would verify a response. If their answers differ from yours, narrow the task before proceeding.
Step 2: Trace the records and establish a source of truth
Next, find where each answer comes from. Do not begin by asking a model to infer the schema. Ask the ERP owner or application team to trace the relevant records, joins, status codes and update paths.
Create a source map such as this:
| Business fact | Legacy source | Transformation or rule | Freshness and owner |
|---|---|---|---|
| Order identifier | Order header key | Map internal key to customer-facing order ID | ERP transaction; order team |
| Line status | Order line status code | Translate approved codes to business labels | ERP transaction; fulfilment team |
| Ordered units | Order line quantity | Apply unit-of-measure conversion if required | ERP transaction; order team |
| Usable stock | Inventory balance and holds | Exclude quarantined or allocated stock per confirmed rule | Stock feed; warehouse team |
| Latest shipment event | Shipment event records | Select latest valid event using event time and status rules | Carrier or ERP interface; logistics team |
The table is illustrative. Your ERP’s identifiers and business rules will differ. Do not copy familiar-looking field names from another company or assume a column’s meaning from its label. Confirm edge cases with people who operate the process.
For the read path, use the least disruptive supported route. An ERP’s official API is often preferable when it has the needed data and access controls. A reporting replica can work when the information is already replicated for analytics. CDC may be appropriate when you need a separate, frequently updated store and can operate the pipeline safely. CDC is not automatically real time, complete or simpler than an API. You need to understand transaction ordering, deletes, schema changes, replay and recovery.
Avoid building an agent feature on top of undocumented direct database access. Raw ERP schemas can contain internal codes, duplicated representations and relationships that are meaningful only within a particular module. A replica protects the production workload from some read pressure, but it does not make the data understandable or safe to expose.
For a broader look at progressive replacement, the strangler fig pattern for replacing legacy systems is a useful starting point. The key idea is to route a defined capability through a new boundary and replace it in stages, rather than attempting a single all-at-once rewrite. Wrapping an ERP API is not itself a strangler migration. It becomes part of that pattern when you can progressively move defined functions behind the facade and route them to new implementations.
What you should see: a verified map from each user-facing fact to its source, transformation rule and business owner.
How to check it worked: take a handful of known orders and compare the mapped output with the ERP screens or the authorised source report. Include at least one order with a partial shipment or a stock hold. Ask the process owner to explain any mismatch before you proceed.
Step 3: Build the read boundary before the agent
Create a small service that accepts a user identity and an order identifier, checks access and returns a limited response. The service should be usable without an AI model. This is important: it lets you test data correctness and access policy independently from prompt behaviour.
A conceptual request might look like this:
{
"order_id": "48217"
}
The identity should come from your authentication layer, not from a value the model invents. The service should derive the caller’s permitted customer, business unit or account scope from trusted credentials and policy. It should not accept a model-supplied user_id as proof of permission.
A conceptual response could be:
{
"order_id": "48217",
"status": "partially_shipped",
"lines": [
{
"sku": "SKU-104",
"ordered_units": 12,
"available_units": 4,
"shipped_units": 8
}
],
"latest_shipment_event": {
"status": "collected",
"recorded_at": "2026-11-10T09:15:00Z"
},
"source_updated_at": "2026-11-10T09:16:00Z"
}
This is a fabricated example for the tutorial, not a PADISO client record or a statement about a real ERP. In production, return only what the use case requires. Avoid unnecessary personal information, internal notes and free-text fields. Use stable types and explicit missing-value behaviour. A missing shipment event should be represented clearly, not silently converted into an empty string that an agent may misread.
The service should enforce:
- Authentication and authorisation for each request.
- Input validation, including length and allowed identifier formats.
- Parameterised queries or supported API calls, never string-concatenated SQL.
- Request timeouts and sensible result limits.
- Rate limits and monitoring for unusual access patterns.
- Error responses that do not disclose database details or secrets.
- A trace or correlation identifier that lets an operator investigate a request.
Make failure explicit. Distinguish “order not found,” “caller cannot access this order,” “source unavailable” and “data too old for this task.” Whether to reveal that an inaccessible order exists depends on your security design. In some contexts, return the same generic response for not found and not authorised to avoid exposing record existence.
What you should see: a documented endpoint that returns the same verified business facts every time for the same authorised source state, without any model in the request path.
How to check it worked: call the endpoint as an allowed user, an unauthorised user and an unauthenticated user. Confirm that only the first receives the permitted data, invalid inputs fail safely and a source outage does not produce invented values.
Step 4: Put business meaning in a semantic layer
The semantic layer translates technical fields into stable concepts. It can sit in a data platform, in an embedded analytics architecture, in a service domain model or in a dedicated semantic product. The important requirement is that it has a clear owner, version history and testable definitions.
For this order example, define terms such as:
order_id: the identifier a service employee uses to locate an order.ordered_units: the confirmed quantity for a specific line, in a stated unit.available_units: stock eligible for allocation under a named business rule.shipped_units: units recorded as shipped, with a defined treatment for reversals.latest_shipment_event: the most recent valid event under a documented ordering rule.source_updated_at: the source or pipeline timestamp that indicates freshness.
Do not create a metric called available_to_promise until the supply chain owner confirms the calculation. In one business, available stock may mean on-hand less allocated stock. In another, it may also exclude quality holds, account for expected receipts or follow location-specific rules. The name alone does not settle the definition.
A semantic layer helps prevent each agent or application from inventing its own join and metric logic. It does not eliminate errors automatically. Incorrect source mappings, stale data and weak permissions can still produce incorrect answers. Cube’s article on semantic layers in the AI era discusses why a governed model can serve as an intermediary between data and AI applications.
Keep the first contract small. Give the assistant a read method such as get_order_status(order_id) rather than an unrestricted query interface such as run_sql(query). The first function expresses business intent and can apply policy. The second makes the model responsible for schema discovery, query construction, data minimisation and safe execution at once.
If the source has tenant, company-code or business-unit boundaries, apply them in the service or data platform using trusted identity claims. Do not rely on a prompt instruction such as “only show this company’s data.” Prompt instructions can guide behaviour, but they do not enforce access control.
What you should see: a short, versioned contract that maps every agent-visible field to an approved definition and policy.
How to check it worked: have a business owner sign off each definition, then run the same test cases against the endpoint and any dashboard or report that already represents the metric. Explain any difference before treating the new definition as authoritative.
Step 5: Add an MCP server as a narrow tool interface
Once the endpoint and semantic contract work, expose a controlled function to the agent. An MCP server can describe available tools and handle calls using the protocol. For practical implementations of the Model Context Protocol in ERP workflows, the key is keeping the tool definitions constrained. For this tutorial, expose one tool named get_order_status with a required order_id string. Keep the tool description specific: it retrieves approved status and fulfilment facts for an order the authenticated caller is allowed to access. It does not change the order.
Your MCP server should call the read service, not the ERP database. Keep the existing identity and permission checks in the service. The tool definition is an interface contract, not a substitute for authentication, authorisation or auditing.
A sensible tool design includes:
- A narrow name and a plain-language description of what it does.
- A strict input schema, including required fields and length limits.
- No optional parameters that broaden access without a clear need.
- A predictable response shape and explicit error states.
- An execution timeout and request identifier.
- Logs that record the caller, tool, permitted record scope, result status and correlation ID without unnecessarily copying sensitive payloads.
Configure the model instructions to cite the returned facts and explain when it cannot answer. Tell it not to infer a delivery date, stock commitment or customer promise unless the tool returns an approved field for that purpose. This improves the interaction, but remember that the service must still return only data the caller is allowed to see.
MCP is one way to standardise tool discovery and invocation. A custom REST tool can also be appropriate, particularly if your agent runtime already has a secure, well-maintained integration pattern. The choice should be based on the clients you need to support and how you will operate the interface. MCP does not remove the need to test each client, model and deployment configuration.
What you should see: the agent can discover one read-only tool and call it with a valid order identifier. The returned data should match the service response, not introduce new values.
How to check it worked: inspect the tool call and compare its arguments and result with the underlying service log. Try a malformed identifier, an unauthorised order and an unavailable source. Confirm the agent reports the relevant limitation without making up a status.
Step 6: Test the whole path, including failure cases
Test the integration as a system, not just as a prompt. Use a fixed test set with expected values agreed by the business owner. Include normal cases and cases designed to expose ambiguity.
A minimum test matrix might include:
| Test case | Expected behaviour |
|---|---|
| Valid order with one line | Returns the approved order and line facts |
| Multiple lines with mixed fulfilment | Reports each line separately and avoids collapsing the statuses |
| Cancelled order | Returns the approved cancellation state and does not suggest it can still ship |
| Unknown order identifier | States that the record was not found, subject to your disclosure policy |
| User outside the permitted scope | Returns no protected order details |
| Stale source data | Shows freshness or refuses an operational conclusion according to policy |
| ERP or replica unavailable | Reports a service limitation and does not answer from memory |
| Ambiguous user request | Asks for the missing identifier instead of guessing |
| Prompt injection in a record field | Treats record text as data, not as an instruction to reveal information |
Prompt injection is malicious or accidental text that tries to redirect the model, for example a note in a record that says to ignore the user’s request and disclose other orders. Treat data returned from the ERP as untrusted input. The model should not follow instructions embedded in a customer note, product description or shipment comment. More importantly, the service must not offer a tool that lets such text expand the caller’s permissions.
Measure correctness at the level of each fact. A response may sound coherent while misstating one quantity. Compare returned values against the source and record the discrepancy. Test status translations, time zones, units of measure, deleted records, reversals and duplicate events. These are common places where an apparently simple lookup becomes misleading.
Review logs with security and operations. Check that sensitive fields do not appear in application traces, model prompts, analytics events or error reporting. Restrict log access and set a retention policy. If you use an external model provider, assess the data handling, contractual terms and deployment settings for your organisation before sending any business data.
What you should see: a test report with expected and actual results, explicit failures and an owner for each issue. The aim is not a perfect-looking conversation. It is a known, bounded behaviour that can be monitored.
How to check it worked: have someone other than the implementer run the test set. They should be able to reproduce the results and explain why each failure is safe. Do not treat a successful happy-path demonstration as evidence that access controls or edge cases work.
Step 7: Pilot in shadow or limited mode
Before making the assistant part of the normal workflow, run it in a controlled pilot. A shadow mode can show answers to staff while keeping the existing ERP process as the official route. Staff compare the result with their usual method and flag mismatches. If shadow mode is not practical, start with a small authorised user group and keep the manual process available.
Define operating thresholds before the pilot. These should reflect the cost of being wrong, not just response speed. For example, you may require that all returned order identifiers match the requested record and that the system never returns data outside the caller’s scope. For a freshness-sensitive answer, define the maximum acceptable delay with the process owner. The correct threshold depends on the workflow and cannot be set from an architecture diagram.
During the pilot, review:
- Whether users ask for information outside the tool’s defined purpose.
- How often the endpoint returns missing, stale or conflicting data.
- Whether the assistant identifies uncertainty accurately.
- Whether users can verify the answer from the record or source timestamp.
- Whether permissions behave as designed across roles and business units.
- Whether logs provide enough information to investigate an incident without storing excess data.
- Whether the integration affects ERP, replica or service performance.
Use incidents to improve the interface and source mapping, not only to revise the system prompt. If staff repeatedly ask for an unsupported delivery estimate, decide whether there is a trusted source for that estimate. If not, make the limitation clearer and keep the answer out of scope.
For regulated Australian organisations, include the relevant risk, security, privacy and operational resilience owners in the approval process. Case studies in legacy system modernisation in Australia show that governance alignment prevents costly architectural rollbacks. Map the design to your organisation’s obligations and controls, including any applicable APRA requirements. A staged integration can make changes easier to isolate and roll back, but it does not by itself prove compliance.
What you should see: a pilot decision based on observed errors, access results, data freshness and operational impact, rather than enthusiasm for the demo.
How to check it worked: ask the process owner, technical owner and security owner to review the same evidence. Record unresolved risks, the decision to proceed or pause, and who can disable the feature.
Step 8: Add writes only as a separate, explicit capability
Do not turn the read tool into a general-purpose write tool. If a later use case needs the agent to create a draft or initiate a change, design a separate action with its own permission model, validation and approval path.
For example, a safe progression might be:
- The assistant reads an order and explains its status.
- It drafts a proposed change using a narrowly scoped action such as
create_order_note_draft. - A user reviews the exact change, target record and reason.
- A separate authorised process submits the approved change to the ERP.
- The system records who approved it, what was submitted and whether the ERP accepted it.
The agent should not get a direct SQL write connection or a broad “update order” function. Use parameterised operations and validate business rules at the service boundary. If the ERP supports a supported API or workflow engine for the action, use it rather than writing around the application’s own controls.
For consequential actions, show the proposed values before confirmation and require an authenticated approval tied to the person and transaction. Make retries safe. A network timeout can leave the caller unsure whether an operation succeeded, so use idempotency controls or a reliable status check to avoid duplicate submissions. Include a way to cancel or compensate where the business process supports it.
Keep approval meaningful. A person should see the actual target, values and consequences, not a generic “approve AI action” button. Log the model’s proposal separately from the human decision and the result in the ERP. The model may prepare an action, but the system should enforce whether it is allowed and who can approve it.
What you should see: a separate, least-privilege tool for one action, with clear validation and a review step. It should be possible to disable the action without disabling the read capability.
How to check it worked: test duplicate requests, rejected approvals, expired approvals, permission changes and downstream failure. Confirm there is no path for the agent to bypass the approval or call the ERP with a different identity.
Step 9: Make the wrapper part of a strangler migration
An API wrapper is useful even if the ERP remains in place. But if your goal is to reduce dependence on the legacy core, treat each new interface as a migration seam, not a permanent pile of adapters.
Start by identifying a domain boundary that the business recognises, such as order status, inventory availability or invoice approval. Put the stable contract in front of the existing ERP implementation. At first, the facade routes the request to the legacy system. Later, you can build a modern service for that domain and route selected requests to it while keeping the external contract stable.
Do not move a domain simply because a new service is technically possible. Confirm ownership of the data, transaction boundaries, failure handling and reconciliation rules. An order status query is easier to separate than a process that updates inventory, billing and fulfilment in one transaction. The more systems that participate in a business action, the more important it is to design for partial failure and reconciliation.
Use an explicit routing policy. It should make clear which system handles each operation and how you know the response is correct. During a transition, compare results where appropriate, but do not double-submit writes. Keep a rollback route to the legacy implementation until the new path has passed the organisation’s acceptance criteria.
The goal is not necessarily to retire the entire ERP. A successful outcome may be a smaller, well-bounded core with stable interfaces around it. The decision to replace or retain a module should follow business value, risk, cost of change and supportability, not a belief that every legacy component must be rewritten.
What you should see: an interface contract that can remain stable while the implementation behind it changes, plus an owner and a route-back plan for each migration slice.
How to check it worked: demonstrate that a test request can be routed to the legacy implementation and, in a non-production environment, to a replacement implementation without changing the agent-facing tool contract. Compare the business facts and document any mismatch.
Common mistakes to avoid
Giving the model a database connection
This makes the model responsible for discovering tables, constructing queries and respecting access boundaries. Give it a business function backed by a service that enforces those rules instead.
Treating MCP as an authorisation system
MCP standardises interaction between a client and tools. Your identity provider, service and data platform still need to authenticate and authorise the caller. Check those controls at the point where data is retrieved.
Copying legacy field names into the prompt
A prompt containing table names and abbreviations does not create a reliable business model. Document concepts and transformations in a versioned semantic contract, then expose only the required fields.
Mixing reads and writes in the first release
Read-only access gives you a smaller risk surface and a clearer test. If a write action is needed, design and approve it as a separate capability with explicit validation and human review where appropriate.
Calling an API wrapper a modernisation programme
A wrapper can stabilise an interface, but it does not remove the underlying dependency. Define whether the work is an integration, a migration seam or a planned replacement, and track progress against that goal.
Trusting a fluent answer
A confident explanation is not proof. Keep record identifiers, source timestamps and returned facts available to the user. Test the content against known records and make uncertainty visible.
A practical build checklist
Before a pilot, confirm each item:
- The use case has one defined business question and an accountable owner.
- The data sources, transformations and business rules are documented.
- A non-agent service can return the correct facts for test records.
- The service derives identity and access scope from trusted credentials.
- The agent receives only the fields needed for the task.
- The tool has strict inputs, bounded output and explicit error behaviour.
- The agent cannot execute raw SQL or call a general-purpose write function.
- Test cases cover denied access, stale data, ambiguous requests and source failure.
- Logs support investigation without retaining unnecessary sensitive content.
- A named owner can pause or disable the integration.
- A later write capability, if needed, has a separate review and approval design.
- The interface has a documented route back to the legacy implementation.
Where PADISO fits
We help teams choose an initial use case, design the service and semantic boundaries, and build agent integrations that fit existing platforms. Our AI agents and automation service, MCP server development and enterprise architecture and platform engineering work can support different parts of this path. A sensible first step is to map one business workflow, its data sources, permissions and failure modes before selecting tools.
To take that step, start by taking our AI readiness test or speak directly with PADISO about your legacy system and AI integration. Bring one business question, an example of the records behind it and the person who owns the process. That is enough to assess whether an API wrapper, semantic layer and agent tool are a sound first slice, or whether the data and system boundary need work first.