Skip to content
heldevia
In the fieldOctober 29, 202612 min read

MCP in production: lessons from an Oracle Fusion ERP server

We run a Model Context Protocol server in production for two clients on Oracle Fusion — 180 tools across 14 functional areas of the ERP. What that actually takes: a ground-truth catalogue, tool descriptions treated as load-bearing infrastructure, a typed tool graph so the agent can reason across domains, and gates against the most dangerous failure in ERP work: the plausible number.

Also available in: Français

Model Context Protocol (MCP) demos are everywhere. Wiring an agent into a live ERP — where the numbers feed real decisions by real finance teams — is a different sport. We build and operate an MCP gateway that runs in production for two clients on Oracle Fusion Cloud, exposing 180 tools, organised in nine code packages across 14 functional areas of the ERP — among them general ledger, payables, receivables, procurement, inventory, supply chain, manufacturing, maintenance and projects. (A tenant that hides some tools sees 170.)

This is a field report: the architecture that survived contact with Oracle Fusion, and the failure modes we paid for. Client names are ours to protect; the engineering is not.

The shape of the problem

Oracle Fusion's REST surface is enormous and irregular. The full catalogue on one of the instances we work with describes thousands of REST resources. Irregular is the important word: on purchaseOrderSchedules, only 22 of 76 attributes are actually queryable server-side — the rest are filterable only through a named finder with its own bind variables. Coverage varies by resource: shipments does better, at 133 of 176, and still leaves 43 attributes out of reach of server-side filtering. On some collections, pagination silently caps at 500 rows per page no matter what limit you request. Error messages are their own dialect: ORA-06502 usually means a numeric parameter in a BI Publisher data model received a non-numeric value, often a %; a date in ISO format can corrupt the year on the way in.

An agent left to guess its way through this API burns tokens on HTTP 400s and comes back with half-answers. And there's a harder constraint underneath: by our design estimate, ten thousand invoices weigh 400,000–600,000 tokens. Whatever the architecture is, raw rows must never flow through the model.

Five layers, not thousands of tools

The temptation with a huge API is one tool per endpoint. That way lies an unusable server. Ours is organised in five layers:

  1. Canonical KPIs — the questions asked every day, precomputed and named.
  2. Aggregations — pivot-style tools (group_by, measure, top_n) where the summing happens server-side; the model receives a result table, never the underlying rows.
  3. Drill-downs — scoped get_* tools with a discriminating condition, for the follow-up questions.
  4. Reports inside the ERP — Oracle's own BI Publisher, driven as a tool: when the answer needs SQL-grade aggregation, run it where the data lives. (BI Publisher is used over SOAP; its failures arrive as generic HTTP 500s, which we translate into diagnosable errors. Production is where idealism goes to die.)
  5. An escape hatch — a raw API explorer for the long tail, used knowingly.

Almost everything in these layers is read-only, and none of the tools modifies business data. What does more than read is gated, not hidden. The gate is coarse and OAuth-scope based — read, execute, admin — and the four tools that execute something require a higher scope than plain reads. One tool can change report configuration, and it requires admin. Launching processes inside the ERP can have effects inside the ERP. A tool nobody has classified falls to admin, never to read. Each tenant can hide tools it does not want exposed, and SQL diagnostics ship switched off by default and are read-only. Data segmentation stays with the ERP's own per-user security (more on that below).

Ground truth as a first-class citizen

The single highest-leverage decision in the whole system: we stopped letting anyone — humans or models — assume what Oracle's API can do, and built the answer into a queryable artefact.

We call it the API Atlas: a per-tenant catalogue built from Oracle's own /describe metadata, recording for every resource which attributes are queryable, which finders exist with which bind variables, and how resources join. Three tools stand on it:

  • query_api_atlas lets the agent explore that ground truth offline — no Oracle round-trip, no guessing.
  • plan_query is a deterministic planner: given a resource and the filters a question implies, it classifies each condition as server-side, finder-routed, client-side or unknown (with the nearest queryable alternative), and returns an execution plan in plain English. No model involved, no live call — it reasons over the Atlas.
  • audit_tool_schemas turns the same ground truth on ourselves: it cross-checks every registered tool against the Atlas and reports filters on non-queryable attributes and projected fields that don't exist on the resource. It runs in CI against an accepted baseline: no new regressions, so a new phantom field breaks the build. The server audits itself against the system it integrates.

That last tool found real defects in our own catalogue within seconds of existing. We recommend the pattern to anyone integrating a large API: make ground truth machine-readable, then point it at your own code first.

Tool descriptions are load-bearing

With a catalogue this size, the model's choice of which tool to call is the product. And that choice is driven entirely by prose — the tool descriptions.

