Using Oracle Autonomous AI Database Serverless
Autonomous AI DatabaseとしてSALESADBを作成するところまでは、以下のEntra IDでの手順と同じです。
SQLclのMCPサーバーのデータベース接続をMicrosoft Entra IDのOAuth2で認証する
~ % mkdir -p ~/Documents/mcp-salesadb-oci
~ % export TNS_ADMIN=~/Documents/mcp-salesadb-oci
~ % unzip -d $TNS_ADMIN ~/Downloads/Wallet_SALESADB.zip
Archive: /Users/________/Downloads/Wallet_SALESADB.zip
inflating: /Users/________/Documents/mcp-salesadb-oci/ewallet.pem
inflating: /Users/________/Documents/mcp-salesadb-oci/README
inflating: /Users/________/Documents/mcp-salesadb-oci/cwallet.sso
inflating: /Users/________/Documents/mcp-salesadb-oci/tnsnames.ora
inflating: /Users/________/Documents/mcp-salesadb-oci/truststore.jks
inflating: /Users/________/Documents/mcp-salesadb-oci/ojdbc.properties
inflating: /Users/________/Documents/mcp-salesadb-oci/sqlnet.ora
inflating: /Users/________/Documents/mcp-salesadb-oci/ewallet.p12
inflating: /Users/________/Documents/mcp-salesadb-oci/keystore.jks
~ % sql admin@salesadb_low
SQLcl: 金 2月 13 10:42:02 2026のリリース25.4 Production
Copyright (c) 1982, 2026, Oracle. All rights reserved.
パスワード (**********?) ****************
Last Successful login time: 金 2月 13 2026 10:42:08 +09:00
接続先:
Oracle AI Database 26ai Enterprise Edition Release 23.26.1.1.0 - for Oracle Cloud and Engineered Systems
Version 23.26.1.1.0
SQL> exit
Oracle AI Database 26ai Enterprise Edition Release 23.26.1.1.0 - for Oracle Cloud and Engineered Systems
Version 23.26.1.1.0から切断されました
~ %
OCI IAMの設定
Oracle Databaseの構成
~ % export TNS_ADMIN=~/Documents/mcp-salesadb-oci
~ % sql admin@salesadb_low
SQLcl: 金 2月 13 11:10:00 2026のリリース25.4 Production
Copyright (c) 1982, 2026, Oracle. All rights reserved.
パスワード (**********?) ****************
Last Successful login time: 金 2月 13 2026 11:10:07 +09:00
接続先:
Oracle AI Database 26ai Enterprise Edition Release 23.26.1.1.0 - for Oracle Cloud and Engineered Systems
Version 23.26.1.1.0
SQL>
BEGIN
DBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATION(
type => 'OCI_IAM',
force => TRUE );
END;
/
SQL> BEGIN
2 DBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATION(
3 type => 'OCI_IAM',
4 force => TRUE );
5 END;
6* /
PL/SQLプロシージャが正常に完了しました。
SQL>
SELECT NAME, VALUE FROM V$PARAMETER WHERE NAME='identity_provider_type';
SQL> SELECT NAME, VALUE FROM V$PARAMETER WHERE NAME='identity_provider_type';
NAME VALUE
_________________________ __________
identity_provider_type OCI_IAM
SQL>
alter user mcpuser quota 25m on data;
grant create table, create view, create sequence to mcpuser;
SQL> create user mcpuser identified globally as 'IAM_GROUP_NAME=sales_dbusers';
User MCPUSERは作成されました。
SQL> alter user mcpuser quota 25m on data;
User MCPUSERが変更されました。
SQL> grant create session to mcpuser;
Grantが正常に実行されました。
SQL> grant create table, create view, create sequence to mcpuser;
Grantが正常に実行されました。
SQL> exit
Oracle AI Database 26ai Enterprise Edition Release 23.26.1.1.0 - for Oracle Cloud and Engineered Systems
Version 23.26.1.1.0から切断されました
~ %
クライアントの構成
~ % brew install oci-cli
✔︎ JSON API formula.jws.json Downloaded 32.0MB/ 32.0MB
✔︎ JSON API cask.jws.json Downloaded 15.3MB/ 15.3MB
Warning: oci-cli 3.74.0 is already installed and up-to-date.
To reinstall 3.74.0, run:
brew reinstall oci-cli
~ %
oci iam db-token get
~/.oci/configが存在しない場合、新たに作成するかどうか聞かれます。デフォルトのYで継続します。
~ % oci iam db-token get
ERROR: Could not find config file at /Users/___________/.oci/config
Do you want to create a new config file? [Y/n]:
Do you want to create your config file by logging in through a browser? [Y/n]:
Enter a region by index or name(e.g.
1: af-johannesburg-1, 2: ap-batam-1, 3: ap-chiyoda-1, 4: ap-chuncheon-1, 5: ap-chuncheon-2,
6: ap-dcc-canberra-1, 7: ap-dcc-gazipur-1, 8: ap-delhi-1, 9: ap-hyderabad-1, 10: ap-ibaraki-1,
11: ap-kulai-2, 12: ap-melbourne-1, 13: ap-mumbai-1, 14: ap-osaka-1, 15: ap-seoul-1,
16: ap-seoul-2, 17: ap-singapore-1, 18: ap-singapore-2, 19: ap-suwon-1, 20: ap-sydney-1,
21: ap-tokyo-1, 22: ca-montreal-1, 23: ca-toronto-1, 24: eu-amsterdam-1, 25: eu-budapest-1,
26: eu-crissier-1, 27: eu-dcc-dublin-1, 28: eu-dcc-dublin-2, 29: eu-dcc-milan-1, 30: eu-dcc-milan-2,
31: eu-dcc-rating-1, 32: eu-dcc-rating-2, 33: eu-dcc-zurich-1, 34: eu-frankfurt-1, 35: eu-frankfurt-2,
36: eu-jovanovac-1, 37: eu-madrid-1, 38: eu-madrid-2, 39: eu-madrid-3, 40: eu-marseille-1,
41: eu-milan-1, 42: eu-paris-1, 43: eu-stockholm-1, 44: eu-turin-1, 45: eu-zurich-1,
46: il-jerusalem-1, 47: me-abudhabi-1, 48: me-abudhabi-2, 49: me-abudhabi-3, 50: me-abudhabi-4,
51: me-alain-1, 52: me-dcc-doha-1, 53: me-dcc-muscat-1, 54: me-dubai-1, 55: me-ibri-1,
56: me-jeddah-1, 57: me-riyadh-1, 58: mx-monterrey-1, 59: mx-queretaro-1, 60: sa-bogota-1,
61: sa-riodejaneiro-1, 62: sa-santiago-1, 63: sa-saopaulo-1, 64: sa-valparaiso-1, 65: sa-vinhedo-1,
66: uk-cardiff-1, 67: uk-gov-cardiff-1, 68: uk-gov-london-1, 69: uk-london-1, 70: us-ashburn-1,
71: us-ashburn-2, 72: us-chicago-1, 73: us-gov-ashburn-1, 74: us-gov-chicago-1, 75: us-gov-phoenix-1,
76: us-langley-1, 77: us-luke-1, 78: us-newark-1, 79: us-phoenix-1, 80: us-saltlake-2,
81: us-sanjose-1, 82: us-somerset-1, 83: us-thames-1): us-ashburn-1
Please switch to newly opened browser window to log in!
You can also open the following URL in a web browser window to continue:
https://login.us-ashburn-1.oraclecloud.com/v1/oauth2/authorize?action=login&client_id=iaas_console&response_type=token+id_token&nonce=5879cd05-d36b-4a99-99c4-a28e5c539faf&scope=openid&public_key=ey*******************************************************************************************************************************************AiSWdub3JlZCJ9&redirect_uri=http%3A%2F%2Flocalhost%3A8181
Completed browser authentication process!
Uploaded new API key with fingerprint: c8:be:62:52:d2:74:89:6c:0f:39:82:aa:f2:68:60:c4
Enter a passphrase for your private key ("N/A" for no passphrase): N/A
Repeat for confirmation: N/A
Config written to: /Users/_________/.oci/config
Try out your newly registered credentials with the following example command:
oci iam region list --config-file /Users/_________/.oci/config --profile DEFAULT
Successfully created config file with your new CLI user profile
Once your public key is uploaded in the console, you can re-run your command to use your new config file and user profile
~ %
salesadb_oci = (
description= (retry_count=20)(retry_delay=3)
(address=(protocol=tcps)(port=1522)(host=adb.us-ashburn-1.oraclecloud.com))
(connect_data=(service_name=**************_salesadb_low.adb.oraclecloud.com))
(security=(ssl_server_dn_match=yes)(TOKEN_AUTH=OCI_TOKEN))
)
export TNS_ADMIN=~/Documents/mcp-salesadb-oci
connect -save salesadb_oci -savepwd /@salesadb_oci
~ % export TNS_ADMIN=~/Documents/mcp-salesadb-oci
~ % sql -home $TNS_ADMIN /nolog
SQLcl: 金 2月 13 12:17:48 2026のリリース25.4 Production
Copyright (c) 1982, 2026, Oracle. All rights reserved.
SQL> connect -save salesadb_oci -savepwd /@salesadb_oci
名前: salesadb_oci
接続文字列: salesadb_oci
ユーザー:
パスワード: 未保存
接続しました.
SQL>
select sys_context('userenv','authentication_method');
値はTOKEN_GLOBALになっています。
SQL> select sys_context('userenv','authentication_method');
SYS_CONTEXT('USERENV','AUTHENTICATION_METHOD')
_________________________________________________
TOKEN_GLOBAL
SQL>
AUTHENTICATED_IDENTITYの値を確認します。
select sys_context('userenv','authenticated_identity');
SQL> select sys_context('userenv','authenticated_identity');
SYS_CONTEXT('USERENV','AUTHENTICATED_IDENTITY')
__________________________________________________
yuji***********************.jp
SQL>
select sys_context('userenv','session_user'), sys_context('userenv','current_user');
SQL> select sys_context('userenv','session_user'), sys_context('userenv','current_user');
SYS_CONTEXT('USERENV','SESSION_USER') SYS_CONTEXT('USERENV','CURRENT_USER')
________________________________________ ________________________________________
MCPUSER MCPUSER
SQL>
以上でクライアントの構成は完了です。
Claude Desktopでの確認
{
"mcpServers": {
"sqlcl": {
"command": "/Users/[ユーザー名]/sqlcl/bin/sql",
"args": [
"-home",
"/Users/[ユーザー名]/Documents/mcp-salesadb-oci",
"-R",
"0",
"-mcp"
],
"env": {
"TNS_ADMIN": "/Users/[ユーザー名]/Documents/mcp-salesadb-oci"
}
}
},
"preferences": {
"coworkScheduledTasksEnabled": false,
"sidebarMode": "chat"
}
}
追記:TOKEN_AUTH=OCI_INTERACTIVEの設定について
oci-iam % sql /@salesadb_int
SQLcl: 火 8月 26 11:40:53 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
接続に失敗しました
USER =
URL = jdbc:oracle:thin:@salesadb_int
エラー・メッセージ = ORA-18726: OracleResourceProviderからの値の取得に失敗しました: No implementation of oracle.jdbc.spi.AccessTokenProvider with name: "ojdbc-provider-oci-token" can be located. Implementations of oracle.jdbc.spi.AccessTokenProvider that can be located have the following names : []
https://docs.oracle.com/error-help/db/ora-18726/
oci-iam %
oci-iam % sql /nolog
SQLcl: 火 8月 26 11:43:02 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
SQL> sdk list
+------------+-----------+---------+----------------------------------------------------------------------+
| SDK | INSTALLED | VERSION | ドキュメント |
+------------+-----------+---------+----------------------------------------------------------------------+
| jdbc-oci | いいえ | 1.0.6 | https://docs.oracle.com/en/database/oracle/oracle-database/23/jjdbc/ |
| jdbc-azure | いいえ | 1.0.6 | https://docs.oracle.com/en/database/oracle/oracle-database/23/jjdbc/ |
+------------+-----------+---------+----------------------------------------------------------------------+
SQL> sdk install jdbc-oci
ojdbc-provider-oci SDKおよびその依存性をダウンロードしています。
jdbc-oci SDKは正常にインストールされました。SQLclを再起動して変更を反映してください
SQL> sdk list
+------------+-----------+---------+----------------------------------------------------------------------+
| SDK | INSTALLED | VERSION | ドキュメント |
+------------+-----------+---------+----------------------------------------------------------------------+
| jdbc-oci | はい | 1.0.6 | https://docs.oracle.com/en/database/oracle/oracle-database/23/jjdbc/ |
| jdbc-azure | いいえ | 1.0.6 | https://docs.oracle.com/en/database/oracle/oracle-database/23/jjdbc/ |
+------------+-----------+---------+----------------------------------------------------------------------+
SQL> exit
oci-iam %
oci-iam % sql /@salesadb_int
SQLcl: 火 8月 26 11:45:00 2025のリリース25.2 Production
Copyright (c) 1982, 2025, Oracle. All rights reserved.
接続に失敗しました
USER =
URL = jdbc:oracle:thin:@salesadb_int
エラー・メッセージ = ORA-18726: OracleResourceProviderからの値の取得に失敗しました
https://docs.oracle.com/error-help/db/ora-18726/
oci-iam %








