Skip to main content
Back to Blog

Building an MCP Server for Your Oracle Database

IntegrationLuminaByte TeamJune 12, 20266 min read
Building an MCP Server for Your Oracle Database

Sooner or later someone in your organisation is going to ask: "can the agent just talk to our Oracle database?" The honest answer is no, not directly — but yes, through a thin MCP server that exposes a small set of curated, auditable queries. This is the pragmatic build pattern that has been holding up in production. It is also a useful first MCP project because Oracle databases are usually where the data your agents actually need lives.

Why "agent + JDBC" is the wrong answer

It is technically possible to give an agent a JDBC-style tool that accepts arbitrary SQL. It is also a near-guaranteed incident waiting for an audit window. Three failure modes are immediate:

  • The agent generates SQL that joins beyond the user's intent and returns data they should not see.
  • The agent generates SQL that runs for hours and locks rows the rest of the application needs.
  • The agent generates SQL that writes — UPDATE or DELETE — when the user only asked for information.

None of these require malice. They are the median behaviour of a capable model given a powerful tool with no guardrails.

The right shape: an MCP server with named queries

Instead, build a small MCP server that exposes a handful of named, parameterised operations. Each operation:

  • Has a clear name and description (the agent reads these to decide when to call).
  • Accepts a small, validated set of parameters.
  • Runs a single, hand-written query the DBA has reviewed.
  • Returns structured data, with bounded result-set sizes.
  • Logs the call to your observability stack.

The agent never sees SQL. The agent sees verbs like findCustomerByEmail, listOpenInvoicesForCustomer or getProductPriceHistory. The database team controls exactly what each verb does.

A starting tool catalogue

For a typical Oracle estate, a sensible first set of tools:

  • Read tools that wrap your most-asked-for read operations. Bound result sets (top 100, configurable). Always include a tenant or owner filter derived from the authenticated session.
  • Aggregation tools for the metrics business users repeatedly ask about. Pre-defined dimensions, pre-defined measures.
  • Search tools that wrap Oracle Text or vector-search capabilities you already have. Return identifiers plus short snippets, not full records.
  • Lookup tools for reference data (status codes, country lists, product categories). These improve agent reasoning without exposing sensitive rows.

Resist the urge to add a writeData tool in the first version. Reads-only first. Writes come later, with a second approval round and an explicit confirmation pattern.

Authentication and identity

The crucial detail is whose identity the queries run under. Three options, in order of preference:

  1. End-user identity propagated through the MCP server. The agent is acting on behalf of a named user. The MCP server's OAuth 2.1 flow validates that user and uses their identity for the database session. Row-level security and existing application permissions apply naturally.
  2. Service identity with explicit scoping. The MCP server uses a dedicated database account whose grants are tightly limited to exactly the queries the tools execute. Audit logs capture which end-user requested each call, even though the database session is under the service account.
  3. Service identity without scoping. The MCP server's database account can read more than the tools expose. This is the path of least resistance and the one that causes the post-incident memo six months later. Avoid.

Option 1 is correct in principle; Option 2 is usually pragmatic in practice. Mixed environments commonly land on Option 2 with strong audit, and that is defensible.

Designing the tools for the agent's benefit

Two small choices materially improve how well the agent uses your server.

Write good tool descriptions. The descriptions are not for humans; they are the prompt the agent reads to decide which tool to call. A description like "looks up a customer record" is worse than "Returns a customer record matched by exact email address. Use when the user has provided a complete email; for partial matches, use searchCustomers instead." The second sentence prevents the wrong-tool failure mode.

Return structured data, not text. An agent that gets back a JSON record can reason about its fields. An agent that gets back prose has to parse it again. Structure is a small effort that pays back every call.

The best MCP server is one whose tool names and descriptions are good enough that the agent picks the right one without trying.

Where this fits in your Oracle estate

The MCP server pattern works well for:

  • OLTP systems where queries are well-understood and the same shapes are run thousands of times.
  • Reporting databases where users repeatedly want similar slices.
  • Knowledge bases stored in Oracle that need to feed agentic workflows.
  • APEX-fronted applications where the same MCP server can serve both the APEX agent (via REST tool) and external clients.

It is less natural for exploratory analytics where every query is novel — that workload still wants a proper BI tool with a semantic layer, not an agent.

Operating considerations

Three practical things that are not obvious until you ship one:

  • Connection pooling matters. Tools called by agents bursts and pauses unpredictably. A naive new-connection-per-call pattern overwhelms Oracle quickly. Use a small, sensibly-sized pool with timeouts.
  • Query budgets. Set per-tool execution time limits at the database layer. A misbehaving tool should be killed by Oracle, not propagated as a timeout the agent has to handle.
  • Schema drift. Your tools depend on column names. When a schema changes, the tools must be updated and the agent informed. Treat your tool catalogue as part of the same change-management process as the application itself.

A minimal first sprint

  1. Pick one Oracle-backed system and three operations end-users repeatedly ask about.
  2. Build an MCP server (any of the official SDKs work) with those three tools, OAuth 2.1, audit logging, and bounded result sets.
  3. Wire one MCP-aware agent to it. Test against representative prompts. Read the logs.
  4. Add a fourth tool only when the first three are stable.
  5. Write the operating runbook: who owns the server, how new tools get added, who reviews the queries.

That is the minimum that turns "agents can talk to our Oracle database" from a slogan into a controlled capability. The pattern scales from there.

The longer view

The MCP server in front of your Oracle estate is not just an integration choice. It is the architectural decision that lets you grow agent-driven workflows over the next two years without giving up control over what the agents can actually do. The discipline of designing tool catalogues — naming the verbs, parameterising the queries, scoping the permissions — is going to become a normal part of enterprise data work. The teams that start now will have catalogues that other teams want to copy by the end of the year.

Share: