Run SQLcl as a MCP Server with Oracle AI Database Free

Model Context Protocol (MCP) is an open-source protocol that exposes data, tools, or services via a standardized interface for large language models (LLMs).

In short, MCP provides contextual resources and tooling capabilities to LLMs, enabling modular AI-driven workflows with strong interoperability.

In this article, we’ll show how to configure Oracle AI Database Free with the latest version of SQLcl as an MCP server and connect it to an AI agent, allowing you to interact with your database using natural language!

Connect to Oracle AI Database Free

First, let’s set up an Oracle AI Database Free container to use with SQLcl. We’ll use the gvenzl/oracle-free image. If you’re not a fan of containers, check out Get Started With Oracle AI Database Free for other free or low-cost ways to run Oracle AI Database.

docker pull gvenzl/oracle-free:23.26.0-slim-faststart

The image is around 4 GB, so it may take a couple minutes to download if you’re on a slow internet connection.

Next, start the image. It should be up and ready-to-use in a matter of seconds:

docker run --name oracledb -d -p 1521:1521 -e ORACLE_RANDOM_PASSWORD=y -e APP_USER=testuser -e APP_USER_PASSWORD=testpwd gvenzl/oracle-free:23.26.0-slim-faststart

Configure SQLcl

Download the latest version of SQLcl, and unzip the package onto your system. You can start SQLcl using the bin/sql file in the downloaded package. To use SQLcl, make sure Java 17 or later is installed and available on your path.

With SQLcl, connect to your database using the app user created during container startup:

<path to SQLcl>/bin/sql  testuser/testpwd@localhost/freepdb1
SQLcl: Release 25.4 Production on Mon Apr 06 12:16:50 2026

Copyright (c) 1982, 2026, Oracle.  All rights reserved.

Last Successful login time: Mon Apr 06 2026 12:16:50 -07:00

Connected to:
Oracle AI Database 26ai Free Release 23.26.1.0.0 - Develop, Learn, and Run for Free
Version 23.26.1.0.0

Then, save the connection for command line MCP access:

conn -save cline_mcp -savepwd testuser/testpwd@localhost/freepdb1
SQL> conn -save cline_mcp -savepwd testuser/testpwd@localhost/freepdb1
Name: cline_mcp
Connect String: localhost/freepdb1
User: testuser
Password: ******
Connected.

Configuring Claude Desktop to use SQLcl MCP Server

We’ll use Claude Desktop in this example, but you can use any AI tool that supports MCP. To get started, download and install Claude Desktop.

Once you’ve downloaded Claude Destkop, configure the developer settings to use SQLcl as an MCP server.

Settings panel of Claude Desktop application showing the Developer section with options to edit configuration and start using Model Context Protocol.

Open the Claude config file and add the following snippet, adding SQLcl as an MCP server. Replace the command path with the path to your SQLcl installation:

{
  "mcpServers": {
    "sqlcl": {
      "command": "<PATH TO SQLCL INSTALL>/bin/sql",
      "args": ["-mcp"]
    }
  }
}

Restart Claude and open a new chat. You can verify sqlcl is available as a tool by clicking the “Search and tools” icon.

User interface showing SQLcl option highlighted in a list of features for an AI tool.

You can also view the database tools Claude has access to, like running SQL commands:

A user interface displaying connection options and command functionalities for a database management tool.

Now that everything’s configured, let’s try it out!

Let’s see if Claude can use SQLcl to create a simple schema, using the following prompt:

create simple, related tables for customers/products/orders, with a maximum of 6 columns per table. Use sqlcl to create the tables in my database.

Claude then issues a series of commands to open a database connection and create tables using the run-sql tool. You’ll be prompted each time to accept or deny the tool call:

A screenshot of a dialogue box showing SQL commands and interactions related to creating database tables in an Oracle database using SQLcl.

Claude ends up creating the following customers, products, and orders tables in the database:

A structured overview of database tables including Customers, Products, and Orders, each with six defined columns and their specifications.

Let’s try populating the schema with a few records, using the following prompt:

Populate the schema with around 25 records.

In my environment, Claude adds the following data:

Summary of database schema populated with sample data, including total records, number of customers, products, and orders, along with example data for each category.

Let’s now ask an analytics question, “what are my top 5 most profitable products and customers?”. Claude generates two queries, runs them using sqlcl, and displays the results in natural language:

SELECT /* LLM in use is claude-sonnet-4 */ 
    p.product_name,
    p.category,
    p.price,
    COUNT(o.order_id) as total_orders,
    SUM(o.total_amount) as total_revenue
FROM products p
JOIN orders o ON p.product_id = o.product_id
GROUP BY p.product_id, p.product_name, p.category, p.price
ORDER BY total_revenue DESC
FETCH FIRST 5 ROWS ONLY;
Table displaying the top 5 most profitable products with details on revenue and sales performance.

It’s fun to play around with, using natural language to interact with your database. I suggest experimenting with different prompts and observing the output.

Should I connect my prod DB using MCP?

Word of warning: AI tools are non-deterministic! It’s best practice to use a read-only, sanitized replica of your data, assign least permissions to the MCP server user, and avoid sending private data to public LLMs.

The SQLcl MCP Server user’s guide has some excellent guidelines around secure usage, which I recommend reading in detail before deploying MCP in a production system.

SQLcl’s MCP server support is continuously evolving, with a rapid release schedule. You can expect additional database features in future release like SQL plans and more!

References

Response

  1. […] To use it, you need SQLcl version 25.2 or newer. andersswanson.dev+2Oracle Blogs+2 […]

Leave a Reply

Discover more from andersswanson.dev

Subscribe now to keep reading and get access to the full archive.

Continue reading