Content is user-generated and unverified.

SQLcl MCP Demo Guide

Overview

This guide will walk you through setting up Oracle Database 23ai with SQLcl MCP server support on macOS, enabling AI-powered natural language database interactions.

Prerequisites

System Requirements

  • macOS 10.15 or later (Intel or Apple Silicon)
  • 8GB RAM minimum (16GB recommended)
  • 10GB free disk space
  • Admin privileges for installations

Step 1: Install Required Software

1.1 Install Homebrew (if not already installed)

bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

1.2 Install Oracle Java 17 or higher

Option A: Using Homebrew (Recommended)

bash
# Install Oracle JDK (latest version - currently Java 24)
brew install --cask oracle-jdk

# Find the Java installation path
/usr/libexec/java_home -V

# The output will show available Java versions. Look for the Oracle JDK path.
# For Java 24, it should be something like:
# /Library/Java/JavaVirtualMachines/jdk-24.jdk/Contents/Home

# Set JAVA_HOME using the dynamic path (recommended)
echo 'export JAVA_HOME="$(/usr/libexec/java_home)"' >> ~/.zshrc
echo 'export PATH="$JAVA_HOME/bin:$PATH"' >> ~/.zshrc

# OR set it to the specific Java 24 path if you see it:
# echo 'export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-24.jdk/Contents/Home"' >> ~/.zshrc
# echo 'export PATH="$JAVA_HOME/bin:$PATH"' >> ~/.zshrc

# Reload your shell
source ~/.zshrc

# Verify installation
java -version

Option B: Manual Download

bash
# 1. Download Oracle JDK from: https://www.oracle.com/java/technologies/downloads/
# 2. Choose macOS x64 Installer (.dmg) for Java 17 or later
# 3. Install the .dmg file
# 4. Find the installed version
/usr/libexec/java_home -V

# 5. Set JAVA_HOME (using dynamic path)
echo 'export JAVA_HOME="$(/usr/libexec/java_home)"' >> ~/.zshrc
echo 'export PATH="$JAVA_HOME/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

# Verify installation
java -version

Expected output should show Oracle Corporation as the vendor (Java 24 example):

java version "24.0.x" 2024-xx-xx
Java(TM) SE Runtime Environment (build 24.0.x+xx-xxx)
Java HotSpot(TM) 64-Bit Server VM (build 24.0.x+xx-xxx, mixed mode, sharing)

Note: Oracle JDK is free for development and testing purposes. For production use, please review Oracle's licensing terms at: https://www.oracle.com/java/technologies/javase/jdk-faqs.html

Java 24 Compatibility: SQLcl works perfectly with Java 24. Oracle tests their tools with the latest Java versions, so you're getting the most up-to-date performance and security features.

1.3 Install Docker Desktop

  1. Download Docker Desktop for Mac from: https://docker.com/products/docker-desktop
  2. Install the .dmg file
  3. Start Docker Desktop from Applications
  4. Verify installation:
bash
docker --version

Step 2: Set Up Oracle Database 23ai

2.1 Pull and Run Oracle Database 23ai Container

bash
# Pull the Oracle Database 23ai Free image (latest version)
docker pull gvenzl/oracle-free:latest

# Alternative: Use the slim version for faster download (recommended)
docker pull gvenzl/oracle-free:slim

# Create a Docker network for Oracle
docker network create oracle-network

# Run Oracle Database 23ai container (using slim version)
docker run -d \
  --name oracle23ai \
  --network oracle-network \
  -p 1521:1521 \
  -p 5500:5500 \
  -e ORACLE_PASSWORD=Welcome123 \
  -e APP_USER=demo \
  -e APP_USER_PASSWORD=demo123 \
  -v oracle-data:/opt/oracle/oradata \
  gvenzl/oracle-free:slim

Available Tags:

  • latest - Latest full version (larger download ~8GB)
  • slim - Latest slim version (smaller download ~5GB, recommended for demos)
  • 23 - Latest Oracle Database 23 version
  • 23-slim - Latest Oracle Database 23 slim version
  • 23.6-slim or 23.7-slim - Specific version numbers

Recommendation: Use slim for this demo as it downloads faster and contains all the features you need.

2.2 Verify Database is Running

bash
# Check container status
docker ps

# Wait for database to be ready (may take 2-3 minutes)
docker logs -f oracle23ai

# Look for: "DATABASE IS READY TO USE!"

