mcp-oracle-dba
A read-only, audited, and SQL-guarded Model Context Protocol server for Oracle Database that lets MCP clients query Oracle databases safely with multi-layer security guards.
README
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.
Tools exposed
| Tool | What it does |
|---|---|
list_schemas |
Returns the allowlist of schemas the server is configured to query. |
describe_table |
Column metadata for SCHEMA.TABLE. Allowlist-enforced. |
run_select |
Validates + runs a SELECT / WITH query. Row-capped, PII-redacted. |
explain_plan |
Oracle EXPLAIN PLAN output for a query (DBMS_XPLAN.DISPLAY). |
top_sql |
Top SQL by elapsed time from v$sql over the last N minutes. |
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 uv- An 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 sync
2. Configure environment
cp .env.example .env
# Edit .env — set ORA_USER, ORA_PASSWORD, ORA_DSN
ORA_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/ -v
You 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 |
|---|---|---|
ORA_USER |
(required) | DB user (should be read-only) |
ORA_PASSWORD |
(required) | DB password |
ORA_DSN |
(required) | Easy-Connect or TNS-format DSN |
MCP_MAX_ROWS |
100 |
Hard cap on rows returned by run_select |
MCP_STATEMENT_TIMEOUT_SECONDS |
5 |
Server-side statement timeout |
MCP_SCHEMA_ALLOWLIST |
APPS,APPLSYS,SYS,RAGAPP |
Comma-separated schemas allowed for describe_table |
MCP_COLUMN_DENYLIST |
SSN,SALARY,TAX_ID,PASSWORD,… |
Column-name substrings to redact |
MCP_AUDIT_LOG |
./audit.log |
JSON-line audit log path |
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.
What's NOT included (yet)
- AWR / ASH tools (top wait events, time model, snapshot comparison) — see roadmap. Requires Oracle Diagnostic Pack license, so it's gated behind a feature flag.
- 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.
Roadmap
- [x] Core tools: list_schemas, describe_table, run_select, explain_plan, top_sql
- [x] SQL guardrails + 45 security tests
- [x] PII column redaction
- [x] JSON-line audit log
- [ ] AWR summary tool (top SQL + waits + time model in one JSON blob)
- [ ] ASH wait-event sampler tool
- [ ] Hybrid TNS + thick-mode support (for environments requiring Oracle Wallet)
- [ ] 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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。