list_gcp_projects
Retrieve all Google Cloud Platform projects available to the authenticated user, returning a list of project IDs for seamless resource management.
Instructions
List all available GCP projects for the authenticated user.
Returns:
List of project IDs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The handler function for the 'list_gcp_projects' tool. It uses the Google Cloud ResourceManager API to search and return a list of project IDs accessible to the authenticated user. Includes error handling. Registered via @mcp.tool() decorator.@mcp.tool() def list_gcp_projects(): """ List all available GCP projects for the authenticated user. Returns: List of project IDs """ try: from google.cloud import resourcemanager_v3 client = resourcemanager_v3.ProjectsClient() request = resourcemanager_v3.SearchProjectsRequest() response = client.search_projects(request=request) return [project.project_id for project in response] except Exception as e: return [f"Error listing GCP projects: {str(e)}"]
- src/gcp_mcp/server.py:33-33 (registration)Invocation of register_tools from the resource_management module, which defines and registers the list_gcp_projects tool using the MCP server instance.resource_tools.register_tools(mcp)
- src/gcp_mcp/server.py:6-6 (registration)Import of the tools module from resource_management, which contains the list_gcp_projects implementation and registration logic.from .gcp_modules.resource_management import tools as resource_tools