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")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool returns information about the active profile, implying a read-only operation, but doesn't clarify aspects like authentication requirements, potential errors (e.g., if no profile is set), rate limits, or the format of the returned information. For a tool with zero annotation coverage, this is insufficient to ensure safe and effective use.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise and front-loaded: the first sentence directly states the tool's purpose, and the second sentence elaborates on the return value. There is no wasted language or redundancy, making it easy for an agent to parse quickly and accurately.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no output schema and no annotations, the description is incomplete. It mentions what the tool returns but doesn't specify the structure or content of the returned information (e.g., profile name, configuration details). For a tool that provides configuration data, this lack of output detail leaves significant gaps in understanding how to interpret results.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and the schema description coverage is 100% (though trivial since there are no parameters). The description doesn't need to add parameter semantics, as there are none to document. A baseline of 4 is appropriate because the description doesn't introduce any confusion about parameters, and the schema fully covers the absence of inputs.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get the currently active OCI profile' and 'Returns information about which profile is currently being used for API calls.' This specifies the verb ('Get') and resource ('currently active OCI profile'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'list_oci_profiles' or 'set_oci_profile', which would be needed for a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'list_oci_profiles' (which might list all profiles) or 'set_oci_profile' (which might change the active profile), nor does it specify any prerequisites or contexts for usage. This leaves the agent without clear direction on appropriate use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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