Skip to main content
Glama

auth_list

Retrieve a list of active Google Cloud credentials and identify the current default account for streamlined access and management using the GCP MCP server.

Instructions

List active Google Cloud credentials. Returns: List of active credentials and the current default account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'auth_list' MCP tool. It lists active Google Cloud credentials by checking application default credentials (ADC), extracting account info, and scanning gcloud credentials directory for additional accounts.
    def auth_list() -> str: """ List active Google Cloud credentials. Returns: List of active credentials and the current default account """ try: import google.auth # Check application default credentials try: credentials, project = google.auth.default() # Try to get email from credentials email = None if hasattr(credentials, 'service_account_email'): email = credentials.service_account_email elif hasattr(credentials, 'refresh_token') and credentials.refresh_token: # This is a user credential adc_path = _get_adc_path() if os.path.exists(adc_path): try: with open(adc_path, 'r') as f: data = json.load(f) if 'refresh_token' in data: # This is a user auth, but we can't get the email directly email = "User account (ADC)" except: pass credential_type = type(credentials).__name__ output = "Active Credentials:\n" if email: output += f"- {email} (Application Default Credentials, type: {credential_type})\n" else: output += f"- Application Default Credentials (type: {credential_type})\n" if project: output += f"\nCurrent Project: {project}\n" else: output += "\nNo project set in default credentials.\n" # Check for other credentials in well-known locations credentials_dir = os.path.expanduser("~/.config/gcloud/credentials") if os.path.isdir(credentials_dir): cred_files = [f for f in os.listdir(credentials_dir) if f.endswith('.json')] if cred_files: output += "\nOther available credentials:\n" for cred_file in cred_files: try: with open(os.path.join(credentials_dir, cred_file), 'r') as f: data = json.load(f) if 'client_id' in data: output += f"- User account ({cred_file})\n" elif 'private_key_id' in data: output += f"- Service account: {data.get('client_email', 'Unknown')} ({cred_file})\n" except: output += f"- Unknown credential type ({cred_file})\n" return output except Exception as e: return f"No active credentials found. Please run auth_login() to authenticate.\nError: {str(e)}" except Exception as e: return f"Error listing credentials: {str(e)}"
  • Registration of authentication tools (including auth_list) by calling register_tools on the auth_tools module in the main GCP MCP server.
    auth_tools.register_tools(mcp)
  • Import of the auth tools module in the main server.py, aliased as auth_tools, which provides the register_tools function.
    from .gcp_modules.auth import tools as auth_tools
  • Helper function used by auth_list to determine the path to the application default credentials (ADC) file.
    def _get_adc_path() -> str: """Get the path to the application default credentials file.""" # Standard ADC paths by platform if os.name == 'nt': # Windows return os.path.join(os.environ.get('APPDATA', ''), 'gcloud', 'application_default_credentials.json') else: # Linux/Mac return os.path.expanduser('~/.config/gcloud/application_default_credentials.json')

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