2.3 Test Database Connection

bash
# Connect to the database container (suppress Java warnings)
export JAVA_TOOL_OPTIONS="--enable-native-access=ALL-UNNAMED"
docker exec -it oracle23ai sqlplus sys/Welcome123@//localhost:1521/FREE as sysdba

# Or connect with SQLcl
sql sys/Welcome123@//localhost:1521/FREE as sysdba

# In SQLPlus/SQLcl, run:
SELECT banner FROM v$version;
EXIT;

Step 3: Install and Configure SQLcl

3.1 Download SQLcl

bash
# Create directory for SQLcl
mkdir -p ~/oracle-tools
cd ~/oracle-tools

# Download latest SQLcl
curl -L -o sqlcl-latest.zip https://download.oracle.com/otn_software/java/sqldeveloper/sqlcl-latest.zip

# Extract SQLcl
unzip sqlcl-latest.zip

3.2 Configure SQLcl Environment

bash
# Add to your shell profile (~/.zshrc)
echo 'export SQLCL_HOME="$HOME/oracle-tools/sqlcl"' >> ~/.zshrc
echo 'export PATH="$SQLCL_HOME/bin:$PATH"' >> ~/.zshrc

# Add Java options to suppress warnings with Java 24
echo 'export JAVA_TOOL_OPTIONS="--enable-native-access=ALL-UNNAMED"' >> ~/.zshrc

# Reload shell
source ~/.zshrc

# Verify SQLcl installation
sql -version

Step 4: Set Up Database Users and Security

4.1 Create Dedicated MCP User

bash
# Connect as SYSDBA
sql sys/Welcome123@//localhost:1521/FREE as sysdba

# In SQLcl, create MCP user:
sql
-- Create MCP user with limited privileges
CREATE USER mcp_user IDENTIFIED BY mcp123;

-- Grant necessary privileges
GRANT CONNECT, RESOURCE TO mcp_user;
GRANT CREATE SESSION TO mcp_user;
GRANT SELECT ANY TABLE TO mcp_user;  -- For demo only, be more restrictive in production

-- Grant quota on USERS tablespace (essential for creating tables)
ALTER USER mcp_user QUOTA UNLIMITED ON USERS;

-- Grant the new 23ai developer role
GRANT DB_DEVELOPER_ROLE TO mcp_user;

-- Create some sample data
CONNECT mcp_user/mcp123@//localhost:1521/FREE;

-- Create sample tables
CREATE TABLE employees (
    id NUMBER PRIMARY KEY,
    name VARCHAR2(100),
    department VARCHAR2(50),
    salary NUMBER,
    hire_date DATE
);

CREATE TABLE departments (
    id NUMBER PRIMARY KEY,
    name VARCHAR2(50),
    manager VARCHAR2(100),
    budget NUMBER
);

-- Insert sample data
INSERT INTO employees VALUES (1, 'John Smith', 'Engineering', 75000, DATE '2023-01-15');
INSERT INTO employees VALUES (2, 'Jane Doe', 'Marketing', 65000, DATE '2023-02-20');
INSERT INTO employees VALUES (3, 'Bob Wilson', 'Engineering', 80000, DATE '2022-11-10');
INSERT INTO employees VALUES (4, 'Alice Brown', 'Sales', 70000, DATE '2023-03-05');

INSERT INTO departments VALUES (1, 'Engineering', 'Tech Lead', 500000);
INSERT INTO departments VALUES (2, 'Marketing', 'Marketing Director', 300000);
INSERT INTO departments VALUES (3, 'Sales', 'Sales Manager', 400000);

COMMIT;

EXIT;

4.2 Create and Save SQLcl Connections

bash
# Suppress Java warnings
export JAVA_TOOL_OPTIONS="--enable-native-access=ALL-UNNAMED"

# Start SQLcl without connecting
sql /nolog
sql
-- Create and save named connections WITH PASSWORDS (essential for MCP)
CONN -save oracle23ai -replace -savepwd mcp_user/mcp123@//localhost:1521/FREE

-- Also create a SYS connection for admin tasks  
CONN -save sys_admin -replace -savepwd sys/Welcome123@//localhost:1521/FREE as sysdba

-- List saved connections to verify (correct SQLcl command)
CONNMGR LIST

-- Show details of a specific connection
CONNMGR SHOW oracle23ai

-- Test the saved connection
CONN oracle23ai
SELECT 'Connection test successful' as status FROM dual;

