oracledb-mcp

oracledb-mcp

MCP server for Oracle SQL performance diagnostics and AWR analysis, compatible with any MCP client that supports stdio or HTTP transports.

Category
Visit Server

README

OracleDB MCP Server

MCP server for Oracle SQL performance diagnostics and AWR analysis, compatible with any MCP client that supports stdio or HTTP transports.

Tools Included

This server now includes a broad DBRE-focused Oracle toolset:

  • health and readonly query execution
  • SQL rewrite and bind-template generation
  • AWR/ASH analysis and comparisons
  • long-running query detection (OEM-style)
  • bind-based SQL rewrite benchmark assistant (original vs rewritten with plan/timing diff)
  • SQL plan regression detection and rescue playbooks
  • SPM baseline create/manage/pack/unpack
  • SQL Profile script generation (coe_xfr_sql_profile style)
  • locking and blocking analysis
  • privilege/schema/stats/index audits
  • CPU/latency/memory/session pressure analytics
  • child cursor explosion and bind sensitivity analysis
  • alert log analyzer
  • SQL patch quarantine helper
  • SQL dependency impact map
  • local SQL hotlist manager

Full per-tool catalog (signature, purpose, example call):

  • docs/TOOL_CATALOG.md (auto-generated)
  • Current tool count: 54

Setup

cd <repo_root>
python3 -m pip install -r requirements.txt

Compatibility

  • Oracle versions: designed for 11.2.0.4 through 23ai/23c.
  • RAC: tools use GV$ views where cluster-wide context matters.
  • SQL syntax compatibility: server now includes automatic fallback for FETCH FIRST ... ROWS ONLY to legacy ROWNUM pattern when running against older versions.
  • Feature-dependent tools (AWR/ASH/SQL Monitor/SPM/SQL Patch/SQL Profile) require corresponding Oracle options, privileges, and pack licensing.

Observability (OpenTelemetry)

MCP tool spans can be exported with OpenTelemetry.

Enable tracing:

export TRACING=enabled
export OTEL_TRACES_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318/v1/traces"
# optional:
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <token>"

Console exporter (local debug):

export TRACING=enabled
export OTEL_TRACES_EXPORTER=console

MCP context propagation

The server extracts trace context from MCP request _meta (when provided), including:

  • traceparent
  • tracestate
  • baggage

This supports parent-child trace continuity between MCP clients and this server.

Reference:

  • OpenTelemetry MCP semantic conventions (context propagation): docs/gen-ai/mcp.md#context-propagation in open-telemetry/semantic-conventions

Run Server

STDIO (best for most MCP clients)

python3 oracledb_mcp.py --transport stdio

Streamable HTTP

python3 oracledb_mcp.py --transport streamable-http --port 8020

Client Configuration Examples

VS Code MCP (example)

{
  "mcpServers": {
    "oracledb-mcp": {
      "command": "python3",
      "args": ["<repo_root>/oracledb_mcp.py", "--transport", "stdio"],
      "env": {
        "ORACLE_USER": "<db_username>",
        "ORACLE_PASSWORD": "<db_password>",
        "ORACLE_DSN": "host:1521/service"
      }
    }
  }
}

Troubleshooting

  • Symptom: MCP client shows Running then immediately Stopped.
  • Fix checklist:
    • Ensure server entry uses stdio and points to <repo_root>/oracledb_mcp.py.
    • Ensure Python environment can import all requirements (pip install -r requirements.txt).
    • Confirm Oracle env vars are present: ORACLE_USER, ORACLE_PASSWORD, ORACLE_DSN.
    • Run directly to validate process startup:
      • python3 <repo_root>/oracledb_mcp.py --transport stdio
    • Run registration test:
      • python3 -m pytest -q tests/test_oracledb_mcp.py

Cursor MCP (example)

{
  "mcpServers": {
    "oracledb-mcp": {
      "command": "python3",
      "args": ["<repo_root>/oracledb_mcp.py", "--transport", "stdio"],
      "env": {
        "ORACLE_USER": "<db_username>",
        "ORACLE_PASSWORD": "<db_password>",
        "ORACLE_DSN": "host:1521/service"
      }
    }
  }
}

