Sunday, August 9, 2026

Unlocking AI-Driven Databases with Oracle DB MCP (Model Context Protocol)

As organizations increasingly integrate AI into their workflows, one challenge keeps surfacing:

How do we securely and efficiently connect large language models (LLMs) to enterprise data in a standard fashion?

This is where MCP (Model Context Protocol) comes in.

Model Context Protocol (MCP) is an open standard that enables LLMs to securely access external systems such as databases, APIs, and files through a unified interface.

Think of MCP as a universal adapter for AI, eliminating the need to build custom integrations for every data source. 

Why MCP Matters

MCP is not just a technical convenience—it’s a shift in how we interact with data:

  • Faster development - no need for custom connectors
  • Improved accessibility - non-technical users can query data using plain English
  • Built-in governance - auditing and monitoring are part of the architecture
  • Reduced risk - access is controlled via database privileges 

MCP in Oracle DB: Two Approaches

Oracle provides two primary ways to work with MCP, depending on your environment.

1. Autonomous Database (ADB) MCP (Easiest Option)

Oracle Autonomous Database includes a built-in MCP server that can be enabled with a simple configuration.

How to enable:
In OCI go to the ADB page and under Tags, add a free-form tag to your database:

Key: adb$feature
Value: {"name":"mcp_server","enable":true}

This approach is ideal for:

  • Cloud-first environments
  • Quick setup with minimal configuration
  • Built-in scalability and management

For additional information see 



2. SQLcl MCP Server (Flexible Option)

For all supported non-Autonomous databases (e.g., Oracle 19c, 23/26ai), Oracle provides MCP support via SQLcl.

Requirements:

  • SQLcl version 25.2 or later
  • Java 17+

Key capabilities include:

  • list-connections – discover saved database connections
  • connect / disconnect – manage sessions
  • run-sql – execute SQL and PL/SQL
  • run-sqlcl – run SQLcl-specific commands

This option is ideal for:

  • On-prem or hybrid environments
  • Advanced customization scenarios
 

Additional SQLcl MCP Resources:

Autonomous vs SQLcl MCP Comparison

Usually, the 2 options don't compete



Key Advantages of Oracle MCP

Oracle’s MCP implementation brings enterprise-grade capabilities that go beyond basic integrations:

  • Natural language queries eliminate the need for SQL expertise
  • Automatic SQL generation reduces development effort
  • Audit trails (via DBTOOLS$MCP_LOG) track all LLM interactions
  • Session monitoring through V$SESSION
  • Support for complex workflows, including schema exploration and performance tuning


Connecting MCP Clients

To use MCP, you connect a client (AI tool or IDE) to the MCP server.

In most cases you can ask the AI tool to help you configure the MCP connection and it will guide you.

Popular options include:


Example: VS Code + Cline Setup (Autonomous DB, Windows)

Here’s a simplified configuration example:

On Windows verify you have npx.cmd by running:

   - 'node -v'
   - '& "C:\Program Files\nodejs\npx.cmd" -v'

Add this MCP server config in Cline (Edit Config) where Oracle_ADW_DB is the database name:

{
"mcpServers": {
"Oracle_ADW_DB": {
"command": "C:\\Program Files\\nodejs\\npx.cmd",
"args": [
"-y",
"mcp-remote",
"https://<YOUR-REGION>/adb/mcp/v1/databases/<YOUR_ADB_OCID>",
"--allow-http"
],
"transport": "streamable-http"
}
}
}

What’s Happening Here

  • npx mcp-remote → acts as MCP client proxy
  • Connects to remote Oracle MCP endpoint
  • Streams requests/responses between LLM and DB
  • streamable-http → enables bidirectional communication

Steps:

  1. Replace the region and database OCID
  2. Save config and restarted VS Code, then checked connection in Cline MCP panel.
  3. Verify connection in the MCP panel
  4. Run a simple test query:
SELECT USER, SYS_CONTEXT('USERENV','CURRENT_SCHEMA') FROM dual;

What Happens Internally

  1. LLM generates intent
  2. MCP client maps to run-sql tool
  3. SQL is sent to MCP server
  4. DB executes query
  5. Results returned as structured response

This is fundamentally different from:

  • Direct JDBC execution
  • ORM-based queries
  • API wrappers

Security Best Practices

When connecting LLMs to databases, security is critical.

A recommended approach is to create a read-only MCP user with minimal privileges:

CREATE USER MCP_USER IDENTIFIED BY "<password>";

GRANT CREATE SESSION TO MCP_USER;

GRANT SELECT ON APP_SCHEMA.TABLE_1 TO MCP_USER;
GRANT SELECT ON APP_SCHEMA.TABLE_2 TO MCP_USER;

For easier management, you can use roles:

CREATE ROLE MCP_READ_ROLE;

GRANT SELECT ON APP_SCHEMA.TABLE_1 TO MCP_READ_ROLE;
GRANT MCP_READ_ROLE TO MCP_USER;
⚠️ Important: Always follow the principle of least privilege. LLMs generate actions based on intent, not risk awareness, so unrestricted access can lead to unintended operations.

In my case I granted the MCP User full privileges in its schema and specific read only grants on other resources. 

⚠️ The Security aspect here is important. MCP does not introduce a new security layer. It relies entirely on existing Oracle privileges


Auditing and Observability

Oracle MCP provides native observability hooks:

1. Interaction Logging

  • Table: DBTOOLS$MCP_LOG
  • Tracks:
    • Prompts
    • Generated SQL
    • Execution metadata

2. Session Monitoring

SELECT * FROM V$SESSION WHERE PROGRAM = 'SQLcl-MCP';

This allows:

  • Real-time tracking of MCP sessions
  • Integration with existing monitoring tools

Final Thoughts

MCP represents a major step forward in bridging AI and enterprise data.

With Oracle’s built-in support, especially in Autonomous Database, you can enable secure, auditable, and AI-driven data access in minutes.

As AI adoption grows, MCP is quickly becoming a foundational component of modern data architectures.