EXIT;

Critical Flags Explained:

  • -save connection_name - Saves the connection with a name
  • -replace - Replaces existing connection if it exists
  • -savepwd - ESSENTIAL: Saves password so MCP can reconnect automatically
  • Without -savepwd, MCP server will fail with connection errors

Connection Naming Best Practice:

  • Use descriptive names like oracle23ai, prod_db, test_env
  • The name oracle23ai clearly identifies this as your Oracle Database 23ai instance
  • This name will appear in Claude Desktop when listing available connections

Connection Management Tips:

sql
-- List all saved connections
CONNMGR LIST

-- Show details of a specific connection
CONNMGR SHOW connection_name

-- Test a connection
CONNMGR TEST connection_name

-- Delete a saved connection if needed
-- (Currently not available in SQLcl - you need to re-save to overwrite)

-- Update a saved connection (with password)
CONN -save oracle23ai -replace -savepwd new_user/new_password@//localhost:1521/FREE

-- Create connections for different environments (all with saved passwords)
CONN -save dev_env -replace -savepwd user/pass@//dev-server:1521/DEV
CONN -save test_env -replace -savepwd user/pass@//test-server:1521/TEST
CONN -save prod_readonly -replace -savepwd readonly_user/pass@//prod-server:1521/PROD

Security Note: While -savepwd stores passwords, they are encrypted in SQLcl's connection store. For production environments, consider using Oracle Wallet or other secure credential management.

Step 5: Start SQLcl MCP Server

5.1 Launch MCP Server

bash
# Start SQLcl in MCP mode
sql -mcp

You should see output like:

---------- MCP SERVER STARTUP ----------
MCP Server started successfully on [timestamp]
Press Ctrl+C to stop the server
----------------------------------------

Keep this terminal window open - the MCP server needs to run continuously.

Step 6: Configure AI Client

6.1 Install Claude Desktop

  1. Download Claude Desktop from: https://test.groupbuyclub.com/download
  2. Install and sign in to your Anthropic account

6.2 Configure MCP in Claude Desktop

Current Method (2025):

Get started by opening up the Claude menu on your computer and select "Settings…" Please note that these are not the Claude Account Settings found in the app window itself.

IMPORTANT: Don't click on Settings in the actual app pane or you'll be really, really disappointed. Go to your menubar and select "Settings…"

Step by step:

  1. Open Claude Desktop
  2. Click on "Claude" in the menubar (top of screen, not in the app)
  3. Select "Settings…" from the dropdown menu
  4. Click on "Developer" in the left-hand bar of the Settings pane, and then click on "Edit Config"
  5. Add the SQLcl MCP server configuration:
json
{
  "mcpServers": {
    "oracle-sqlcl": {
      "command": "/Users/[your-username]/oracle-tools/sqlcl/bin/sql",
      "args": ["-mcp"],
      "env": {
        "JAVA_HOME": "/Library/Java/JavaVirtualMachines/jdk-24.jdk/Contents/Home"
      }
    }
  }
}

6. Save the file and restart Claude Desktop

Alternative: Extensions Method (Newer)

With the introduction of desktop extensions (DXT), installing and managing local MCP servers has become significantly easier.

  1. Open Claude Desktop
  2. Navigate to Settings > Extensions within Claude Desktop
  3. Look for available MCP extensions to install with one click

Note: Replace [your-username] with your actual username. If you're unsure of your Java path, run /usr/libexec/java_home in terminal to get the exact path.

Manual Configuration File Method (If Needed)

If you prefer to edit the configuration file directly:

Location on macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Content:

json
{
  "mcpServers": {
    "oracle-sqlcl": {
      "command": "/Users/[your-username]/oracle-tools/sqlcl/bin/sql",
      "args": ["-mcp"],
      "env": {
        "JAVA_HOME": "/Library/Java/JavaVirtualMachines/jdk-24.jdk/Contents/Home"
      }
    }
  }
}

How to Verify MCP is Working

After configuration and restart:

  1. Look for a hammer/tools icon in the bottom-right corner of Claude Desktop
  2. Click it to see available MCP tools
  3. You should see tools like "connect", "run-sql", "list-connections"

Step 7: Test Everything Works

7.1 First, Test Saved Connections

bash
# Suppress Java warnings
export JAVA_TOOL_OPTIONS="--enable-native-access=ALL-UNNAMED"

