Governed, least-privilege Oracle Database access for AI agents — in pure Rust.
oraclemcp is a Model Context Protocol server that gives an AI agent governed, least-privilege access to an Oracle database. Every raw statement the agent submits is classified before it can reach Oracle: read tools admit only statements proven read-only, and non-read SQL runs only through an explicit, profile-gated path that rolls DML back by default and requires a preview-derived grant before commit. Session elevation is explicit, temporary, and capped by profile max_level. The engine-free SQL guard remains independent of PL/SQL intelligence; the default binary embeds the offline engine. All crates use #![forbid(unsafe_code)].
An independent open-source project — not affiliated with Oracle. See how it compares to Oracle's own MCP servers.
Drivers
oraclemcp connects through its own mature, pure-Rust Oracle driver as the primary path. The official oracledb crate from Oracle — whose crate name we handed to Oracle in a friendly handshake — is currently in beta, and therefore ships purely as a bounded, connect-time fallback for the rare case something goes awry. No Oracle Instant Client, ODPI-C, or C toolchain is required.
flowchart LR
A["Connection request"] --> D["driver-cx<br/>pure-Rust · primary<br/>password · IAM · wallet · TCPS/PEM"]
D -->|"basic-password<br/>connect fails"| O["oracledb<br/>Oracle · beta<br/>connect-time fallback"]
D --> DB[("Oracle Database")]
O --> DB
Only a failed basic-password connect ever falls back; IAM, wallet, and TCPS/PEM always stay on driver-cx, and a fallback never migrates a live session.
At a glance
Quick start
One line installs or updates on macOS and Linux (works pasted in a terminal or in a non-interactive agent run):
curl -fsSL "https://raw.githubusercontent.com/MuhDur/oraclemcp/main/install.sh?$(date +%s)" | bash
It verifies a SHA-256 digest (plus cosign signature/provenance when cosign is present) and installs oraclemcp and the short om alias into $HOME/.local. Also available: Windows (install.ps1), Docker (ghcr.io/muhdur/oraclemcp:latest), and cargo binstall oraclemcp. Air-gapped offline install, verification postures, and service install are documented via bash install.sh --help and docs/. No npm/npx channel is offered.
Onboard and connect a client:
oraclemcp setup --discover # one READ_ONLY profile per tnsnames.ora entry — consent-gated, no secrets written to disk
oraclemcp doctor # offline diagnostics: driver, TNS/wallet, classifier, NLS
oraclemcp serve --profile db_ro --allow-no-auth # stdio (local dev)
Wire it into an MCP client (e.g. Claude Desktop) over stdio:
{
"mcpServers": {
"oracle": {
"command": "oraclemcp",
"args": ["serve", "--profile", "db_ro", "--allow-no-auth"]
}
}
}
Several local MCP clients can use this same stdio configuration concurrently,
including write-capable profiles. When service state is needed, clients
automatically attach to one local broker that owns the audit writer and
database pools. Each client retains its own session level, confirmation tokens,
transaction and cancellation. The broker exits after 60 seconds without clients.
HTTP also gives each client an isolated stateful session by default.
HTTP and stdio clients share that same broker and state root. Each local client
must resolve its own configured database credentials. Credentials that differ
from the broker's receive ORACLEMCP_BROKER_CREDENTIAL_MISMATCH before opening a session.
Or run authenticated HTTP with a shown-once bearer, and open the local dashboard through a secret-free one-time pairing URL:
oraclemcp --json clients issue --label claude --scope oracle:read
oraclemcp serve --listen 127.0.0.1:7070 --client-credentials --profile db_ro
om dashboard
doctor output is safe to paste into agent sessions — it omits connect strings, usernames, credential references, passwords, wallet paths, IAM tokens, and server DNs while keeping structured failure classes and ORA codes.
Why oraclemcp
- Fail-closed by construction. A
SELECTan agent dreams up can never silently become aDELETE. Read tools admit only proven read-onlySELECT/WITHand dictionary introspection. Non-read execution is isolated inoracle_execute, bounded by the profile ceiling, rollback-by-default for DML, and explicit-confirm-before-commit. Forbidden constructs (multi-statement batches, string-concat dynamic SQL, an unproven function call inside a SELECT) are rejected before touching Oracle, with a typed envelope and a suggested safe alternative. - Agent-first UX. Every tool ships a real JSON Schema, title, and explicit MCP annotations (
readOnlyHint,destructiveHint,idempotentHint,openWorldHint). Errors are structuredErrorEnvelopes with machine-stable classes, fuzzy suggestions, and next-step hints — never bare strings. A zero-argoracle_capabilitiestool lets an agent discover the surface. - Pure Rust, no
unsafe. Every crate is#![forbid(unsafe_code)]; the fail-closed classifier is a realsqlparserAST classifier and carries a differential cargo-fuzz target. - Two transports. stdio (default) and Streamable HTTP (
--listen) with fail-closed auth defaults, optional OAuth bearer enforcement, and native rustls TLS/mTLS.
How it compares
Oracle ships an official MCP built into SQLcl; ours is independent. On the axis that decides whether you can safely point an AI agent at a database — the guard between the agent and your data — here is the honest, evidence-backed contrast:
SQLcl-MCP rows reflect Oracle's own documentation (configure a minimum-privilege user, prefer a non-prod replica, audit via DBTOOLS$MCP_LOG); the oraclemcp rows are enforced in this repository. Oracle is the official, supported option, and its managed Autonomous MCP takes a different curated-report approach with per-user identity — strong for locked-down read-only BI.
Safety model
When a guarded request is refused, use the generated refusal catalogue for its typed safe next action; it never recommends bypassing the guard.
The core invariant is a fail-closed SQL guard — not "read-only forever." Operating levels form a ladder, READ_ONLY < READ_WRITE < DDL < ADMIN, surfaced through oracle_execute, oracle_compile_object, oracle_create_or_replace, oracle_patch_source, and oracle_set_session_level. Read-only is the default and the cap for unconfigured or protected profiles; a profile's max_level may permit escalation up to ADMIN. Every escalation is guarded:
- a preview → confirmation-token step-up before any non-read statement runs,
- a temporary, TTL-bounded elevation window,
- the classifier still gating every statement at the current level,
- DML rolling back by default,
protectedprofiles pinned atREAD_ONLYwith an immutable ceiling, and OAuth scopes that can only lower the effective level, - a signed, append-only, HMAC-SHA256 hash-chained audit record for every privileged action.
flowchart LR
A["Agent SQL"] --> C{"Fail-closed<br/>classifier"}
C -->|"proven READ_ONLY"| R["Read tools · rows returned"]
C -->|"forbidden / unparseable"| X["Refuse<br/>typed ErrorEnvelope"]
C -->|"non-read"| L{"Operating-level gate<br/>READ_ONLY → READ_WRITE → DDL → ADMIN"}
L -->|"above level / ceiling"| X
L -->|"within profile ceiling"| P["Preview → confirmation token"]
P --> E["Execute"]
E -->|"DML"| RB["Rollback by default<br/>commit only with grant"]
R --> AU[("Signed hash-chained audit")]
E --> AU
An unparseable or unclassifiable statement fails closed. Statements can emit a verdict certificate bound to the classified bytes and the audit record; the routine-purity law it relies on is specified in proofs/purity-core/PurityCore.lean and pinned to the Rust classifier by a conformance test.
Governed dimensions
A database session is treated as a governed surface with several independent controls, each with an executable proof script:
What an agent sees depends on the active level and effective ceiling. At READ_ONLY, tools/list includes oracle_execute and execute_approved when the effective profile/OAuth ceiling permits READ_WRITE; their visibility grants no write authority. Other higher-level tools remain hidden until the session is elevated within the ceiling. A call to a not-yet-visible tool is refused with the same typed ErrorEnvelope as any other below-level statement.
Tools
The tables below are generated from the server's tool registry — the same descriptors tools/list serves — by scripts/docs_generate.sh (rendered from oraclemcp robot-docs tools --markdown). Do not hand-edit them; edit the registry and run bash scripts/docs_generate.sh --write.
Every advertised tool descriptor includes a human title plus explicit MCP annotations; these hints are advisory for clients, while the fail-closed classifier and operating-level gate remain the enforcement boundary. oracle_query and oracle_explain_plan also advertise outputSchema, and query results keep Oracle NUMBER cells as strings by default (opt into numbers_as_float=true explicitly). Beyond tools/*, initialize advertises resources, prompts, and completions (protocol 2025-11-25): resources/list exposes oracle://capabilities and oracle://tools, and read templates for oracle://schema/{owner} and oracle://object/{owner}/{type}/{name} route through the same safe dispatch path.
Compatibility aliases
For migrations from shorter Oracle MCP tool surfaces, the server advertises compatibility aliases that route to the guarded oracle_* tools and share their classifier, validation, and operating-level behavior. execute_approved, deploy_ddl, and read_patch_preview are wrappers rather than plain renames.
Configuration
Connection profiles live in profiles.toml. No secrets are written to disk — credentials are references resolved at runtime through env:, file:, or keyring:. A minimal read-only profile:
[profiles.db_ro]
connect_string = "//db.example.com:1521/FREEPDB1"
username = "APP_RO"
credential_ref = "env:ORACLE_APP_PASSWORD"
# default_level defaults to read_only and is the ceiling for this profile;
# set max_level to permit explicit, TTL-bounded elevation up to ADMIN.
The full field reference — HTTP TLS/mTLS/OAuth listeners, the signed audit chain, result-masking policy, fleet/monitor profiles, TCPS/wallet and IAM/DRCP/proxy auth, and per-call timeout/SDU budgets — is in docs/configuration.md.
Documentation
- Installation manual — verified installers, air-gapped installs, updates, uninstall, services, dashboard pairing, and release channels.
- Configuration reference — every profile, auth, transport, audit, and masking field.
- Operating & deployment — containerized deployment, least-privilege account, network posture, service management (systemd/launchd/Windows), air-gapped install, and the operator runbook.
- TNS discovery onboarding · Toolchain · Upgrade runbooks and field-hardening notes.
- Architecture decisions:
docs/adr/· Formal proofs:proofs/purity-core/.
Build from source
This branch is pinned to nightly-2026-05-11 and has no stable MSRV (the pin arrives transitively through asupersync, and Windows needs windows_by_handle; see docs/toolchain.md). Prefer the verified release archive above; build from source only when you intend to:
rustup toolchain install nightly-2026-05-11 --component rustfmt --component clippy
cargo +nightly-2026-05-11 install oraclemcp
Live database access is built in through the pure-Rust thin driver — no Oracle Instant Client, ODPI-C, or C toolchain. Optionally set TNS_ADMIN for net-service-name connections. The default build embeds the offline PL/SQL engine; --no-default-features omits it.
License
Licensed under Apache-2.0 OR MIT. The Docker image and crates do not redistribute Oracle Instant Client.