AI Agents on Existing Systems: How to Connect Them to Your ERP Without Handing Over the Keys

Few companies deploy an AI agent on a brand-new system. They place it on top of the ERP that handles invoicing, the CRM that supports sales, and applications that have been running for years. The demo looks great because the agent only reads data. The real questions appear when the agent needs to write.

Who allows it to issue a refund? Up to what amount? What happens if it issues the same refund twice? How will you know afterward what changed?

The answer has little to do with the AI model and a lot to do with architecture. It depends on where you place the boundary between the agent and your systems, and what decisions that boundary is responsible for making.

Let’s explore this using .NET code and a simple scenario: a customer service agent that retrieves order information and issues refunds in an ERP system.

The Agent Is Just Another API Client and Not Entirely Trustworthy

A traditional dependency usually fails loudly: an HTTP 500 error or a request timeout. A model can fail silently. It may return a perfectly valid JSON payload containing the wrong order, an amount expressed in cents instead of euros, or a customer that does not exist. It passes schema validation and reaches your systems looking perfectly legitimate.

The model is not always to blame. If the agent reads an email, a review, or a web page, that content may contain hidden instructions. The model may follow them. This is known as indirect prompt injection.

That is why an agent should be treated like an external client consuming your API, one that you do not fully trust. Everything it sends should be validated. Everything it can do should be explicitly authorized.

Tools Should Represent Use Cases, Not Operations

The temptation is to expose the entire internal API as agent tools. It is easy to do. For example, Azure API Management can convert REST API operations into MCP tools directly from the portal.

MCP (Model Context Protocol) is the open standard that allows agents to discover and invoke tools. But if an agent sees two hundred operations, it must choose among two hundred operations. A single mistake, or a prompt injection attack, may lead to the wrong choice.

OWASP calls this excessive agency and includes it in its Top 10 risks for LLM applications. It identifies three root causes:

  • Too many functions
  • Too many permissions
  • Too much autonomy

The first is solved through design: expose only a small number of tools aligned with the agent’s purpose.

The second is solved through identity and permissions per agent.

The third requires limits and human approval.

For a customer service scenario, two tools are enough:

  • Retrieve an order
  • Issue a refund

If you use API Management to generate tools automatically, carefully select which operations are exposed. Only expose those that represent actual business use cases.

Each tool should call an application-layer use case, never the database and never the internal API directly.

This effectively acts as an Anti-Corruption Layer, the pattern introduced by Eric Evans in Domain-Driven Design. It translates between systems that model the business differently, preventing one from polluting the design of the other.

Because these two systems do not deserve the same level of trust, Microsoft’s guidance recommends validating incoming data at this boundary. The agent speaks natural language and produces approximate JSON. Your domain speaks rules that cannot be approximate.

AI agents

Every Agent Needs Its Own Identity and Permissions

If all agents use the same credentials, any of them can do whatever the most privileged agent can do. And the logs will only show that it was “the integration.”

Every agent needs its own identity. Microsoft Entra Agent ID provides one and is available to all Microsoft Entra customers. The protections already available for users and applications — conditional access, risk detection, sign-in logs, and auditing — extend to agents through Microsoft Agent 365.

Microsoft Agent 365 is included in Microsoft 365 E7 and is available as an add-on for Microsoft E5, A5, and Business Premium.

With its own identity, each agent has its own permissions. The sales agent can retrieve orders but cannot issue refunds. And because the domain knows which agent is requesting each refund, it can enforce a specific limit for each one: the customer service agent can issue refunds of up to €200 without approval.

When an agent acts on behalf of a user, OWASP recommends operating within that user’s context and granting only the minimum permissions required.

In front of a custom MCP server, such as the one in our example, Azure API Management acts as a gateway. It validates the Microsoft Entra ID token, applies quotas and rate limits, and logs every call without changing the tools’ code.

The server, in turn, only accepts calls that come through the gateway.

It’s the same principle we explored in our article on AI agent governance for model consumption: usage limits belong at the gateway, rather than being scattered across individual applications. Business rules, such as the amount of a refund, belong in the domain.

Audit What Changed, Not What the Model Said

What matters is what actually changed in your systems: which refund was issued, for what amount, against which order, by which agent, during which execution, and who approved it.

That record doesn’t come from the chat. The application layer writes it as a business event, in the same transaction in which it records its decision. The call to the ERP happens afterward, using the same idempotency key.

This allows you to answer an auditor’s questions without reconstructing conversations and to correct anything that went wrong.

An agent execution isn’t a single transaction that can simply be rolled back. If the agent issued three refunds and one was unnecessary, the record tells you exactly which one and which key was used.

The MCP specification already requires client applications to log tool usage, but this business record is the authoritative one.

How to Get Started Without Putting Existing Systems at Risk

You don’t need to open everything up on day one. A better approach is to move forward in four steps:

  1. Read-only access. The agent retrieves orders and proposes refunds. A person issues them.
  2. One write tool, with approval required for everything. The agent initiates refunds, but each one remains pending until someone reviews it.
  3. Measure the results. Track how many proposals are approved without changes, how many are rejected, and why.
  4. Increase limits where the data justifies it. Small refunds can be issued without approval; larger ones still require it.

Each step can be rolled back without changing the ERP, because you control the boundary.

Let’s Talk

At Bravent, we help organizations bring AI agents into systems that are already in production. We work with you to select the first use case, design the boundary — tools, identities, gateway, and auditing — and validate it through a pilot.

Want to explore what an AI agent could do with your ERP or CRM without handing over the keys? Get in touch at info@bravent.net.

César Díaz

César Díaz

.NET Technical Lead - Bravent
    Privacy

    This website uses cookies so that we can offer you the best possible user experience. Cookie information is stored in your browser and performs functions such as recognizing you when you return to our website or helping our team understand which sections of the website you find most interesting and useful.

    Strictly Necessary Cookies

    Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

    Third party cookies

    This website uses analytical cookies to collect anonymous information such as the number of visitors to the site, or the most popular pages.

    Leaving this cookie active allows us to improve our website.