Skip to main content
Glama

create_service_account

Generate a new service account in a GCP project by specifying project ID, account ID, display name, and optional description, simplifying IAM management.

Instructions

    Create a new service account in a GCP project.
    
    Args:
        project_id: The ID of the GCP project
        account_id: The ID for the service account (must be between 6 and 30 characters)
        display_name: A user-friendly name for the service account
        description: Optional description for the service account
    
    Returns:
        Result of the service account creation
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
descriptionNo
display_nameYes
project_idYes

Implementation Reference

  • The main handler function for the 'create_service_account' tool. It uses the Google Cloud IAM client to create a service account with the given parameters and returns success or error message.
        @mcp.tool()
        def create_service_account(project_id: str, account_id: str, display_name: str, description: Optional[str] = None) -> str:
            """
            Create a new service account in a GCP project.
            
            Args:
                project_id: The ID of the GCP project
                account_id: The ID for the service account (must be between 6 and 30 characters)
                display_name: A user-friendly name for the service account
                description: Optional description for the service account
            
            Returns:
                Result of the service account creation
            """
            try:
                from google.cloud import iam_v1
                
                # Initialize the IAM client
                client = iam_v1.IAMClient()
                
                # Create service account
                request = iam_v1.CreateServiceAccountRequest(
                    name=f"projects/{project_id}",
                    account_id=account_id,
                    service_account=iam_v1.ServiceAccount(
                        display_name=display_name,
                        description=description
                    )
                )
                service_account = client.create_service_account(request=request)
                
                return f"""
    Service Account created successfully:
    - Email: {service_account.email}
    - Name: {service_account.name}
    - Display Name: {service_account.display_name}
    - Description: {service_account.description or 'None'}
    """
            except Exception as e:
                return f"Error creating service account: {str(e)}"
  • Registration of IAM tools module, which includes the create_service_account tool, by calling iam_tools.register_tools(mcp). This is part of the overall tool registration in the MCP server.
    iam_tools.register_tools(mcp)
  • Import of the IAM tools module aliased as iam_tools, necessary for registration.
    from .gcp_modules.iam import tools as iam_tools
  • Type hints defining the input schema (parameters) and output (str) for the tool.
    def create_service_account(project_id: str, account_id: str, display_name: str, description: Optional[str] = None) -> str:

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.2/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It provides parameter constraints but does not disclose behavioral traits like idempotency, permission requirements, or error handling. The return value is vaguely described as 'Result of the service account creation.'

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 docstring is concise and well-structured, stating the purpose first, then listing each argument and the return value without wasted words.

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?

For a create tool with no output schema and no annotations, the description is adequate but lacks detail on return values and edge cases (e.g., duplicate account_id). It does not mention prerequisites like IAM permissions or project existence.

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

Parameters5/5

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

The description explains all four parameters, including the 6-30 character constraint on account_id, adding meaning beyond the bare schema types. This fully compensates for the 0% schema description coverage.

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 'Create a new service account in a GCP project,' using a specific verb and resource. It distinguishes itself from sibling tools like list_service_accounts and create_instance.

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

Usage Guidelines4/5

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

The context is clear: this tool is for creating a service account in a GCP project. However, it does not explicitly mention when not to use it or alternatives, though none obvious exists among siblings.

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