delete_object
Remove a specific object from a Cloud Storage bucket on GCP by specifying the project ID, bucket name, and file name. Streamlines storage management directly through natural language commands.
Instructions
Delete an object from a Cloud Storage bucket.
Args:
project_id: The ID of the GCP project
bucket_name: The name of the bucket to delete from
blob_name: The name of the file to delete
Returns:
Result of the delete operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blob_name | Yes | ||
| bucket_name | Yes | ||
| project_id | Yes |
Implementation Reference
- The main handler function for the 'delete_object' tool. It is decorated with @mcp.tool() for registration and implements the logic to delete a blob from a GCP Cloud Storage bucket using the google.cloud.storage library. Includes input parameters, docstring schema, and error handling.@mcp.tool() def delete_object(project_id: str, bucket_name: str, blob_name: str) -> str: """ Delete an object from a Cloud Storage bucket. Args: project_id: The ID of the GCP project bucket_name: The name of the bucket to delete from blob_name: The name of the file to delete Returns: Result of the delete operation """ try: from google.cloud import storage # Initialize the Storage client client = storage.Client(project=project_id) # Get the bucket bucket = client.get_bucket(bucket_name) # Delete the blob blob = bucket.blob(blob_name) blob.delete() return f"Object gs://{bucket_name}/{blob_name} has been successfully deleted." except Exception as e: return f"Error deleting object: {str(e)}"
- src/gcp_mcp/server.py:42-42 (registration)Invocation of the storage module's register_tools function within the main server.py, which registers the 'delete_object' tool (and other storage tools) with the MCP server instance.storage_tools.register_tools(mcp)
- src/gcp_mcp/server.py:9-9 (registration)Import of the storage tools module in the main server.py, enabling the registration of the 'delete_object' tool.from .gcp_modules.storage import tools as storage_tools