2026年9月7日月曜日

GoogleのMCP Toolbox for DatabasesをOracle Databaseで使用してみる

GoogleのMCP Toolbox for DatabaseがMCPの2026-07-28を実装したので、Oracle Databaseに接続して使用してみました。

Introduction

オープン・ソースのSDKがOracle Databaseをサポートしていることは少ない印象があるのですが、MCP ToolboxではOracle Databaseを使うことができます。

Oracle using MCP
Oracle Source

利用できるツールはoracle-execute-sql(任意のSQLの実行)、oracle-sql(事前に定義したSQLの実行)の2種類です。ドキュメントには他のツールもありますが、これはoracle-sqlツールにSELECT文を事前定義したツールのようです。

できるだけ時間をかけずに動作確認ができる手順で作業をします。

接続先のOracle Databaseとして手元のMacでコンテナとして動作している、Oracle AI Database 26ai Freeを使用します。接続先はlocalhost:1521/freepdb1になります。接続先となるデータベース・ユーザーはあらかじめ作成しておきます。

動作確認をするクライアントとしてMCP Inspectorを使います。バージョンがv2に上がって、UIが大幅に変更されています。

MCP Inspectorを使用する手順は、Getting StartedのQuickstart(MCP)に記載されています。

Quickstart(MCP)

Quickstart(MCP)のStep 1: Set up your databaseでセットアップするデータベースはpostgresです。今回の接続先はOracle Databaseを想定しているため、以下のスクリプトを実行します。
CREATE TABLE hotels (
  id            NUMBER PRIMARY KEY,
  name          VARCHAR2(80) NOT NULL,
  location      VARCHAR2(80) NOT NULL,
  price_tier    VARCHAR2(80) NOT NULL,
  checkin_date  DATE NOT NULL,
  checkout_date DATE NOT NULL,
  booked        NUMBER NOT NULL CHECK (booked IN (0, 1))
);

alter session set nls_date_format = 'YYYY-MM-DD';

INSERT INTO hotels(id, name, location, price_tier, checkin_date, checkout_date, booked)
VALUES (1, 'Hilton Basel', 'Basel', 'Luxury', '2024-04-22', '2024-04-20', 0);
INSERT INTO hotels(id, name, location, price_tier, checkin_date, checkout_date, booked)
VALUES (2, 'Marriott Zurich', 'Zurich', 'Upscale', '2024-04-14', '2024-04-21', 0);
INSERT INTO hotels(id, name, location, price_tier, checkin_date, checkout_date, booked)
VALUES (3, 'Hyatt Regency Basel', 'Basel', 'Upper Upscale', '2024-04-02', '2024-04-20', 0);
INSERT INTO hotels(id, name, location, price_tier, checkin_date, checkout_date, booked)
VALUES (4, 'Radisson Blu Lucerne', 'Lucerne', 'Midscale', '2024-04-24', '2024-04-05', 0);
INSERT INTO hotels(id, name, location, price_tier, checkin_date, checkout_date, booked)
VALUES (5, 'Best Western Bern', 'Bern', 'Upper Midscale', '2024-04-23', '2024-04-01', 0);
INSERT INTO hotels(id, name, location, price_tier, checkin_date, checkout_date, booked)
VALUES (6, 'InterContinental Geneva', 'Geneva', 'Luxury', '2024-04-23', '2024-04-28', 0);
INSERT INTO hotels(id, name, location, price_tier, checkin_date, checkout_date, booked)
VALUES (7, 'Sheraton Zurich', 'Zurich', 'Upper Upscale', '2024-04-27', '2024-04-02', 0);
INSERT INTO hotels(id, name, location, price_tier, checkin_date, checkout_date, booked)
VALUES (8, 'Holiday Inn Basel', 'Basel', 'Upper Midscale', '2024-04-24', '2024-04-09', 0);
INSERT INTO hotels(id, name, location, price_tier, checkin_date, checkout_date, booked)
VALUES (9, 'Courtyard Zurich', 'Zurich', 'Upscale', '2024-04-03', '2024-04-13', 0);
INSERT INTO hotels(id, name, location, price_tier, checkin_date, checkout_date, booked)
VALUES (10, 'Comfort Inn Bern', 'Bern', 'Midscale', '2024-04-04', '2024-04-16', 0);

commit;
exit;
MCP Toolboxのバイナリをダウンロードします。リリースのページを開き、適切なOS/Architectureのリンクから、バイナリをダウンロードします。私の環境はApple SiliconのmacOSなので、darwin/arm64のバイナリをダウンロードしています。MCP Toolboxは頻繁にアップデートされているようなので、最新のリリースを選択します。2026年9月7日の時点ではv1.10.0でした。



最初はPrebuiltのツールを使用します。Oracle向けのPrebuiltツールを使用する設定については、以下に記載されています。

Prebuilt Configs / Oracle

ダウンロードしたバイナリtoolboxに実行フラグを立てます。

chmod +x toolbox

mcp-toolbox % chmod +x toolbox 

mcp-toolbox % 