Claude Desktop MCP (example)

{
  "mcpServers": {
    "oracledb-mcp": {
      "command": "python3",
      "args": ["<repo_root>/oracledb_mcp.py", "--transport", "stdio"],
      "env": {
        "ORACLE_USER": "<db_username>",
        "ORACLE_PASSWORD": "<db_password>",
        "ORACLE_DSN": "host:1521/service"
      }
    }
  }
}

Example Calls

  • Query rewrite analysis:
    • oracle_suggest_query_rewrite(sql_text="select * from orders where trunc(created_at)=:d", sql_id="8f6t6uk2y6fht")
  • Bind-template generation:
    • oracle_generate_bind_query_from_vsql(sql_id="8f6t6uk2y6fht")
  • AWR analysis from file:
    • oracle_analyze_awr_report(report_path="/tmp/awr_12345_12346.txt")
  • AWR comparison:
    • oracle_compare_awr_reports(baseline_report_path="/tmp/awr_before.txt", target_report_path="/tmp/awr_after.txt")
  • Wait hotspot analysis:
    • oracle_waits_hotspots(hours=2, top_n=20)
  • Blocking tree:
    • oracle_blocking_sessions_analyzer(top_n=20)
  • Privilege audit:
    • oracle_role_privilege_audit(username="TARGET_USER", include_object_privileges=true)
  • OEM-style long running SQL:
    • oracle_oem_long_running_queries(min_elapsed_seconds=5, window_minutes=60, top_n=20, only_active=true)
  • Bind-based A/B SQL test:
    • oracle_test_query_with_binds(original_sql="...", candidate_sql="...", bind_sets=[...], iterations=3, fetch_rows=200)
  • End-to-end rewrite advisor + benchmark:
    • oracle_sql_rewrite_benchmark_assistant(sql_id="3mrzy6ugwvvz4", rewritten_sql="select ...", use_captured_binds=true, iterations=3, fetch_rows=200)

OEM-Style Tuning Workflow

  1. Find active long-running SQL (for example >5s):
    • oracle_oem_long_running_queries(min_elapsed_seconds=5, window_minutes=60, top_n=20, only_active=true)
  2. Deep diagnostics on selected SQL_ID:
    • oracle_planx_sql_id(sql_id="...", lookback_days=7)
  3. Benchmark original vs rewritten SQL with bind sets:
    • oracle_sql_rewrite_benchmark_assistant(sql_id="...", rewritten_sql="...", use_captured_binds=true, iterations=3)
  4. If rewritten SQL is consistently better and correct, roll out app change.

Examples Folder

examples/ now contains LLM-formatted prompt/response documentation (not raw JSON):

  • examples/TOOL_EXAMPLES.md

Testing

Registration test:

cd <repo_root>
python3 -m pytest -q tests/test_oracledb_mcp.py

Live Oracle integration test (executes all tools):

cd <repo_root>
ORACLE_USER='<db_username>' ORACLE_PASSWORD='<db_password>' ORACLE_DSN='<host:port/service>' python3 tests/integration_oracledb_mcp.py

Open Source

  • Contribution guide: CONTRIBUTING.md
  • CI pipeline: .github/workflows/ci.yml
  • Catalog generator: scripts/generate_tool_catalog.py

Privileges Recommended

At minimum, grant access to required views/packages for your operational model:

  • V_$SQL
  • V_$SQLAREA
  • V_$SQL_BIND_CAPTURE
  • V_$DATABASE
  • V_$INSTANCE
  • DBMS_WORKLOAD_REPOSITORY

Notes

  • oracle_execute_readonly_query intentionally blocks non-SELECT/WITH SQL for safety.
  • Bind capture visibility depends on Oracle version, cursor lifecycle, and capture settings.
  • AWR tooling works best with text exports. HTML can still work but parsed detail may be reduced.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured