Skip to main content
Glama

config_set_project

Set the default Google Cloud project ID for streamlined resource management in GCP MCP operations. Input the project ID to configure and validate settings.

Instructions

    Set the default Google Cloud project.
    
    Args:
        project_id: The ID of the project to set as default
    
    Returns:
        Status message indicating whether the project was set
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes

Implementation Reference

  • The core handler function for the 'config_set_project' tool. Decorated with @mcp.tool() for automatic registration. Updates the global project ID, writes to gcloud config file using helper, and verifies project accessibility using GCP Resource Manager API.
    @mcp.tool()
    def config_set_project(project_id: str) -> str:
        """
        Set the default Google Cloud project.
        
        Args:
            project_id: The ID of the project to set as default
        
        Returns:
            Status message indicating whether the project was set
        """
        nonlocal _current_project_id
        
        try:
            # Update global project ID
            _current_project_id = project_id
            
            # Create or update the config file
            _set_project_id_in_config(project_id)
            
            # Verify the project exists
            try:
                from google.cloud import resourcemanager_v3
                import google.auth
                
                credentials, _ = google.auth.default()
                client = resourcemanager_v3.ProjectsClient(credentials=credentials)
                name = f"projects/{project_id}"
                
                try:
                    project = client.get_project(name=name)
                    return f"Default project set to {project_id} ({project.display_name})."
                except Exception:
                    # Project might not exist or user might not have access
                    return f"Default project set to {project_id}. Note: Could not verify if this project exists or if you have access to it."
            
            except Exception as e:
                # Don't fail if we can't verify the project
                return f"Default project set to {project_id}."
                
        except Exception as e:
            return f"Error setting project: {str(e)}"
  • Helper function called by the handler to persist the project ID in the standard gcloud configuration file (~/.config/gcloud/configurations/config_default).
    def _set_project_id_in_config(project_id: str) -> None:
        """Set the project ID in the configuration file."""
        config_dir = _get_config_path()
        os.makedirs(config_dir, exist_ok=True)
        
        config_file = os.path.join(config_dir, 'configurations', 'config_default')
        os.makedirs(os.path.dirname(config_file), exist_ok=True)
        
        # Read existing config if it exists
        config_data = {}
        if os.path.exists(config_file):
            try:
                with open(config_file, 'r') as f:
                    for line in f:
                        if '=' in line:
                            key, value = line.strip().split('=', 1)
                            config_data[key.strip()] = value.strip()
            except:
                pass
        
        # Update project
        config_data['project'] = project_id
        
        # Write back config
        with open(config_file, 'w') as f:
            for key, value in config_data.items():
                f.write(f"{key} = {value}\n")
  • The @mcp.tool() decorator registers the config_set_project function as an MCP tool within the register_tools(mcp) function.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a mutation operation ('Set'), but doesn't mention whether this affects global state, requires specific permissions, has side effects, or provides error handling. The description lacks critical behavioral context needed for safe invocation.

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 efficiently structured with a clear purpose statement followed by Args/Returns sections. Every sentence serves a purpose with zero waste, making it easy to parse while maintaining completeness for its current content.

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 mutation tool with no annotations and no output schema, the description provides basic purpose and parameter explanation but lacks critical context about behavioral traits, error conditions, and relationship to sibling tools. It's minimally adequate but leaves significant gaps in understanding how and when to use this tool safely.

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?

With only one parameter and 0% schema description coverage, the description compensates well by explaining what 'project_id' represents ('The ID of the project to set as default'). This adds meaningful context beyond the bare schema, though it doesn't specify format constraints or validation rules.

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 ('Set') and resource ('default Google Cloud project'), making the purpose specific and understandable. However, it doesn't differentiate from sibling tools like 'set_quota_project' or 'config_list', which reduces clarity about when to choose this specific configuration tool over alternatives.

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 'config_list' or 'set_quota_project'. It mentions neither prerequisites (e.g., authentication state) nor exclusions, leaving the agent with insufficient context for proper tool selection.

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