MCP ToolboxのPrebuilt構成が必要とする環境変数を設定します。Prebuilt構成を使用する場合、tools.yamlといった構成ファイルは不要です。

export ORACLE_CONNECTION_STRING="ホスト名:ポート番号/サービス名"
export ORACLE_USERNAME="データベース・ユーザー"
export ORACLE_PASSWORD="パスワード"
ORACLE_USE_OCI=false


ORACLE_USE_OCIをtrueにする場合、Oracle Instant Clientが必要です。今回はローカルのコンテナで実行しているOracle AI Database 26ai Freeを接続先とするため、ORACLE_USE_OCIをfalseとしています。Autonomous AI Databaseの場合はtrueにする必要があるでしょう。

mcp-toolbox % export ORACLE_CONNECTION_STRING="localhost:1521/freepdb1"

mcp-toolbox % export ORACLE_USERNAME="apexdev"

mcp-toolbox % export ORACLE_PASSWORD="パスワード"

mcp-toolbox % ORACLE_USE_OCI=false

mcp-toolbox % 


MCP ToolboxをOracleのPrebuilt構成で実行します。

./toolbox --prebuilt oracledb

Server ready to serve!と表示されれば、MCPサーバーとして接続できる状態です。

mcp-toolbox % ./toolbox --prebuilt oracledb                            

2026-09-07T14:24:21.940256+09:00 INFO "Starting MCP Toolbox for Databases version 1.10.0+binary.darwin.arm64.21f972f" 

2026-09-07T14:24:21.942172+09:00 INFO "Using prebuilt tool configurations for: oracledb" 

2026-09-07T14:24:21.942183+09:00 WARN "These prebuilt configs are intended for 'build-time' use cases, where agents are helping trusted developers build things. They are not secure enough for 'run time' use cases, where the agent will be talking to potentially untrusted developers." 

2026-09-07T14:24:22.016809+09:00 INFO "Initialized 1 sources: oracle-source" 

2026-09-07T14:24:22.016839+09:00 INFO "Initialized 0 authServices: " 

2026-09-07T14:24:22.016862+09:00 INFO "Initialized 0 embeddingModels: " 

2026-09-07T14:24:22.017076+09:00 INFO "Initialized 7 tools: list_top_sql_by_resource, list_tablespace_usage, list_invalid_objects, execute_sql, list_tables, list_active_sessions, get_query_plan" 

2026-09-07T14:24:22.017088+09:00 INFO "Initialized 0 prompts: " 

2026-09-07T14:24:22.017102+09:00 INFO "Initialized 2 groups: default, oracle_database_tools" 

2026-09-07T14:24:22.017493+09:00 WARN "wildcard (*) allows any website to access the primitives. This creates a security risk regardless of whether you are in a production or local development environment. Recommended to use --allowed-origins with specific local addresses." 

2026-09-07T14:24:22.017532+09:00 WARN "wildcard (*) hosts allow any domain to access this resource, making it vulnerable to DNS rebinding attacks regardless of whether you are in a production or local development environment. For improved security, use the --allowed-hosts flag to specify trusted domains." 

2026-09-07T14:24:22.017822+09:00 INFO "Server ready to serve!" 


MCP Inspectorを実行します。

npx @modelcontextprotocol/inspector

% npx @modelcontextprotocol/inspector


Starting MCP inspector...


MCP Inspector Web is up and running at:

   http://127.0.0.1:6274?MCP_INSPECTOR_API_TOKEN=26f426782a8a0ed97e6e2d79b1fd4941d91f06803defe71e92a0d77e22dbeb0e


   Sandbox (MCP Apps): http://127.0.0.1:6275/sandbox


   Auth token: 26f426782a8a0ed97e6e2d79b1fd4941d91f06803defe71e92a0d77e22dbeb0e


   Secrets: OS keychain


Opening browser...



ブラウザが起動し、MCP Inspectorの画面が開きます。

最初にAdd Serversから+ Add manuallyを実行します。現在実行中のMCP ToolboxをMCPサーバーとして登録します。


Server IDmcp-toolboxとします。Transportstreamable-httpを選択し、URLhttp://localhost:5000/mcpを設定します。MCP Toolboxはデフォルトで、リクエストをHTTPの5000番ポートで待ち受けます。


MCPサーバーmcp-toolboxが登録されます。Settingsを開きます。


新しいv2のMCP Inspectorは、MCPの2026-07-28を含むMCPの拡張機能に対応しています。


Advertise ExtensionsにはTasks(非同期実行)およびMCP Apps UIのサポートが含まれています。


OAuth SettingsEnterprise-managed authorizationが含まれています。


MCPサーバーに接続すると、クライアント/サーバー間のメッセージのやり取りが表示されます。


Connection Infoをクリックします。


Server Capabilitiesを見る範囲では、サポートされているのは実質的にToolsのみのようです。


Prebuilt構成として提供されているツールを確認します。Toolsタブを開きます。

execute_sqlは任意のSQLを実行するツールです。それ以外のget_query_plan、list_active_sessions、list_invalid_objects、list_tables、list_tablespace_usage、list_top_sql_by_resourceは受け付けるパラメータの有無はありますが、事前定義されたSQLを実行しているようです。


