Skip to main content
Glama
krzko

Google Cloud MCP Server

by krzko

Test Project IAM Permissions

gcp-iam-test-project-permissions

Test which permissions your Google Cloud account has on a project to verify access before making API calls or deploying resources.

Instructions

Test which permissions the current caller has on a Google Cloud project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectNoProject ID (defaults to current project)
permissionsYesList of permissions to test (e.g., ["resourcemanager.projects.get", "compute.instances.list"])

Implementation Reference

  • The handler function that implements the tool logic. It tests the specified IAM permissions on the given or current GCP project using the Resource Manager client and returns a formatted markdown response with granted and denied permissions.
    async ({ project, permissions }) => {
      try {
        const projectId = project || (await getProjectId());
        const resourceManager = getResourceManagerClient();
    
        const [response] = await resourceManager.testIamPermissions({
          resource: `projects/${projectId}`,
          permissions,
        });
    
        const grantedPermissions = response.permissions || [];
        const deniedPermissions = permissions.filter(
          (p) => !grantedPermissions.includes(p),
        );
    
        let result = `# Project IAM Permissions Test\n\nProject: ${projectId}\n\n`;
    
        result += `## ✅ Granted Permissions (${grantedPermissions.length})\n\n`;
        if (grantedPermissions.length > 0) {
          grantedPermissions.forEach((permission) => {
            result += `- ${permission}\n`;
          });
        } else {
          result += `*No permissions granted*\n`;
        }
    
        result += `\n## ❌ Denied Permissions (${deniedPermissions.length})\n\n`;
        if (deniedPermissions.length > 0) {
          deniedPermissions.forEach((permission) => {
            result += `- ${permission}\n`;
          });
        } else {
          result += `*All permissions granted*\n`;
        }
    
        result += `\n**Summary:** ${grantedPermissions.length}/${permissions.length} permissions granted on project ${projectId}\n`;
    
        return {
          content: [
            {
              type: "text",
              text: result,
            },
          ],
        };
      } catch (error: unknown) {
        const errorMessage =
          error instanceof Error ? error.message : "Unknown error";
        logger.error(`Error testing project IAM permissions: ${errorMessage}`);
    
        return {
          content: [
            {
              type: "text",
              text: `# Error Testing Project IAM Permissions\n\nFailed to test IAM permissions on project "${project || "current"}": ${errorMessage}\n\nPlease ensure the project ID is correct and accessible.`,
            },
          ],
          isError: true,
        };
      }
    },
  • Zod input schema defining the parameters for the tool: optional project ID and array of permissions to test.
    inputSchema: {
      project: z
        .string()
        .optional()
        .describe("Project ID (defaults to current project)"),
      permissions: z
        .array(z.string())
        .describe(
          'List of permissions to test (e.g., ["resourcemanager.projects.get", "compute.instances.list"])',
        ),
    },
  • The registration of the tool with the MCP server using server.registerTool.
    "gcp-iam-test-project-permissions",
  • Helper function that provides a singleton instance of the Google Cloud ResourceManager ProjectsClient used by the tool handler for IAM operations.
    export function getResourceManagerClient(): ProjectsClient {
      if (!resourceManagerClientInstance) {
        resourceManagerClientInstance = new ProjectsClient({
          projectId: process.env.GOOGLE_CLOUD_PROJECT,
        });
      }
      return resourceManagerClientInstance;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states what the tool does without behavioral details. It doesn't disclose whether this is a read-only operation, what authentication is required, how results are returned, or any rate limits. For a permissions-testing tool, this leaves critical behavioral traits unspecified.

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 a single, efficient sentence that states the tool's purpose without unnecessary words. It's front-loaded with the core functionality and appropriately sized for a straightforward tool.

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 no annotations and no output schema, the description is incomplete for a permissions-testing tool. It doesn't explain what the output looks like (e.g., which permissions are granted/denied), how errors are handled, or authentication requirements. For a tool that interacts with IAM systems, this leaves significant gaps in understanding.

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%, so the schema already documents both parameters thoroughly. The description doesn't add any parameter semantics beyond what's in the schema (e.g., it doesn't explain permission format conventions or project ID resolution). Baseline 3 is appropriate when the schema does the heavy lifting.

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 clearly states the specific action ('Test which permissions') and resource ('the current caller has on a Google Cloud project'), distinguishing it from siblings like 'gcp-iam-test-resource-permissions' which tests permissions on resources rather than projects. It uses precise terminology that matches the tool's domain.

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 like 'gcp-iam-test-resource-permissions' or 'gcp-iam-analyse-permission-gaps'. It doesn't mention prerequisites, use cases, or exclusions, leaving the agent to infer usage from the name alone.

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/krzko/google-cloud-mcp'

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