mcp-oracle-dba
The mcp-oracle-dba server provides a secure, read-only MCP interface to Oracle databases (12.1+, 19c, 23ai; single instance and RAC), enabling LLMs to safely query metadata and data with multi-layer guardrails, PII redaction, and full audit logging.
Core Tools:
list_schemas: Returns the configured allowlist of schemas the server can query (no database call required).describe_table: Retrieves column metadata for aSCHEMA.TABLE, restricted to allowed schemas.run_select: ExecutesSELECTorWITHqueries with safety guards:Blocks DDL, DML, PL/SQL, dangerous packages (
DBMS_*,UTL_*,SYS.*), and multi-statement injectionsAutomatically redacts sensitive columns (SSN, SALARY, PASSWORD, etc.)
Caps returned rows (configurable via
MCP_MAX_ROWS, default 100)Enforces server-side statement timeouts
explain_plan: Returns OracleEXPLAIN PLANoutput for a given SELECT query — useful for diagnosing slow queries.top_sql: Shows recent high-elapsed-time SQL fromv$sql(default: last 60 min, top 10 results).
Optional AWR/ASH Tools (requires MCP_ENABLE_AWR=true and Oracle Diagnostic Pack):
list_awr_snapshots: Lists available AWR snapshots.awr_summary: Compact AWR analysis — top SQL, wait events, and DB-time breakdown.awr_top_sql: Top SQL by elapsed time between two AWR snapshots.awr_wait_events: Top ASH wait events between snapshots.awr_time_model: DB-time breakdown acrossDBA_HIST_SYS_TIME_MODELcounters.
What it will NOT do:
Execute INSERT, UPDATE, DELETE, MERGE, DROP, CREATE, ALTER, or any other mutating statement
Call dangerous packages or expose unredacted PII column values
Return more rows than the configured cap
Every tool call (including rejections) is logged to an audit file for compliance. Security is enforced through five independent guardrail layers and a dedicated read-only database user.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-oracle-dba List available Oracle schemas"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-oracle-dba
A Model Context Protocol (MCP) server for Oracle Database — read-only, audited, and SQL-guarded. Lets Claude Desktop, Claude Code, Cursor, or any MCP client query your Oracle database safely.
Built by an Oracle Apps DBA. Designed so an LLM can explore production data without ever being able to mutate it.