execute_sqlツールを選択し、sqlとしてselect * from hotelsを記述します。

Execute Toolをクリックし、sqlに与えたSELECT文を実行します。


表HOTELSの内容がJSONドキュメントとして返されます。


Prebuilt構成について、動作が確認できました。

Prebuilt構成で実質的に使用できるツールは、任意のSQLを実行するツールexecute_sqlのみです。それだけでは実用的ではないため、ツールを構成してみます。

任意のSQLを実行するツールとしてexecute_sqlは残し、その他に、すべてのホテルをリストするツールlist_all_hotelsと、指定したロケーションにあるホテルを、検索する上限を設定して返すツールlist_hotels_in_the_lcoationを作成します。

tools.yamlとして以下を記述します。Oracle Databaseの接続先、ユーザー名やパスワードは、Prebuilt構成の際に設定した環境変数を利用します。
kind: source
name: my-oracle-instance
type: oracle
connectionString: ${ORACLE_CONNECTION_STRING}
user: ${ORACLE_USERNAME}
password: ${ORACLE_PASSWORD}
---
# Execute arbitrary SQL.
kind: tool
name: execute_sql
type: oracle-execute-sql
source: my-oracle-instance
description: Use this tool to execute sql statement.
---
# List All hotels.
kind: tool
name: list_all_hotels
type: oracle-sql
source: my-oracle-instance
statement: |
  SELECT * FROM hotels
description: |
  Use this tools to list all hotels.
---
# List hotels located in specific location.
kind: tool
name: list_hotels_in_the_location
type: oracle-sql
source: my-oracle-instance
statement: |
  SELECT * FROM hotels WHERE location = :1
  FETCH FIRST :2 ROWS ONLY
description: |
  List hotels located in specified location. 
  Return the specified number of hotels.
  Example: 
  {{
      "location": "Basel",
      "limit": 10
  }}
parameters:
  - name: location
    type: string
    description: location of the hotel
  - name: limit
    type: integer
    description: number of the hotels to be returned
作成したtools.yamlを構成ファイルとして指定し、toolboxを実行します。

./toolbox --config tools.yaml

mcp-toolbox % ./toolbox --config tools.yaml

2026-09-07T15:34:36.871842+09:00 INFO "Starting MCP Toolbox for Databases version 1.10.0+binary.darwin.arm64.21f972f" 

2026-09-07T15:34:36.926093+09:00 INFO "Initialized 1 sources: my-oracle-instance" 

2026-09-07T15:34:36.926127+09:00 INFO "Initialized 0 authServices: " 

2026-09-07T15:34:36.926146+09:00 INFO "Initialized 0 embeddingModels: " 

2026-09-07T15:34:36.926185+09:00 INFO "Initialized 3 tools: execute_sql, list_all_hotels, list_hotels_in_the_location" 

2026-09-07T15:34:36.926192+09:00 INFO "Initialized 0 prompts: " 

2026-09-07T15:34:36.926206+09:00 INFO "Initialized 1 groups: default" 

2026-09-07T15:34:36.926224+09:00 WARN "wildcard (*) allows any website to access the primitives. This creates a security risk regardless of whether you are in a production or local development environment. Recommended to use --allowed-origins with specific local addresses." 

2026-09-07T15:34:36.926339+09:00 WARN "wildcard (*) hosts allow any domain to access this resource, making it vulnerable to DNS rebinding attacks regardless of whether you are in a production or local development environment. For improved security, use the --allowed-hosts flag to specify trusted domains." 

2026-09-07T15:34:36.926503+09:00 INFO "Server ready to serve!" 



MCP Inspectorからツール一覧を確認します。

tools.yamlに設定したツールexecute_sqllist_all_hotelslist_hotels_in_the_locationの3つが現れていることが確認できます。


ツールlist_hotels_in_the_locationを選択すると、パラメータとして設定したlimitlocationの入力を要求されます。それぞれ、3Baselと入力し、Execute Toolを実行します。


locationがBaselのホテルが3つリストされます。


Oracle Corporationからは、ツール開発部門より3種類のMCPサーバーが提供されています。

Oracle MCP Servers

また、それとは別にAutonomous AI Database向けのMCPサーバーが提供されています。

Autonomous AI Database MCP Server
https://www.oracle.com/autonomous-database/mcp-server/

ユースケースによっては、オープンソースのMCPサーバーも検討する価値はあるでしょう。例えば、オンプレミスのOracle Database向けのMCPサーバーはSQLclかORDSで実装することになりますが、現状では両方ともカスタム・ツールの実装をサポートしていません。また、Oracle Databaseの他にもデータ・ソースがあり、それらを同様にOIDC認証したい場合など、認証はMCP Toolboxが行うためデータ・ソースごとの設定は不要になります。確認していませんが、OIDC認証で受け取るIDトークンのsubの値をSQLの引数として渡すこともできるようなので、データの検索範囲も認証されたユーザーに応じて制限できそうです。