Skip to main content
Glama

list_service_accounts

Retrieve a list of service accounts within a specified Google Cloud Platform (GCP) project using the project ID, simplifying IAM and resource management.

Instructions

    List service accounts in a GCP project.
    
    Args:
        project_id: The ID of the GCP project
    
    Returns:
        List of service accounts in the project
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes

Implementation Reference

  • Handler function implementing the list_service_accounts tool. It lists service accounts in a GCP project using the IAM client and returns a formatted string list. Registered inline with @mcp.tool() decorator.
        def list_service_accounts(project_id: str) -> str:
            """
            List service accounts in a GCP project.
            
            Args:
                project_id: The ID of the GCP project
            
            Returns:
                List of service accounts in the project
            """
            try:
                from google.cloud import iam_v1
                
                # Initialize the IAM client
                client = iam_v1.IAMClient()
                
                # List service accounts
                request = iam_v1.ListServiceAccountsRequest(
                    name=f"projects/{project_id}"
                )
                service_accounts = client.list_service_accounts(request=request)
                
                accounts_list = []
                for account in service_accounts:
                    display_name = account.display_name or "No display name"
                    accounts_list.append(f"- {account.email} ({display_name})")
                
                if not accounts_list:
                    return f"No service accounts found in project {project_id}."
                
                accounts_str = "\n".join(accounts_list)
                
                return f"""
    Service Accounts in GCP Project {project_id}:
    {accounts_str}
    """
            except Exception as e:
                return f"Error listing service accounts: {str(e)}"
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action 'List' but does not mention whether this is a read-only operation, if it requires specific permissions, rate limits, or what the return format entails (e.g., pagination, structure). This leaves significant gaps in understanding the tool's behavior.

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 front-loaded with the core purpose in the first sentence, followed by structured Args and Returns sections. It avoids unnecessary verbosity, though the formatting with blank lines could be slightly tighter. Every sentence adds value without waste.

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 output schema, no annotations), the description covers the basic purpose and parameter semantics adequately. However, it lacks details on behavioral aspects like permissions or return format, which are important for a list operation in a cloud environment, making it minimally viable but with clear gaps.

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 'project_id' by specifying it as 'The ID of the GCP project', which clarifies its purpose beyond the schema's minimal title 'Project Id'. With 0% schema description coverage and only one parameter, this compensation is adequate, though not exhaustive (e.g., no format examples).

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 verb 'List' and the resource 'service accounts in a GCP project', making the purpose unambiguous. However, it does not explicitly differentiate from sibling tools like 'list_roles' or 'list_assets', which list different resources, so it falls short of a perfect score.

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, such as 'list_roles' for roles or 'list_assets' for broader asset listings. It lacks context on prerequisites or exclusions, leaving the agent to infer usage based on the tool 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

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