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:
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavioral traits. It states this is a creation tool, implying mutation, but lacks critical details: required permissions (e.g., IAM roles), whether the operation is idempotent, potential side effects (e.g., billing implications), or error handling. The description adds minimal behavioral context beyond the basic action.

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

Conciseness4/5

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

The description is well-structured with a clear purpose statement followed by parameter and return sections. It uses bullet-like formatting for readability. However, the 'Returns' section is vague ('Result of the service account creation'), and some sentences could be more direct (e.g., merging the purpose with parameter context).

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 complexity (a mutation tool in GCP with no annotations and no output schema), the description is incomplete. It lacks behavioral transparency (e.g., permissions, side effects), usage guidelines, and details on return values. While parameter semantics are covered, the overall context for safe and effective use is insufficient.

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?

Schema description coverage is 0%, so the description must compensate. It provides meaningful semantics for all four parameters: 'project_id' specifies the GCP project, 'account_id' includes a length constraint (6-30 characters), 'display_name' clarifies it's user-friendly, and 'description' notes it's optional. This adds significant value beyond the bare schema, though it could detail formats (e.g., project ID pattern).

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 ('Create a new service account') and resource ('in a GCP project'), using a precise verb. It distinguishes this tool from sibling tools like 'list_service_accounts' or 'get_gcp_project_details' by focusing on creation rather than listing or retrieval.

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 does not mention prerequisites (e.g., authentication, project permissions), when not to use it, or how it relates to sibling tools like 'list_service_accounts' for verification. Usage is implied only by the tool name.

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

Related 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/henihaddad/gcp-mcp'

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