We learnt this the honest way: a routing incident where a question about expenses landed on the invoice-aggregation tool, which covers payables only, instead of the ledger's expense-analysis tool. The answer came out about three times smaller than the right one. Correct arithmetic, wrong lens, and nobody lied — the descriptions had drifted and overlapped.

Descriptions are now a governed artefact with their own rubric: purpose in 25 words or fewer, an explicit yes/no scope section, and — the part that matters most — symmetric routing: each description names its neighbouring alternatives and says when to prefer them. Two enforcement layers keep it honest: a linter that runs in our unit tests in CI, and an LLM-as-judge evaluation that replays a golden set of realistic questions against the catalogue. The judge runs on demand rather than in CI, with a threshold of at least 95% first-choice routing; it went from 29 of 32 questions routed correctly (90.6%) to 33 of 33.

If you take one thing from this article: with a large tool catalogue, your descriptions are your router. Version them, lint them, evaluate them.

A typed graph, because the full catalogue doesn't fit in a context window

Descriptions route among the tools the model can see. The harder question is which tools it sees at all. An early prototype exposed about 142 tools to a single agent and measured the consequence: it ran into a 100,000-token limit, with roughly 108,000 tokens of schemas before the user had asked anything. The full catalogue can never ride along.

So our agent — which lives outside the gateway and uses it as a connector — retrieves tools per turn: embed the question, recall the 30 closest candidates from an embeddings store over the tool corpus, rerank them to 15, add the always-available core tools. Every tool stays reachable; the model sees fewer than twenty of the 180. With that retrieval layer, the same turn came down to about 15,000 tokens.

That works until the question crosses domains. "The supplier we owe the most — do they have open purchase orders?" retrieves payables tools, because that is what the words say. The second half of the answer lives in procurement, and nothing in the phrase "owe the most" smells like a purchase order. Pure semantic retrieval has a structural blind spot: it finds tools that sound like the question, not tools that chain with the answer.

Our fix is a tool knowledge graph, published by the gateway itself. Nodes are hand-curated: every tool carries a domain and a one-line purpose. Edges are typed with a deliberately small vocabulary — resolves_ids_for, prerequisite_of, joins_on:<key> and complements (a fifth, same_domain, was left out on purpose: it was the weakest) — and our agent expands its retrieved set with the one-hop neighbours of the tools retrieval found: an ID resolver or a prerequisite unlocks a call, a cross-domain join answers the question the embeddings couldn't see. A compact domain map from the same graph goes into the system prompt, so the model knows the territory even where it has no tools loaded this turn.

The graph gets the same engineering discipline as everything else here:

  • It lives in the gateway, not in the agent — because it must always match the tools the gateway actually serves. It is filtered per tenant so it agrees with list_tools, its version is a SHA-256 content hash, and a redeploy is the publish event.
  • A lockstep unit test in CI fails the build when a registered tool has no node, when an edge references a tool that no longer exists, or when a declared key parameter isn't a real field of the tool's input schema. Curated data rots; gates keep it honest.
  • It is an enhancer, never load-bearing. If the graph doesn't answer, the turn simply carries on without it. A feature that improves answers must degrade to zero, not to an outage.

The dangerous failure is the plausible number

Nothing in this system scared us more than the bugs where everything looked right.

Two incidents shaped the design. In one, a scan capped at 2,500 rows was silently truncated, reported success: true, and the total went out anyway — plausible, while the real total was about 14% higher. In another, an upstream cost source flickered mid-scan, cost coverage ended at 36.5% after three attempts, and two runs returned two different totals, both marked complete. No exception, no error state. Just a confident number a finance team could have acted on.

The fix is a completeness contract: every aggregate result carries its own verdict about the data behind it, in complete and population_complete flags. We think of row completeness and cost coverage as two independent axes, and when the keys behind a total are not complete, the total is returned as null with a named lower bound — never a best guess. Each response carries a request ID in its metadata, so any number on any screen can be traced back to its invocation.

