Skip to main content
Glama

get_policy

Retrieve detailed IAM policy information including all statements by providing the policy OCID to manage Oracle Cloud Infrastructure access controls.

Instructions

Get detailed information about a specific IAM policy.

Args:
    policy_id: OCID of the policy to retrieve

Returns:
    Detailed policy information including all policy statements

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
policy_idYes

Implementation Reference

  • MCP tool handler for the 'get_policy' tool. Wraps the helper function with error handling and logging, calls OCI Identity client via the imported helper.
    @mcp.tool(name="get_policy")
    @mcp_tool_wrapper(
        start_msg="Getting policy details for {policy_id}...",
        success_msg="Retrieved policy details successfully",
        error_prefix="Error getting policy details"
    )
    async def mcp_get_policy(ctx: Context, policy_id: str) -> Dict[str, Any]:
        """
        Get detailed information about a specific IAM policy.
    
        Args:
            policy_id: OCID of the policy to retrieve
    
        Returns:
            Detailed policy information including all policy statements
        """
        return get_policy(oci_clients["identity"], policy_id)
  • Core helper function that executes the OCI Identity API call to retrieve policy details and formats the response dictionary.
    def get_policy(identity_client: oci.identity.IdentityClient, policy_id: str) -> Dict[str, Any]:
        """
        Get details of a specific policy.
        
        Args:
            identity_client: OCI Identity client
            policy_id: OCID of the policy
            
        Returns:
            Details of the policy
        """
        try:
            policy = identity_client.get_policy(policy_id).data
            
            policy_details = {
                "id": policy.id,
                "name": policy.name,
                "description": policy.description,
                "statements": policy.statements,
                "version_date": str(policy.version_date) if policy.version_date else None,
                "lifecycle_state": policy.lifecycle_state,
                "time_created": str(policy.time_created),
                "compartment_id": policy.compartment_id,
            }
            
            logger.info(f"Retrieved details for policy {policy_id}")
            return policy_details
            
        except Exception as e:
            logger.exception(f"Error getting policy details: {e}")
            raise
  • Import statement registering the get_policy helper function from identity.py for use in the MCP tool handlers.
    from mcp_server_oci.tools.identity import (
        list_users,
        get_user,
        list_groups,
        get_group,
        list_policies,
        get_policy,
        list_dynamic_groups,
        get_dynamic_group,
    )
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 retrieves detailed information, implying a read-only operation, but doesn't specify authentication requirements, rate limits, error conditions, or what 'detailed information' entails beyond policy statements. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 appropriately sized and front-loaded: the first sentence states the purpose clearly, followed by structured 'Args' and 'Returns' sections. Every sentence earns its place by providing essential information without redundancy, making it efficient and easy to parse.

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

Completeness3/5

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

Given the tool's low complexity (one parameter, no nested objects) and lack of annotations or output schema, the description is minimally adequate. It covers the basic purpose and parameter semantics but lacks details on usage guidelines, behavioral traits, and return value specifics. For a simple read operation, this is acceptable but not comprehensive.

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 description adds meaningful context for the single parameter: 'policy_id: OCID of the policy to retrieve.' Since schema description coverage is 0% (the schema only provides a title 'Policy Id' without explanation), this compensates well by specifying the format (OCID) and purpose. With only one parameter, the baseline is high, and the description effectively clarifies its semantics beyond the minimal schema.

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 detailed information about a specific IAM policy.' It uses a specific verb ('Get') and resource ('IAM policy'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'list_policies' or other 'get_' tools, which would require a 5.

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_policies' for browsing policies or other 'get_' tools for different resources, nor does it specify prerequisites or contexts for usage. This lack of comparative guidance limits its effectiveness.

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