get_gcp_project_details
Retrieve comprehensive details about a specific Google Cloud Platform (GCP) project by providing its project ID. Simplifies project management and resource oversight without manual credential setup.
Instructions
Get detailed information about a specific GCP project.
Args:
project_id: The ID of the GCP project to get details for
Returns:
Detailed information about the specified GCP project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes |
Implementation Reference
- The main handler function for the 'get_gcp_project_details' tool. It uses the Google Cloud ResourceManager v3 client to retrieve and format project details including number, name, creation time, state, and labels.@mcp.tool() def get_gcp_project_details(project_id: str) -> str: """ Get detailed information about a specific GCP project. Args: project_id: The ID of the GCP project to get details for Returns: Detailed information about the specified GCP project """ try: from google.cloud import resourcemanager_v3 # Initialize the Resource Manager client client = resourcemanager_v3.ProjectsClient() # Get the project details name = f"projects/{project_id}" project = client.get_project(name=name) # Format the response project_number = project.name.split('/')[-1] if project.name else "N/A" display_name = project.display_name or "N/A" create_time = project.create_time.isoformat() if project.create_time else "N/A" state = project.state.name if project.state else "N/A" labels = dict(project.labels) if project.labels else {} labels_str = "\n".join([f" {k}: {v}" for k, v in labels.items()]) if labels else " None" return f""" GCP Project Details for {project_id}: Project Number: {project_number} Name: {display_name} Creation Time: {create_time} State: {state} Labels: {labels_str} """ except Exception as e: return f"Error getting GCP project details: {str(e)}"
- src/gcp_mcp/server.py:33-33 (registration)The registration call for the resource management tools module, which includes the 'get_gcp_project_details' tool via its @mcp.tool() decorator inside register_tools.resource_tools.register_tools(mcp)
- src/gcp_mcp/server.py:63-63 (registration)Top-level call to register_tools() which triggers registration of all GCP tools, including get_gcp_project_details.register_tools()
- Docstring serving as input/output schema for the tool, defining the 'project_id' parameter and return description.""" Get detailed information about a specific GCP project. Args: project_id: The ID of the GCP project to get details for Returns: Detailed information about the specified GCP project """