In the screenshot above, Claude (via this MCP server) successfully runs
discovery + a real SELECT over my Oracle 23ai database — and is then
refused when it tries to DROP TABLE. Every call is recorded in the
audit log.
Why this exists
Most "let your LLM query the database" demos are unsafe by default:
they give the LLM a connection string and trust it not to send
DROP TABLE. This server flips that model. The LLM gets a narrow,
explicit toolset, every call is parsed against a multi-layer SQL
guardrail, the result rows are PII-redacted, and every call is
audit-logged.
If the LLM hallucinates DROP TABLE users while debugging a slow
query, the server refuses before the SQL ever reaches Oracle.
Related MCP server: mcp-sqlserver-readonly
Tools exposed
Core (5 tools, always enabled):
Tool | What it does |
| Returns the allowlist of schemas the server is configured to query. |
| Column metadata for |
| Validates + runs a |
| Oracle |
| Top SQL by elapsed time from |
AWR / ASH (5 tools, gated behind MCP_ENABLE_AWR=true):
Tool | What it does |
| Available AWR snapshots in the last N hours (one row per |
| Compact AWR analysis: top SQL + wait events + DB-time breakdown in one JSON. Reach for this first when answering "why was the DB slow between X and Y?". |
| Top SQL by elapsed time between two snapshots. Per- |
| Top ASH wait events between snapshots. From |
| DB-time breakdown across cumulative |
AWR/ASH tools require Oracle Diagnostic Pack licensing on Standard Edition and Enterprise Edition production databases. Oracle Database Free Edition (23ai) includes the diagnostic features for development use. Set
MCP_ENABLE_AWR=truein.envto expose these tools.
Security model (defense in depth)
Five independent layers — any one of them rejects unsafe input before it reaches the database:
Single-statement parser: rejects
... ; DROP TABLE xinjection.First-keyword allowlist: only
SELECTandWITHaccepted.Banned-keyword scan: blocks
INSERT,UPDATE,DELETE,MERGE,TRUNCATE,DROP,CREATE,ALTER,GRANT,REVOKE,BEGIN,DECLARE,EXECUTE,CALL,COMMIT,ROLLBACK,SAVEPOINT,LOCK,RENAME,FLASHBACK— anywhere in the statement.Dangerous-package regex: blocks any call into
DBMS_*,UTL_*, orSYS.*(thinkDBMS_LOCK.sleep,UTL_HTTP.request,UTL_FILE.fopen).Row cap: every approved query is wrapped in
SELECT * FROM (...) FETCH FIRST :max_rows ROWS ONLY.
Plus:
Read-only DB user (
mcp_ro): zeroINSERT/UPDATE/DELETEprivileges at the SQL layer. The guardrails are belt-and-suspenders on top of this.Schema allowlist for
describe_table: only configured schemas are introspectable.PII redaction: column names matching
SSN,SALARY,TAX_ID,PASSWORD, etc., are auto-replaced with[REDACTED]in returned rows.Statement timeout: enforced server-side via
oracledb'scall_timeout.Audit log: every tool call (including rejections) emits a JSON line to
MCP_AUDIT_LOG(default./audit.log).
The guardrails come with 45 security tests
(pytest tests/) — every test represents a real attack vector
explicitly blocked.
Quickstart
Prerequisites
Python 3.12+
uv:brew install uvAn Oracle database with a read-only user
Optional: an MCP client (Claude Desktop, Claude Code, Cursor)
1. Clone + install
git clone https://github.com/shopsmartai/mcp-oracle-dba.git
cd mcp-oracle-dba
uv sync2. Configure environment
cp .env.example .env
# Edit .env — set ORA_USER, ORA_PASSWORD, ORA_DSNORA_DSN examples:
localhost:1521/FREEPDB1— local Oracle 23ai Freeoracle23ai.orb.local:1521/FREEPDB1— OrbStack on macOS, when running the server from a normal terminal (avoids port-forwarding NAT issues that mangle TNS handshakes)192.168.215.2:1521/FREEPDB1— OrbStack container direct IP, required when this MCP server is launched by Claude Desktop or any sandboxed macOS app. Sandboxed child processes do not have access to OrbStack's.orb.localDNS resolver — the connection fails withDPY-6005 / No route to host. Usedocker inspect oracle23ai --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'to get the IP.prod-db.example.com:1521/PRODPDB— production (use a read-only user!)
3. Run the tests (security check)
uv run pytest tests/ -vYou should see 45 passing. Every test maps to a real attack vector — DDL, DML, multi-statement injection, dangerous package calls, etc.
4. Smoke test
uv run python -c "
from mcp_oracle_dba.server import list_schemas, run_select
print('Schemas:', list_schemas())
print(run_select('SELECT user FROM dual'))
"5. Wire to Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json
(macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"oracle-dba": {
"command": "/opt/homebrew/bin/uv",
"args": [
"--directory",
"/absolute/path/to/mcp-oracle-dba",
"run",
"mcp-oracle-dba"
]
}
}
}Restart Claude Desktop. The tools should appear under the 🔧 icon in the chat input.
Try asking: "List the schemas available in our Oracle DB", "Describe the FND_USER table", "What's the top SQL in the last hour?"
Configuration reference
All settings load from .env (see .env.example):
Variable | Default | Meaning |
| (required) | DB user (should be read-only) |
| (required) | DB password |
| (required) | Easy-Connect or TNS-format DSN |
|
| Hard cap on rows returned by |
|
| Server-side statement timeout |
|
| Comma-separated schemas allowed for |
|
| Column-name substrings to redact |
|
| JSON-line audit log path |
|
| Expose the 5 AWR/ASH tools (requires Diagnostic Pack on production) |
Recommended database setup
A minimal read-only Oracle user for the MCP server:
CREATE USER mcp_ro IDENTIFIED BY "strong_password";
GRANT CREATE SESSION TO mcp_ro;
GRANT SELECT_CATALOG_ROLE TO mcp_ro;
-- For each business table you want exposed:
GRANT SELECT ON appsapp.fnd_user TO mcp_ro;
-- ...SELECT_CATALOG_ROLE is preferred over individual V$ grants —
it covers all data-dictionary and dynamic-performance views in
one line, and avoids the "SYSTEM can't forward SYS-owned grants"
issue you hit otherwise.
Oracle version compatibility
Version | Status | Notes |
Oracle 23ai (CDB+PDB or single) | Tested | Primary development target |
Oracle 19c | Works without code changes | Same tools, same syntax. The MCP server uses no 23ai-specific features. Most production EBS R12.2 environments are on 19c. |
Oracle 12.1+ | Works |
|
RAC | Works |
|
For EBS R12.2 + 19c specifically, customize MCP_SCHEMA_ALLOWLIST:
MCP_SCHEMA_ALLOWLIST=APPS,APPLSYS,FND,AR,AP,GL,SYSWhat's NOT included (yet)
Connection pooling — current implementation opens one connection per tool call. Fine for sparse MCP workloads; swap in
oracledb.create_pool()if you need higher throughput.Write-mode tools — by design. There are no
INSERT_*orUPDATE_*tools, and there never will be in this server. Write paths belong in dedicated, application-specific MCP servers with their own threat model.Thick-mode support for environments requiring Oracle Wallet — thin mode handles most cases including SSL; thick mode would need a separate code path.
Roadmap
Core tools: list_schemas, describe_table, run_select, explain_plan, top_sql
SQL guardrails + 45 security tests
PII column redaction
JSON-line audit log
AWR summary tool (top SQL + waits + time model in one JSON blob)
ASH wait-event sampler tool
AWR top SQL + time model tools
AWR feature flag (
MCP_ENABLE_AWR) for Diagnostic Pack gatingConnection pooling (
oracledb.create_pool()) for higher throughputHybrid TNS + thick-mode support (for environments requiring Oracle Wallet)
Structured failure responses (machine-readable JSON refusals with policy ID + retry guidance, per community feedback)
CI integration tests against a Docker
gvenzl/oracle-freeservice container
License
MIT. Oracle and Oracle Database are trademarks of Oracle Corporation. This project is not affiliated with or endorsed by Oracle.
Available Tools
5 toolsdescribe_tableA
Return column metadata for SCHEMA.TABLE.
Errors if `schema` is not in the configured allowlist.
Inputs: schema (required), table (required). Returns: result
explain_planB
Return Oracle EXPLAIN PLAN output for a SELECT query.
Inputs: sql (required). Returns: result
list_schemasA
List schemas the MCP server is allowed to query.
Schemas are configured via MCP_SCHEMA_ALLOWLIST. This is a
metadata tool — no DB call required.
Inputs: no named parameters. Returns: result
run_selectA
Run a SELECT or WITH query against Oracle.
Guardrails:
- Only SELECT / WITH statements allowed
- DDL, DML, PL/SQL blocks, DBMS_/UTL_/SYS. calls are rejected
- Result row count is capped (see MCP_MAX_ROWS)
- PII-named columns (SSN, SALARY, PASSWORD, …) are auto-redacted
- Server-side statement timeout enforced
Returns a list of column-name dicts.
Inputs: sql (required). Returns: result
top_sqlA
Top SQL by elapsed time from v$sql within the last N minutes.
Useful for "what's been slow recently?" investigations from Claude Desktop.
Inputs: window_minutes, limit. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a distinct purpose: listing schemas, describing table columns, executing arbitrary SELECT queries, explaining query plans, and showing top SQL by elapsed time. No overlaps.
All tool names follow a consistent lowercase snake_case verb_noun pattern (describe_table, explain_plan, list_schemas, run_select, top_sql).
5 tools is well-scoped for an Oracle DBA assistant covering metadata, query execution, performance analysis, and plan analysis.
Covers core DBA query workflow: schema discovery, table structure, arbitrary queries, explain plans, and top SQL. Missing list tables in a schema but that can be done via run_select.
Maintenance
Related MCP Connectors
Paid remote MCP for governed database query review, SQL simulation, approvals, and audits.
Read-only MCP server for The Quiet Protocol's engines, benchmarks, proof, and business data.
Guarded MCP server for agent-readable business truth, provenance, readiness, and discovery.
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables interaction with Oracle databases through MCP by executing SELECT queries, describing table structures, and listing available tables with secure, read-only access.32ISC
- AlicenseNot gradedqualityDmaintenanceRead-only SQL Server MCP server enabling safe database queries, table listing, and schema inspection with built-in security protections.MIT
- FlicenseNot gradedqualityDmaintenanceA read-only MCP server for Oracle databases that enables SQL queries, schema inspection, and data sampling without requiring OCI client libraries. It supports both TNS alias and direct connection modes with robust security guardrails.-
- FlicenseNot gradedqualityDmaintenanceA read-only MCP server for exploring and querying Oracle schemas safely. Provides tools for table listing, schema description, column search, and validated SELECT execution.2-