# Test saved connections
sql /nolog
sql
-- List all saved connections
CONNMGR LIST

-- Connect using saved connection name
CONN oracle23ai

-- Test the tables we created
SELECT table_name FROM user_tables;
SELECT * FROM employees;

-- Test switching connections
CONN sys_admin
SELECT username FROM dba_users WHERE username = 'MCP_USER';

EXIT;

7.2 Test SQLcl MCP Server

bash
# Start the MCP server
sql -mcp

Keep this terminal open - you should see:

---------- MCP SERVER STARTUP ----------
MCP Server started successfully on [timestamp]
Press Ctrl+C to stop the server
----------------------------------------

7.3 Test Claude Desktop Integration

  1. Restart Claude Desktop after MCP configuration
  2. Look for the hammer/tools icon in the bottom-right corner
  3. Click the tools icon to see available MCP tools
  4. You should see tools like:
    • list-connections
    • connect
    • run-sql
    • disconnect

Step 8: Demo Scenarios

8.1 Open New Terminal for Testing

Open a new terminal (keep the MCP server running in the first one).

8.2 In Claude Desktop, Try These Prompts:

Basic Connection Test

List all available database connections, then connect to oracle23ai and show me all available tables in the schema.

Data Analysis

Connect to oracle23ai and show me the highest paid employees and their departments.

Complex Query

Using the oracle23ai connection, create a report showing the average salary by department, including the department budget and the percentage of budget spent on salaries.

Schema Exploration

Connect to oracle23ai and describe the structure of the employees table and show me some sample data.

Data Manipulation

Using oracle23ai connection, add a new employee: Sarah Connor, Engineering department, salary $85000, hired today.

Advanced Analytics

Connect to oracle23ai and analyze employee salary trends. Show me the salary distribution by department and identify any salary outliers.

Database Administration

Using oracle23ai connection, show me the current database version, available tablespaces, and total number of objects in the mcp_user schema.

Note: By specifying the connection name (oracle23ai), Claude will use the MCP connect tool to establish the connection using your saved credentials.

Step 9: Monitor MCP Activity

9.1 Check MCP Logs in Database

bash
# In a new terminal, connect to database
export JAVA_TOOL_OPTIONS="--enable-native-access=ALL-UNNAMED"
sql oracle23ai
sql
-- View MCP activity logs
DESC DBTOOLS$MCP_LOG;

-- See recent MCP operations
SELECT 
    id,
    mcp_client,
    model,
    end_point_type,
    end_point_name,
    log_message,
    created_on
FROM DBTOOLS$MCP_LOG
ORDER BY created_on DESC;

9.2 Monitor Active Sessions

sql
-- Check active MCP sessions
SELECT 
    sid,
    serial#,
    username,
    module,
    action,
    status,
    logon_time
FROM v$session 
WHERE module LIKE '%MCP%' 
   OR username = 'MCP_USER';

Step 10: Advanced Demo Features

10.1 Create Complex Scenario

sql
-- Connect to the database first
-- sql oracle23ai (or use Claude Desktop with "Connect to oracle23ai")

-- Add more realistic data
CREATE TABLE sales_data (
    id NUMBER PRIMARY KEY,
    employee_id NUMBER,
    sale_date DATE,
    amount NUMBER,
    product VARCHAR2(50),
    FOREIGN KEY (employee_id) REFERENCES employees(id)
);

INSERT INTO sales_data VALUES (1, 4, DATE '2024-01-15', 15000, 'Enterprise Software');
INSERT INTO sales_data VALUES (2, 4, DATE '2024-01-20', 25000, 'Cloud Services');
INSERT INTO sales_data VALUES (3, 2, DATE '2024-01-18', 5000, 'Marketing Package');

COMMIT;

10.2 Test Advanced AI Prompts

Connect to oracle23ai and analyze the sales performance by employee. Create a summary report showing each salesperson's total sales, average deal size, and commission (assuming 5% commission rate).
Using oracle23ai connection, create a new table to track customer information and insert sample customer data for the sales we have recorded.
Connect to oracle23ai and generate a comprehensive business intelligence report showing employee performance, departmental budgets, and sales metrics with recommendations for improvement.

Step 11: Cleanup and Troubleshooting

11.1 Stop Services

bash
# Stop MCP server (Ctrl+C in the MCP terminal)
# Stop Docker container
docker stop oracle23ai

11.2 Restart Services

bash
# Start Oracle container
docker start oracle23ai

