この他に参照した資料は以下です。
Azure AD (Entra ID) Tokens: 1. Entra ID App Registrations
Vijay Balebailさんの以下の記事:
Autonomous AI Databaseの作成
sql -home $TNS_ADMIN admin@salesadb_low
~ % export TNS_ADMIN=~/Documents/mcp-salesadb-entraid
~ % sql -home $TNS_ADMIN admin@salesadb_low
SQLcl: 火 2月 10 14:46:06 2026のリリース25.4 Production
Copyright (c) 1982, 2026, Oracle. All rights reserved.
パスワード (**********?) ****************
Last Successful login time: 火 2月 10 2026 14:46:18 +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から切断されました
~ %
Microsoft Entra IDの設定
"requestedAccessTokenVersion": 2,
Oracle Databaseの構成
begin
dbms_cloud_admin.enable_external_authentication(
type => 'AZURE_AD',
params => json_object(
'tenant_id' value 'ディレクトリ(テナント)ID',
'application_id' value 'アプリケーション(クライアント)ID',
'application_id_uri' value 'アプリケーションIDのURL'
),
force => true
);
end;
/
~ % sql -home $TNS_ADMIN admin@salesadb_low
SQLcl: 火 2月 10 15:04:59 2026のリリース25.4 Production
Copyright (c) 1982, 2026, Oracle. All rights reserved.
パスワード (**********?) ****************
Last Successful login time: 火 2月 10 2026 15:05:10 +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
2 dbms_cloud_admin.enable_external_authentication(
3 type => 'AZURE_AD',
4 params => json_object(
5 'tenant_id' value '3940****-****-****-****-********2758',
6 'application_id' value '70ec****-****-****-****-********2b4a',
7 'application_id_uri' value 'api://70ec****-****-****-****-********2b4a'
8 ),
9 force => true
10 );
11 end;
12* /
PL/SQLプロシージャが正常に完了しました。
SQL>
SQL> select name, value from v$parameter where name = 'identity_provider_type';
NAME VALUE
_________________________ ___________
identity_provider_type AZURE_AD
SQL>
alter user mcpuser quota 25m on data;
grant create session to mcpuser;
SQL> create user mcpuser identified globally as 'AZURE_ROLE=MCPUSER_ROLE';
User MCPUSERは作成されました。
SQL> alter user mcpuser quota 25m on data ;
User MCPUSERが変更されました。
QL> grant create table, create view, create sequence, create synonym to mcpuser;
Grantが正常に実行されました。
SQL> grant create session to mcpuser;
Grantが正常に実行されました。
SQL>
https://login.windows.net/common/discovery/keys
begin
dbms_network_acl_admin.append_host_ace(
host => '*',
ace => xs$ace_type(
privilege_list => xs$name_list('connect'),
principal_name => 'MCPUSER',
principal_type => xs_acl.ptype_db
)
);
end;
/
SQL> begin
2 dbms_network_acl_admin.append_host_ace(
3 host => '*',
4 ace => xs$ace_type(
5 privilege_list => xs$name_list('connect'),
6 principal_name => 'MCPUSER',
7 principal_type => xs_acl.ptype_db
8 )
9 );
10 end;
11* /
PL/SQLプロシージャが正常に完了しました。
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から切断されました
~ %
接続情報の更新
(TOKEN_AUTH=OAUTH)(TOKEN_LOCATION=/Users/[ユーザー名]/Documents/mcp-salesadb-entraid/token.txt)
salesadb_token = (
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=OAUTH)
(TOKEN_LOCATION=/Users/___________/Documents/mcp-salesadb-entraid/token.txt))
)
~ % az login --tenant "3940****-****-****-****-********2758" --scope "api://70ec****-****-****-****-********2b4a/session:scope:connect"
A web browser has been opened at https://login.microsoftonline.com/3940****-****-****-****-********2758/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
~ % az login --tenant "3940****-****-****-****-********2758" --scope "api://70ec****-****-****-****-********2b4a/session:scope:connect"
A web browser has been opened at https://login.microsoftonline.com/3940****-****-****-****-********2758/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
Retrieving subscriptions for the selection...
[Tenant and subscription selection]
No Subscription name Subscription ID Tenant
----- -------------------- ------------------------------------ ------------------------------------
[1] * Azure subscription 1 7ada****-****-****-****-********7b71 3940****-****-****-****-********2758
The default is marked with an *; the default tenant is '3940****-****-****-****-********2758' and subscription is 'Azure subscription 1' (7ada****-****-****-****-********7b71).
Select a subscription and tenant (Type a number or Enter for no changes):
Tenant: 3940****-****-****-****-********2758
Subscription: Azure subscription 1 (7ada****-****-****-****-********7b71)
[Announcements]
With the new Azure CLI login experience, you can select the subscription you want to use more easily. Learn more about it and its configuration at https://go.microsoft.com/fwlink/?linkid=2271236
If you encounter any problem, please open an issue at https://aka.ms/azclibug
[Warning] The login output has been updated. Please be aware that it no longer displays the full list of available subscriptions by default.
~ %
az account get-access-token --scope "api://アプリケーションID URL/session:scope:connect" --query accessToken -o tsv > ~/Documents/mcp-salesadb-entraid/token.txt
~ % az account get-access-token --scope "api://70ec****-****-****-****-********2b4a/session:scope:connect" --query accessToken -o tsv > ~/Documents/mcp-salesadb-entraid/token.txt
~ %
connect -save salesadb -savepwd /@salesadb_token
~ % export TNS_ADMIN=~/Documents/mcp-salesadb-entraid
~ % sql -home $TNS_ADMIN /nolog
SQLcl: 木 2月 12 11:10:08 2026のリリース25.4 Production
Copyright (c) 1982, 2026, Oracle. All rights reserved.
SQL> connect -save salesadb -savepwd /@salesadb_token
名前: salesadb
接続文字列: salesadb_token
ユーザー:
パスワード: 未保存
接続しました.
SQL>
select
sys_context('userenv','session_user') as session_user,
sys_context('userenv','current_user') as current_user,
sys_context('userenv','authenticated_identity') as azure_user
from dual;
SQL> select
2 sys_context('userenv','session_user') as session_user,
3 sys_context('userenv','current_user') as current_user,
4 sys_context('userenv','authenticated_identity') as azure_user
5* from dual;
SESSION_USER CURRENT_USER AZURE_USER
_______________ _______________ _____________________________________________________________
MCPUSER MCPUSER yuji.n****_outlook.com_EXT_@*******soutlook.onmicrosoft.com
SQL>
データベース・ユーザーMCPUSERとして接続されています。Entra IDで認証されたユーザーは、システム・コンテキストのUSERENVにAUTHENTICATED_IDENTITYとして設定されています。
{
"mcpServers": {
"sqlcl": {
"command": "/Users/[ユーザー名]/sqlcl/bin/sql",
"args": [
"-home",
"/Users/[ユーザー名]/Documents/mcp-salesadb-entraid",
"-R",
"0",
"-mcp"
],
"env": {
"TNS_ADMIN": "/Users/[ユーザー名]/Documents/mcp-salesadb-entraid"
}
}
},
"preferences": {
"coworkScheduledTasksEnabled": false,
"sidebarMode": "chat"
}
}













































