Provides examples of how to interact with the MCP server's HTTP transport using curl commands for initializing connections, making requests, and accessing server-sent events.
Provides access to Google Cloud services including Logging, Spanner, Monitoring, and Cloud Trace. Enables querying logs, executing Spanner database queries, retrieving monitoring metrics, analyzing trace data, and discovering Google Cloud resources.
Enables executing SQL queries on Spanner databases, listing databases and instances, retrieving schema information, and obtaining query execution metrics.
Used for package management in the project, allowing installation of dependencies, building, and running the MCP server.
Google Cloud MCP Server
A Model Context Protocol (MCP) server for Google Cloud services including Logging, Spanner, Monitoring, and Cloud Trace.
Features
- Google Cloud Logging: Query logs, list log entries, and search across different log sources
- Google Cloud Spanner: Execute queries, list databases and instances, get schema information
- Google Cloud Monitoring: Query metrics, list metric descriptors, get monitoring data
- Google Cloud Trace: Retrieve trace data and analyze distributed system performance
- Resource Discovery: Automatically discover and list available Google Cloud resources
- Project Management: Tools for managing Google Cloud project settings
Transport Support
This server supports two transport modes:
1. Stdio Transport (Default)
The traditional MCP stdio transport for use with MCP clients like Claude Desktop.
2. HTTP Transport (New!)
A web-based HTTP transport implementing the MCP Streamable HTTP specification.
Installation
Configuration
Environment Variables
GOOGLE_APPLICATION_CREDENTIALS
: Path to your Google Cloud service account key fileGOOGLE_CLOUD_PROJECT
: Your default Google Cloud project IDGOOGLE_CLIENT_EMAIL
: Service account email (alternative to credentials file)GOOGLE_PRIVATE_KEY
: Service account private key (alternative to credentials file)LAZY_AUTH
: Set to 'false' to initialize auth immediately (default: 'true')DEBUG
: Set to 'true' for debug loggingMCP_TRANSPORT
: Transport type - 'stdio' (default) or 'http'MCP_HTTP_PORT
: Port for HTTP transport (default: 3000)
Google Cloud Authentication
You can authenticate in several ways:
- Service Account Key File (Recommended):
- Environment Variables:
- Application Default Credentials: If running on Google Cloud, ADC will be used automatically.
Usage
Using Stdio Transport (Default)
Using HTTP Transport
When using HTTP transport, the server will be available at:
- MCP Endpoint:
http://127.0.0.1:3000/mcp
- Health Check:
http://127.0.0.1:3000/health
HTTP Transport Features
The HTTP transport implements the MCP Streamable HTTP specification with:
- Session Management: Automatic session ID assignment and tracking
- Server-Sent Events (SSE): For real-time communication and server-initiated messages
- Request/Response Handling: Proper JSON-RPC 2.0 message handling
- Security: Origin validation to prevent DNS rebinding attacks
- CORS Support: Cross-origin requests support for web applications
- Connection Management: Automatic cleanup of stale connections
HTTP Transport Usage Examples
Initialize Connection
The response will include a Mcp-Session-Id
header that should be used in subsequent requests.
Make Requests with Session
Server-Sent Events Stream
Available Tools
Logging Tools
gcp-logging-query
: Query Google Cloud Logsgcp-logging-list-entries
: List log entries with filters
Spanner Tools
gcp-spanner-execute-query
: Execute SQL queries on Spanner databasesgcp-spanner-list-databases
: List Spanner databasesgcp-spanner-list-instances
: List Spanner instancesgcp-spanner-get-schema
: Get database schema informationgcp-spanner-query-count
: Get query execution metrics
Monitoring Tools
gcp-monitoring-query
: Query monitoring metricsgcp-monitoring-list-metrics
: List available metric descriptorsgcp-monitoring-get-resource-metrics
: Get metrics for specific resources
Trace Tools
get-trace
: Retrieve trace data by trace IDsearch-traces
: Search for traces with filtersget-trace-summary
: Get summary statistics for traces
Project Tools
gcp-get-project-info
: Get current project informationgcp-list-enabled-services
: List enabled APIs and services
Available Resources
Logging Resources
gcp://logging/logs/{logName}
: Individual log resourcesgcp://logging/entries
: Recent log entries
Spanner Resources
gcp://spanner/instances
: List of Spanner instancesgcp://spanner/databases/{instanceId}
: Databases in an instancegcp://spanner/schema/{instanceId}/{databaseId}
: Database schema
Monitoring Resources
gcp://monitoring/metrics
: Available monitoring metricsgcp://monitoring/resources
: Monitored resource types
Trace Resources
gcp://trace/traces
: Recent trace data
Available Prompts
analyze-logs
: Analyze log patterns and errorsquery-optimization
: Optimize Spanner queriestroubleshoot-performance
: Troubleshoot application performance issuessecurity-analysis
: Analyze security-related logs and traces
Development
Troubleshooting
Authentication Issues
- Check your credentials:
- Verify service account permissions:
- Logging Viewer
- Spanner Database User
- Monitoring Viewer
- Cloud Trace User
- Test authentication:
HTTP Transport Issues
- Port conflicts: If port 3000 is in use, specify a different port:
- CORS issues: The server only accepts requests from localhost, 127.0.0.1, and .local domains for security.
- Session management: Make sure to include the
Mcp-Session-Id
header in requests after initialization.
Performance Issues
- Enable lazy authentication:
- Reduce logging verbosity: Remove
DEBUG=true
from production environments.
Security Considerations
HTTP Transport Security
- The server binds only to
127.0.0.1
(localhost) by default - Origin header validation prevents DNS rebinding attacks
- Sessions are automatically cleaned up
- Request timeouts prevent resource exhaustion
Google Cloud Security
- Use service accounts with minimal required permissions
- Regularly rotate service account keys
- Monitor access logs for unusual activity
- Use VPC-native clusters when possible
License
MIT License - see LICENSE file for details.
Tools
An MCP server that enables querying and interacting with Google Cloud services including Logging, Spanner, Monitoring, and Cloud Trace through natural language.
Related MCP Servers
- -securityFlicense-qualityAn MCP server that enables interaction with Google Cloud Logging API, allowing users to write, read, and manage log entries and configurations through natural language.Last updated -Python
- -securityFlicense-qualityAn MCP server that provides access to Google Cloud Monitoring API, enabling interaction with cloud resources monitoring data through natural language commands.Last updated -Python
- -securityFlicense-qualityAn MCP Server that enables interaction with Google Cloud's Data Loss Prevention (DLP) API, allowing users to discover, classify, and protect sensitive data through natural language commands.Last updated -Python
- -securityFlicense-qualityAn MCP Server that enables interaction with Google Cloud SQL Admin API, allowing users to manage Cloud SQL database instances through natural language commands.Last updated -Python