Skip to main content
Glama
ahmedselimmansor-ctrl

IBM Cloud MCP Server

iam_create_policy

Create an IAM access or authorization policy by specifying subjects, roles, and resources as JSON.

Instructions

Create a new IAM access policy

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYesPolicy type
subjectsYesJSON string of policy subjects array
rolesYesJSON string of roles array (e.g., [{role_id: 'crn:v1:bluemix:public:iam::::role:Viewer'}])
resourcesYesJSON string of resources array

Implementation Reference

  • Registration of iam_create_policy tool via server.tool() with name, description, Zod schema, and handler function.
    // ─── iam_create_policy ────────────────────────────────────────
    server.tool(
      "iam_create_policy",
      "Create a new IAM access policy",
      {
        type: z.enum(["access", "authorization"]).describe("Policy type"),
        subjects: z.string().describe("JSON string of policy subjects array"),
        roles: z.string().describe("JSON string of roles array (e.g., [{role_id: 'crn:v1:bluemix:public:iam::::role:Viewer'}])"),
        resources: z.string().describe("JSON string of resources array"),
      },
      async ({ type, subjects, roles, resources }) => safeTool(async () => {
        assertWriteAllowed(config.allowWrite);
        return client.post(`${IBM_ENDPOINTS.IAM_POLICY}/policies`, {
          type,
          subjects: JSON.parse(subjects),
          roles: JSON.parse(roles),
          resources: JSON.parse(resources),
        });
      })
    );
  • Zod schema defining input parameters: type (enum 'access'|'authorization'), subjects (JSON string), roles (JSON string), resources (JSON string).
    {
      type: z.enum(["access", "authorization"]).describe("Policy type"),
      subjects: z.string().describe("JSON string of policy subjects array"),
      roles: z.string().describe("JSON string of roles array (e.g., [{role_id: 'crn:v1:bluemix:public:iam::::role:Viewer'}])"),
      resources: z.string().describe("JSON string of resources array"),
    },
  • Handler function that asserts write access, then POSTs parsed JSON data to IBM IAM Policy API endpoint.
    async ({ type, subjects, roles, resources }) => safeTool(async () => {
      assertWriteAllowed(config.allowWrite);
      return client.post(`${IBM_ENDPOINTS.IAM_POLICY}/policies`, {
        type,
        subjects: JSON.parse(subjects),
        roles: JSON.parse(roles),
        resources: JSON.parse(resources),
      });
    })
  • assertWriteAllowed helper — throws WriteNotAllowedError if write operations are disabled.
    export function assertWriteAllowed(allowWrite: boolean): void {
      if (!allowWrite) {
        throw new WriteNotAllowedError();
      }
    }
  • IBM_ENDPOINTS.IAM_POLICY constant defining the base URL (https://iam.cloud.ibm.com/v1) used by the handler for POST request.
    export const IBM_ENDPOINTS = {
      IAM: "https://iam.cloud.ibm.com",
      IAM_IDENTITY: "https://iam.cloud.ibm.com/v1",
      IAM_ACCESS_GROUPS: "https://iam.cloud.ibm.com/v2",
      IAM_POLICY: "https://iam.cloud.ibm.com/v1",
Behavior2/5

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

No annotations provided; the description only states 'Create' but does not disclose idempotency, side effects, or authorization requirements. The mutation behavior is implied but not elaborated.

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?

A single, clear sentence that front-loads the purpose with no extraneous words.

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?

The tool requires complex JSON-encoded parameters (subjects, roles, resources) but the description does not explain how to construct them or provide constraints. No output schema is provided, leaving the agent uncertain about the response format.

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

Parameters3/5

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

Schema description coverage is 100% (each parameter has a description). The tool description adds no extra meaning beyond what the schema already provides, so baseline score of 3 applies.

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

Purpose5/5

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

The description specifies a clear action ('Create') and resource ('new IAM access policy'), distinguishing it from other IAM tools like iam_create_access_group or iam_create_api_key.

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?

No guidance on when to use this tool versus alternatives (e.g., when to create an access policy vs. an authorization policy). No prerequisites or conditions are mentioned.

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/ahmedselimmansor-ctrl/IBM_cloud_MCP_SERVER'

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