# Wait for database to be ready
docker logs -f oracle23ai

# Start MCP server
export JAVA_TOOL_OPTIONS="--enable-native-access=ALL-UNNAMED"
sql -mcp

11.3 Common Troubleshooting

SQLcl MCP Connection Issues

bash
# If you get "getCurrentConnection() is null" error:

# 1. MOST COMMON CAUSE: Missing -savepwd flag
# Re-save connections with passwords:
sql /nolog
CONN -save oracle23ai -replace -savepwd mcp_user/mcp123@//localhost:1521/FREE
CONNMGR LIST
EXIT;

# 2. Stop the current MCP server (Ctrl+C) and restart
export JAVA_TOOL_OPTIONS="--enable-native-access=ALL-UNNAMED"
sql -mcp

# 3. If still issues, try starting with explicit connection
sql mcp_user/mcp123@//localhost:1521/FREE -mcp

# 4. Verify saved connections work
sql /nolog
CONN oracle23ai
SELECT 'Test successful' FROM dual;
EXIT;

Alternative MCP Server Startup Methods

bash
# Method 1: Start with explicit connection
sql mcp_user/mcp123@//localhost:1521/FREE -mcp

# Method 2: Start and then connect via MCP tools
sql -mcp
# Then use Claude to connect

# Method 3: Use SQLcl with connection file
echo "mcp_user/mcp123@//localhost:1521/FREE" > connection.txt
sql @connection.txt -mcp

Verify MCP Server Status

bash
# Check if MCP server is responding
# In another terminal while MCP server is running:
ps aux | grep sql
netstat -an | grep LISTEN

# Test basic MCP functionality
echo '{"jsonrpc": "2.0", "method": "initialize", "params": {"capabilities": {}}, "id": 1}' | nc -l 3000

Claude Desktop MCP Troubleshooting

bash
# Check Claude Desktop logs (macOS)
tail -f ~/Library/Logs/Claude/claude_desktop.log

# Check MCP server configuration
cat ~/Library/Application\ Support/Claude/claude_desktop_config.json

# Restart Claude Desktop completely
# Close app, then restart

Connection Issues

bash
# Test database connectivity
sql mcp_user/mcp123@//localhost:1521/FREE

# Check Docker container
docker ps
docker logs oracle23ai

MCP Server Issues

bash
# Verify SQLcl version (should be 25.2+)
sql -version

# Check MCP server startup
sql -mcp -verbose

Security Best Practices

Production Considerations

  1. Never use these demo passwords in production
  2. Create read-only users for AI access when possible
  3. Use connection pooling and resource limits
  4. Regularly audit the DBTOOLS$MCP_LOG table
  5. Implement proper network security

Sample Production User

sql
-- Production-ready user setup
CREATE USER ai_readonly IDENTIFIED BY complex_password;
GRANT CONNECT TO ai_readonly;
GRANT SELECT ON specific_schema.specific_table TO ai_readonly;
-- Grant quota if the user needs to create temporary tables
-- ALTER USER ai_readonly QUOTA 100M ON USERS;
-- Grant only necessary permissions

Next Steps

  1. Explore Oracle 23ai AI Vector Search capabilities
  2. Set up SSL/TLS connections for production
  3. Integrate with your existing database schemas
  4. Create custom MCP tools for specific business needs
  5. Implement monitoring and alerting for MCP usage

Useful Commands Reference

bash
# Check running containers
docker ps

# View Oracle logs
docker logs oracle23ai

# Connect to database using saved connection
sql oracle23ai

# Connect to database directly
sql mcp_user/mcp123@//localhost:1521/FREE

# Start MCP server
sql -mcp

# Check SQLcl version
sql -version

# Save new connection with password
sql /nolog
CONN -save oracle23ai -replace -savepwd mcp_user/mcp123@//localhost:1521/FREE

# List saved connections
sql /nolog
CONNMGR LIST

# Show connection details
CONNMGR SHOW oracle23ai

Sample Claude Desktop Prompts:

  • List all available database connections, then connect to oracle23ai and show me all tables.
  • Connect to oracle23ai and show me employee salary statistics by department.
  • Using oracle23ai connection, create a monthly sales report with charts.

This demo provides a complete local development environment for experimenting with AI-powered database interactions using Oracle Database 23ai and SQLcl MCP server.

Content is user-generated and unverified.
    SQLcl MCP Demo Guide | Claude