Skip to main content
Glama

auth_revoke

Revoke Google Cloud credentials using GCP MCP to manage access securely. Returns a status message confirming successful credential revocation.

Instructions

    Revoke Google Cloud credentials.
    
    Returns:
        Status message indicating whether the credentials were revoked
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'auth_revoke' tool. It attempts to revoke active Google Cloud credentials using google.auth and removes the application default credentials (ADC) file.
    def auth_revoke() -> str:
        """
        Revoke Google Cloud credentials.
        
        Returns:
            Status message indicating whether the credentials were revoked
        """
        try:
            import google.auth
            from google.auth.transport.requests import Request
            
            # Check if we have application default credentials
            try:
                credentials, _ = google.auth.default()
                
                # If credentials have a revoke method, use it
                if hasattr(credentials, 'revoke'):
                    credentials.revoke(Request())
                
                # Remove the application default credentials file
                adc_path = _get_adc_path()
                if os.path.exists(adc_path):
                    os.remove(adc_path)
                    return "Application default credentials have been revoked and removed."
                else:
                    return "No application default credentials file found to remove."
            
            except Exception as e:
                return f"No active credentials found or failed to revoke: {str(e)}"
                
        except Exception as e:
            return f"Error revoking credentials: {str(e)}"
  • Registers all authentication tools, including 'auth_revoke', with the MCP server by calling the auth module's register_tools function.
    auth_tools.register_tools(mcp)
  • Helper function used by auth_revoke to determine the path to the application default credentials file for removal.
    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')
  • Imports the auth tools module, enabling registration of auth_revoke tool.
    from .gcp_modules.auth import tools as auth_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