Skip to content

Commit b20410d

Browse files
committed
add user and token tools to identity server (oracle#23)
Signed-off-by: Richard Gebhardt <[email protected]>
1 parent a00e8b2 commit b20410d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

oci_identity.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,29 @@ def get_current_tenancy():
6060
"home_region_key": tenancy.home_region_key,
6161
}
6262

63+
@mcp.tool
64+
def create_auth_token(user_id: str):
65+
identity = get_identity_client()
66+
token = identity.create_auth_token(user_id=user_id).data
67+
return {
68+
"token": token.token,
69+
"description": token.description,
70+
"lifecycle_state": token.lifecycle_state,
71+
}
72+
73+
@mcp.tool
74+
def get_current_user():
75+
identity = get_identity_client()
76+
config = oci.config.from_file(
77+
profile_name=os.getenv("OCI_CONFIG_PROFILE", oci.config.DEFAULT_PROFILE)
78+
)
79+
user_id = config["user"]
80+
user = identity.get_user(user_id).data
81+
return {
82+
"id": user.id,
83+
"name": user.name,
84+
"description": user.description,
85+
}
6386

6487
if __name__ == "__main__":
6588
mcp.run()

0 commit comments

Comments
 (0)