get_user
Retrieve detailed IAM user information including capabilities, MFA status, and group memberships from Oracle Cloud Infrastructure using the user's OCID.
Instructions
Get detailed information about a specific IAM user.
Args:
user_id: OCID of the user to retrieve
Returns:
Detailed user information including capabilities, MFA status, and group memberships
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes |
Implementation Reference
- mcp_server_oci/mcp_server.py:1074-1090 (handler)The main handler function for the 'get_user' MCP tool, including registration decorator @mcp.tool(name='get_user') and wrapper decorator. It takes user_id and calls the helper get_user with the identity client.@mcp.tool(name="get_user") @mcp_tool_wrapper( start_msg="Getting user details for {user_id}...", success_msg="Retrieved user details successfully", error_prefix="Error getting user details" ) async def mcp_get_user(ctx: Context, user_id: str) -> Dict[str, Any]: """ Get detailed information about a specific IAM user. Args: user_id: OCID of the user to retrieve Returns: Detailed user information including capabilities, MFA status, and group memberships """ return get_user(oci_clients["identity"], user_id)
- mcp_server_oci/mcp_server.py:1074-1074 (registration)MCP tool registration using @mcp.tool decorator with name 'get_user'.@mcp.tool(name="get_user")
- Helper function that implements the core logic for retrieving OCI user details using the OCI SDK, called by the MCP handler.def get_user(identity_client: oci.identity.IdentityClient, user_id: str) -> Dict[str, Any]: """ Get details of a specific user. Args: identity_client: OCI Identity client user_id: OCID of the user Returns: Details of the user """ try: user = identity_client.get_user(user_id).data user_details = { "id": user.id, "name": user.name, "description": user.description, "email": user.email, "email_verified": user.email_verified, "is_mfa_activated": user.is_mfa_activated, "lifecycle_state": user.lifecycle_state, "time_created": str(user.time_created), "compartment_id": user.compartment_id, "capabilities": { "can_use_console_password": user.capabilities.can_use_console_password if user.capabilities else None, "can_use_api_keys": user.capabilities.can_use_api_keys if user.capabilities else None, "can_use_auth_tokens": user.capabilities.can_use_auth_tokens if user.capabilities else None, "can_use_smtp_credentials": user.capabilities.can_use_smtp_credentials if user.capabilities else None, } if user.capabilities else None, } logger.info(f"Retrieved details for user {user_id}") return user_details except Exception as e: logger.exception(f"Error getting user details: {e}") raise