In ERP work, "the model added correctly over incomplete data" is strictly worse than an error message. Design for the honest incomplete. (We make the broader case for keeping arithmetic out of the model in five AI projects we won't sell you.)

The unglamorous production layer

The parts nobody demos, in brief: OAuth 2.0 with Dynamic Client Registration (RFC 7591, rate-limited per IP), PKCE and the standard metadata documents (RFC 8414 and 9728), so hosted agents connect per the MCP spec; multi-tenant routing by path (/t/{tenant}), with per-tenant tool gating (a report not deployed on your tenant simply doesn't appear in your tool list); structured JSON logs with secret redaction; OpenTelemetry traces around every Oracle call; latency percentiles at P50, P95 and P99; rate limiting per identity and per tenant; exponential backoff and circuit breakers, because a SaaS ERP has moods. It runs on a managed Kubernetes cluster with secrets in a vault and the OAuth store in Redis, deployed by GitHub Actions with a canary and a 15-minute soak.

One security lesson worth its own paragraph: we removed our per-tool RBAC layer, which covered a fraction of the tools — a misleading half-control that looked like security in an architecture diagram and delivered little. Completing it inside the gateway would have meant re-implementing the ERP's own security, so we did not. Data segmentation stays with the ERP's per-user security, applied with the user's own token. We kept only a coarse OAuth-scope gate for the few tools that execute or change something. A partial control that reads as a full one is worse than none.

The numbers

What we measureValue
Tools in the catalogue180 (170 on a tenant that hides some)
Clients in production2
ERP coverage14 functional areas, in 9 code packages
Resources described in the API AtlasThousands of REST resources per instance
Queryable attributes on purchaseOrderSchedules22 of 76
Queryable attributes on shipments133 of 176
Oracle pagination cap500 rows/page on some collections, regardless of requested limit
Raw scale that forbids raw data in prompts10,000 invoices ≈ 400–600K tokens (design estimate)
Full tool catalogue as context (early prototype)~142 tools ≈ 108K tokens of schemas, over a 100K-token limit
The same turn with the retrieval layer~15K tokens
Tools our agent sends the model per turnFewer than twenty of 180 (30 recalled, reranked to 15, plus core tools)
Edge types in the tool knowledge graph4 (resolves_ids_for, prerequisite_of, joins_on:<key>, complements)
Backend test functions11,471 across 537 files
Application code~153,000 lines of Python

What we would do differently

  • Build the Atlas first. We added machine-readable ground truth after dozens of tools existed, and the self-audit immediately found real defects in them. Inverting the order — catalogue first, tools generated and validated against it — would have saved every one of those bugs.
  • Govern descriptions from day one. The routing rubric and its CI gates were born from an incident. They should have been born with the third tool.
  • Never ship a half-control. The partial RBAC looked like defence in depth and was actually a false promise. If a control doesn't cover the whole surface, finish it or delete it.
  • Assume the vendor API lies somewhere. Budget for the escape hatches — the SOAP path to BI Publisher, the error-translation tool that maps Oracle's dialect to actionable fixes — as first-class features, not embarrassments.

Connecting an agent to the system a company actually runs on is where AI stops being a demo and starts being engineering: ground truth, gates, observability, and numbers that refuse to look better than they are. That discipline is the product — and it's exactly what we bring to systems integration for our clients.

Frequently asked questions

How many tools is too many for an MCP server?
The count matters less than the routing — and than what the model actually sees. Our server exposes 180 tools and it works in production because the expensive surface — tool descriptions — is engineered (a strict rubric, a CI linter, an LLM-as-judge routing evaluation), and because our agent never loads the full catalogue at once: each turn it retrieves a small semantically relevant subset and expands it through a typed tool graph. An early prototype exposed about 142 tools to a single agent and ran into a 100,000-token limit, with roughly 108,000 tokens of schemas alone. With the retrieval layer, the same turn dropped to about 15,000. That, not the count itself, is what breaks agents.
Why not give the agent raw API or SQL access instead of curated tools?
Token economics and API irregularity. By our design estimate, ten thousand invoices are 400,000 to 600,000 tokens — no model should ever see raw rows at that scale, so aggregation must happen server-side and the model should receive results, not data. And Oracle Fusion's REST surface is irregular enough (on `purchaseOrderSchedules`, only 22 of 76 attributes are actually queryable) that an agent guessing its way through it burns time and errors. Curated layers plus a machine-readable catalogue of what is actually queryable outperform raw access on both counts.
Can an MCP server safely write to an ERP?
In our server almost everything is read-only, and none of the tools modifies business data. The only gate we kept is a coarse OAuth-scope one — read, execute, admin. The four tools that execute something require a higher scope than plain reads; one tool can change report configuration and requires admin; and launching processes inside the ERP can have effects inside the ERP. A tool nobody has classified falls to admin, not to read. Each tenant can hide tools it does not want exposed, and SQL diagnostics ship switched off by default and read-only. Data segmentation stays with the ERP's own per-user security.
How do you stop an AI agent from reporting wrong financial numbers?
The model never computes totals — deterministic code does, server-side. And a correct sum is not enough: our worst bugs were correct arithmetic over silently incomplete data. Every aggregate result now carries a completeness verdict, and when the data cannot support a total, it comes back null with a named lower bound instead — we check row completeness and cost coverage as two separate axes. An honest 'incomplete' beats a plausible wrong number, especially in front of a CFO.

← All articles

Ready to transform your business with AI?

Let's discuss how intelligent solutions can drive your next competitive advantage.