Skip to main content
Glama

get_current_oci_profile

Identify the active Oracle Cloud Infrastructure profile for API calls to manage resources across tenancies.

Instructions

Get the currently active OCI profile.

Returns information about which profile is currently being used for API calls.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for the 'get_current_oci_profile' MCP tool. Returns details of the currently active OCI profile (stored in global current_profile) using the get_profile_info helper, or indicates no active profile.
    @mcp.tool(name="get_current_oci_profile") async def get_current_profile_tool(ctx: Context) -> Dict[str, Any]: """ Get the currently active OCI profile. Returns information about which profile is currently being used for API calls. """ try: if current_profile is None: await ctx.info("No profile currently active") return { "active": False, "message": "No profile selected. Use list_oci_profiles to see available profiles, then set_oci_profile to activate one." } profile_info = get_profile_info(current_profile) await ctx.info(f"Current active profile: {current_profile}") return { "active": True, "current_profile": current_profile, "profile_details": profile_info } except Exception as e: error_msg = f"Error getting current profile: {str(e)}" await ctx.error(error_msg) logger.exception("Error getting current profile") return { "error": error_msg }
  • Helper function get_profile_info that retrieves detailed config information (user, tenancy, region, fingerprint) for a given OCI profile name by parsing the ~/.oci/config file via list_available_profiles.
    def get_profile_info(profile_name: str) -> Optional[Dict[str, str]]: """ Get detailed information about a specific profile. Args: profile_name: Name of the profile Returns: Dictionary with profile information, or None if not found """ try: profiles = list_available_profiles() for profile in profiles: if profile["name"] == profile_name: return profile return None except Exception as e: logger.error(f"Error getting profile info: {e}") return None
  • Supporting helper list_available_profiles that parses the OCI config file (~/.oci/config) and extracts all available profiles with their key details (user OCID, tenancy OCID, region, key fingerprint). Called by get_profile_info.
    def list_available_profiles() -> List[Dict[str, str]]: """ List all available profiles from the OCI config file. Returns: List of dictionaries containing profile information: [ { "name": "DEFAULT", "user": "ocid1.user...", "tenancy": "ocid1.tenancy...", "region": "us-ashburn-1", "fingerprint": "aa:bb:cc:..." }, ... ] Raises: FileNotFoundError: If OCI config file doesn't exist Exception: If config file cannot be parsed """ config_path = get_oci_config_path() if not os.path.exists(config_path): raise FileNotFoundError( f"OCI config file not found at {config_path}. " f"Please create it or set OCI_CONFIG_FILE environment variable." ) try: config = configparser.ConfigParser() config.read(config_path) profiles = [] for section in config.sections(): profile_info = { "name": section, "user": config.get(section, "user", fallback="N/A"), "tenancy": config.get(section, "tenancy", fallback="N/A"), "region": config.get(section, "region", fallback="N/A"), "fingerprint": config.get(section, "fingerprint", fallback="N/A"), } profiles.append(profile_info) logger.info(f"Found {len(profiles)} profiles in {config_path}") return profiles except Exception as e: logger.exception(f"Error parsing OCI config file: {e}") raise Exception(f"Failed to parse OCI config file at {config_path}: {str(e)}")
  • MCP tool registration decorator specifying the tool name 'get_current_oci_profile'.
    @mcp.tool(name="get_current_oci_profile")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jopsis/mcp-server-oci'

If you have feedback or need assistance with the MCP directory API, please join our Discord server