gcp-storage-mcp
Enables interaction with Google Cloud Storage buckets and blobs through an MCP server, supporting operations like listing, uploading, searching, batch operations, and generating signed URLs.
README
๐ Professional GCP Storage API
A comprehensive, enterprise-grade FastAPI server providing REST endpoints for Google Cloud Storage operations. Built with production-ready features including authentication, rate limiting, monitoring, caching, and structured logging.
<img src="imgs/logo.png" alt="Logo" width="300" height="300">
โจ Features
๐ง Core API Features
- Complete GCS Operations: Full REST API for buckets, blobs, and storage management
- Batch Operations: Efficient bulk upload/delete operations
- Storage Analytics: Comprehensive storage usage and performance metrics
- Search & Filter: Advanced blob search and size-based filtering
- Signed URLs: Temporary access URL generation with configurable expiration
- Project Management: Multi-project support and project switching
๐ Security & Authentication
- API Key Authentication: Secure API key-based authentication system
- Rate Limiting: Configurable rate limiting with Redis support
- CORS Protection: Configurable cross-origin resource sharing
- Security Headers: Comprehensive security headers (CSP, HSTS, etc.)
- Input Validation: Extensive request validation and sanitization
โก Performance & Monitoring
- Intelligent Caching: In-memory caching with TTL and automatic invalidation
- Request Tracking: Unique request IDs for complete request tracing
- Metrics Collection: Built-in performance and usage metrics
- Structured Logging: JSON-based structured logging with request context
- Health Checks: Advanced health monitoring with dependency status
๐ก๏ธ Production Ready
- Configuration Management: Environment-based configuration system
- Error Handling: Comprehensive error responses with detailed context
- Graceful Shutdown: Proper application lifecycle management
- Documentation: Auto-generated OpenAPI documentation with examples
- Monitoring Endpoints: Built-in metrics and health check endpoints
๐ Usage
GCP Storage MCP can be used with Claude Desktop, Cursor, and more.
๐ฆ Claude Desktop
claude_desktop_config.json
"mcpServers": {
"gcp-storage-mcp": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/uysalserkan/gcp-storage-mcp",
"gcp-storage-mcp",
"--credential_path",
"your-credential-path.json"
]
},
...
}
๐ฆ Cursor
.cursor/mcp.json
"mcpServers": {
"gcp-storage-mcp": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/uysalserkan/gcp-storage-mcp",
"gcp-storage-mcp",
"--credential_path",
"your-credential-path.json"
]
},
...
}
๐ฆ Quick Start FastAPI
Prerequisites
- Python 3.11+
- Google Cloud SDK installed and configured
- Active Google Cloud Project with Cloud Storage API enabled
- Service Account with appropriate permissions
Installation
- Clone and Setup
git clone https://github.com/your-username/gcp-storage-mcp.git
cd gcp-storage-mcp
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
- Configure GCP Authentication
# Option 1: Service Account Key
export GOOGLE_APPLICATION_CREDENTIALS="path/to/service-account.json"
# Option 2: Application Default Credentials
gcloud auth application-default login
- Start the Server
# Development mode
python gcp-storage-mcp/api.py
# Production mode with configuration
GCP_STORAGE_API_LOG_LEVEL=INFO python gcp-storage-mcp/api.py
- Access the API
- API Documentation:
http://localhost:8000/docs - Health Check:
http://localhost:8000/health - Metrics:
http://localhost:8000/metrics
๐ API Documentation
Core Endpoints
Health & Monitoring
GET /health- Advanced health check with dependenciesGET /metrics- System performance metricsGET /- API information and navigation
Project Management
GET /projects- List all accessible GCP projectsGET /projects/current- Get current project ID
Bucket Operations
GET /buckets- List all bucketsPOST /buckets/{bucket_name}- Create bucketDELETE /buckets/{bucket_name}- Delete bucketGET /buckets/{bucket_name}- Get bucket informationGET /buckets/{bucket_name}/exists- Check bucket existence
Blob Operations
GET /buckets/{bucket_name}/blobs- List blobs with prefix filteringPOST /buckets/{bucket_name}/blobs/{blob_name}/upload- Upload blobPOST /buckets/{bucket_name}/blobs/{blob_name}/download- Download blobDELETE /buckets/{bucket_name}/blobs/{blob_name}- Delete blobGET /buckets/{bucket_name}/blobs/{blob_name}- Get blob informationGET /buckets/{bucket_name}/blobs/{blob_name}/url- Get public URLPOST /buckets/{bucket_name}/blobs/{blob_name}/signed-url- Generate signed URL
Advanced Operations
POST /buckets/{bucket_name}/blobs/{blob_name}/copy- Copy blobPOST /buckets/{bucket_name}/blobs/{blob_name}/move- Move blobPOST /buckets/{bucket_name}/batch/upload- Batch uploadPOST /buckets/{bucket_name}/batch/delete- Batch delete
Analytics & Search
GET /buckets/{bucket_name}/analytics/storage- Storage analyticsPOST /buckets/{bucket_name}/search- Search blobs by patternPOST /buckets/{bucket_name}/filter- Filter blobs by size
๐ง Usage Examples
Basic Operations
Authentication with API Key
curl -H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
http://localhost:8000/health
List Buckets
curl -H "X-API-Key: your-api-key" \
http://localhost:8000/buckets
Upload a File
curl -X POST \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{"file_path": "/path/to/local/file.txt"}' \
http://localhost:8000/buckets/my-bucket/blobs/path/to/file.txt/upload
Generate Signed URL
curl -X POST \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{"expiration_hours": 24, "method": "GET"}' \
http://localhost:8000/buckets/my-bucket/blobs/file.txt/signed-url
Python Client Example
import httpx
import asyncio
class GCPStorageClient:
def __init__(self, base_url: str, api_key: str):
self.base_url = base_url
self.headers = {"X-API-Key": api_key}
async def list_buckets(self):
async with httpx.AsyncClient() as client:
response = await client.get(
f"{self.base_url}/buckets",
headers=self.headers
)
return response.json()
async def upload_file(self, bucket: str, blob_name: str, file_path: str):
async with httpx.AsyncClient() as client:
response = await client.post(
f"{self.base_url}/buckets/{bucket}/blobs/{blob_name}/upload",
headers=self.headers,
json={"file_path": file_path}
)
return response.json()
# Usage
async def main():
client = GCPStorageClient("http://localhost:8000", "your-api-key")
# List buckets
buckets = await client.list_buckets()
print(f"Found {buckets['count']} buckets")
# Upload file
result = await client.upload_file(
"my-bucket",
"documents/file.pdf",
"/local/path/file.pdf"
)
print(f"Upload completed: {result}")
if __name__ == "__main__":
asyncio.run(main())
๐ Monitoring & Observability
Health Monitoring
The API provides comprehensive health checks:
# Basic health check
curl http://localhost:8000/health
# Response includes:
# - Overall status
# - GCP connection status
# - Dependency health
# - Performance metrics
# - Uptime information
Metrics Collection
Built-in metrics endpoint provides:
curl http://localhost:8000/metrics
# Metrics include:
# - Request counts by endpoint
# - Response times
# - Error rates
# - Active requests
# - Cache hit rates
Structured Logging
All requests are logged with structured JSON:
{
"timestamp": "2024-01-15T10:30:00Z",
"level": "INFO",
"message": "Request completed",
"request_id": "550e8400-e29b-41d4-a716-446655440000",
"method": "GET",
"path": "/buckets",
"status_code": 200,
"duration_ms": 45.2,
"client_ip": "192.168.1.100"
}
๐ Security Best Practices
Authentication
- Use strong, randomly generated API keys
- Rotate API keys regularly
- Store keys securely (environment variables, secret managers)
CORS Configuration
# Restrict origins in production
GCP_STORAGE_API_ALLOWED_ORIGINS="https://yourdomain.com,https://app.yourdomain.com"
Rate Limiting
# Configure appropriate limits
GCP_STORAGE_API_RATE_LIMIT_DEFAULT="1000/hour"
GCP_STORAGE_API_RATE_LIMIT_STORAGE="redis://secure-redis:6379"
GCP Permissions
Minimum required IAM roles:
roles/storage.objectViewer- Read operationsroles/storage.objectCreator- Upload operationsroles/storage.admin- Full management (production)
๐ Performance Features
Intelligent Caching
- Bucket Lists: Cached for 5 minutes
- Bucket Info: Cached for 10 minutes
- Blob URLs: Cached for 1 hour
- Storage Analytics: Cached for 30 minutes
- Automatic Invalidation: Cache cleared on data modifications
Request Optimization
- Parallel Processing: Concurrent operations where possible
- Batch Operations: Efficient bulk operations
- Connection Pooling: Optimized GCP client connections
- Request Tracking: Complete request lifecycle monitoring
๐งช Testing
# Install test dependencies
pip install pytest pytest-cov httpx
# Run tests
pytest tests/
# Run with coverage
pytest --cov=gcp-storage-mcp tests/
# Integration tests (requires GCP setup)
GCP_STORAGE_API_TEST_BUCKET="test-bucket" pytest tests/integration/
๐ค Contributing
We welcome contributions! Please:
- Fork the repository
- Create a feature branch
- Follow the existing code style
- Add tests for new features
- Update documentation
- Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Resources
- API Documentation:
/docsendpoint (Swagger UI) - Google Cloud Storage: Official Documentation
- FastAPI: Official Documentation
- Rate Limiting: SlowAPI Documentation
๐ Support
- ๐ Issues: GitHub Issues
- ๐ง Email: uysalserkan08@gmail.com
Status: โ Production Ready | Version: 1.0.0 | Last Updated: January 2025
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.