Wednesday, July 01, 2026

Using Oracle SQLcl MCP with Claude Code CLI tool

While SQL Developer for VS Code provides a built-in "one-click" MCP for Copilot, Claude Code requires you to explicitly add the database MCP server (like SQLcl for Oracle or generic SQL servers) using its CLI.

Here are the steps I used to configure it with CC: 

 (1) Download SQLcl 

You may download the latest Oracle SQLcl tool which supports MCP at https://www.oracle.com/database/sqldeveloper/technologies/sqlcl/download/ , current version 26.1.
 
In my case, it was downloaded last year with version 25.2 it is at my local path: C:\users\dsun\sqlcl-latest\sqlcl\bin 

(2) Add the SQL MCP Server In my project directory C:\Users\dsun\ClaudeCode_DBA_Assistant:
PS C:\Users\dsun\ClaudeCode_DBA_Assistant> claude mcp add --transport stdio sqlcl -- C:\users\dsun\sqlcl-latest\sqlcl\bin\sql -mcp
Added stdio MCP server sqlcl with command: C:\users\dsun\sqlcl-latest\sqlcl\bin\sql -mcp to local config
File modified: C:\Users\dsun\.claude.json [project: C:\Users\dsun\ClaudeCode_DBA_Assistant]
(3) Verify the Connection
 
PS C:\Users\dsun\ClaudeCode_DBA_Assistant> claude mcp list
sqlcl: C:\users\dsun\sqlcl-latest\sqlcl\bin\sql -mcp - v Connected
PS C:\Users\dsun\ClaudeCode_DBA_Assistant>

(4) Create a saved connection Note: using -thin is necessary in my environment to avoid error from " thick client "
PS C:\users\dsun\sqlcl-latest\sqlcl\bin> .\sql -thin 'test/"xxzzzzzz"@dbhost1.mycompany.com:1521/testdb'


SQLcl: Release 25.2 Production on Wed Jul 01 07:07:37 2026

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

Last Successful login time: Wed Jul 01 2026 07:07:42 -04:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.28.0.0.0

SQL> conn -save testdb_cc -savepwd
Name: testdb_cc
Connect String: dbhost1.mycompany.com:1521/testdb
User: test
Password: ******
 
(5) Interact with database in CC CLI Using natural language e.g. sqlcl show 10 largest tables in testdb_cc
PS C:\Users\dsun\ClaudeCode_DBA_Assistant> claude
 ¦?¦¦¦?¦   Claude Code v2.1.181
??¦¦¦¦¦??  Haiku 4.5 · API Usage Billing
  ?? ??    ~\ClaudeCode_DBA_Assistant


> sqlcl show 10 largest tables in testdb_cc

  Thought for 3s, called MCP (ctrl+o to expand)

? I'll connect to testdb_cc and query the 10 largest tables using sqlcl.

  Called sqlcl 2 times (ctrl+o to expand)

? Now I'll query the 10 largest tables by size.

  Called sqlcl (ctrl+o to expand)

? Let me check the available columns in DBA_TABLES and use the correct approach.

  Called sqlcl 2 times (ctrl+o to expand)

? Let me use DBA_SEGMENTS instead, which contains the actual allocated space:

  Called sqlcl (ctrl+o to expand)

? Here are the 10 largest tables in testdb_cc:

  +-------------------------------------------------------------------+
  ¦ Owner ¦    Table Name     ¦ Size (GB) ¦ Segment Type ¦ Tablespace ¦
  +-------+-------------------+-----------+--------------+------------¦
  ¦ TEST  ¦ LOGFILE_SYNC_TEST ¦ 57.30     ¦ TABLE        ¦ USERS      ¦
  +-------+-------------------+-----------+--------------+------------¦
  ¦ USER1 ¦ CF1               ¦ 2.06      ¦ TABLE        ¦ IOPS       ¦
  +-------+-------------------+-----------+--------------+------------¦
  ¦ USER3 ¦ CF1               ¦ 2.01      ¦ TABLE        ¦ IOPS       ¦
  +-------+-------------------+-----------+--------------+------------¦
  ¦ USER5 ¦ CF1               ¦ 2.00      ¦ TABLE        ¦ IOPS       ¦
  +-------+-------------------+-----------+--------------+------------¦
  ¦ USER4 ¦ CF1               ¦ 2.00      ¦ TABLE        ¦ IOPS       ¦
  +-------+-------------------+-----------+--------------+------------¦
  ¦ USER7 ¦ CF1               ¦ 2.00      ¦ TABLE        ¦ IOPS       ¦
  +-------+-------------------+-----------+--------------+------------¦
  ¦ USER6 ¦ CF1               ¦ 2.00      ¦ TABLE        ¦ IOPS       ¦
  +-------+-------------------+-----------+--------------+------------¦
  ¦ USER2 ¦ CF1               ¦ 1.99      ¦ TABLE        ¦ IOPS       ¦
  +-------+-------------------+-----------+--------------+------------¦
  ¦ USER8 ¦ CF1               ¦ 1.98      ¦ TABLE        ¦ IOPS       ¦
  +-------+-------------------+-----------+--------------+------------¦
  ¦ TPCC  ¦ STOCK             ¦ 0.18      ¦ TABLE        ¦ TPCC_DATA  ¦
  +-------------------------------------------------------------------+

  Key observations:
  - The TEST.LOGFILE_SYNC_TEST table dominates storage at 57.3 GB (likely a test/load table)
  - Multiple user schemas (USER1-USER8) have similarly-sized CF1 tables (~2 GB each) in the IOPS tablespace
  - The TPCC.STOCK table is relatively small at 0.18 GB in the TPCC_DATA tablespace

  Would you like to analyze space usage patterns, identify candidates for cleanup, or investigate the purposes of these large tables?

? Worked for 25s

? recap: Identified 10 largest tables in testdb_cc: TEST.LOGFILE_SYNC_TEST dominates at 57.3GB, followed by USER schemas' CF1 tables at ~2GB each. Awaiting next diagnostic step. (disable recaps in /config)


In summary, this post demonstrates how to connect Oracle SQLcl to the Claude Code CLI tool using the Model Context Protocol (MCP). By registering SQLcl as an MCP server and saving database credentials locally, users can query Oracle databases using natural language commands directly within the Claude Code interface. In the provided walkthrough, Claude successfully identifies the 10 largest tables in an Oracle 19c database by dynamically inspecting data dictionary views like DBA_SEGMENTS.

No comments: