Google Cloud Logging MCP server
Create a powerful Model Context Protocol (MCP) server for Google Cloud Logging to collect, search, analyze, and export logs from across your GCP infrastructure and applications. This integration enables AI agents to manage logs, create metrics from log data, export logs to data warehouses, and set up alerts—all with secure service account authentication.
Setting up an MCP server
This article covers the standard steps for creating an MCP server in AI Gateway and connecting it to an AI client. The steps are the same for every integration — application-specific details (API credentials, OAuth endpoints, and scopes) are covered in the Authentication section on this page.
Before you begin
You'll need:
- Access to AI Gateway with permission to create MCP servers.
- API credentials for the application you're connecting (see the Authentication section on this page for what to collect).
Create an MCP server
Find the app in the catalog
- Sign in to AI Gateway and select App Catalog from the left navigation.
- Search for the application you want to connect, then select it from the catalog.
- Select Create MCP Server to start the wizard.
App Configuration
Confirm the Base URL for the API, then, under Tools, select the endpoints you want to expose. Select Next.
MCP Server Setup
- Enter a Name for your server — something descriptive that identifies both the application and its purpose.
- Enter a Description so your team knows what the server is for.
- Set the log level: choose Production Mode for terser logs, or Non-Production Mode for more verbose logs that can help with debugging.
- Select Next.
Authentication
Enter the authentication details for the application. This varies by service — see the Authentication section on this page for the specific credentials, OAuth URLs, and scopes to use.
Review
Look over the summary of your MCP server configuration, then select Create & Deploy. AI Gateway provisions the server and provides a server URL you'll use when configuring your AI client.
Connect to an AI client
Once your server is deployed, you'll need to add it to the AI client your team uses. Select your client for setup instructions:
Tips
- You can create multiple MCP servers for the same application — for example, a read-only server for reporting agents and a read-write server for automation workflows.
- If you're unsure which OAuth scopes to request, start with the minimum read-only set and add write scopes only when needed. Most application pages include scope recommendations.
Authentication
Google Cloud Logging uses OAuth 2.0 with service accounts for API access. Create a service account in your Google Cloud project with the Logging Admin role and download a JSON key file. In Google Cloud Console, go to IAM & Admin > Service Accounts, create a service account with the Logging Admin role, and download a JSON key.
| Value | Setting |
|---|---|
| Token endpoint | https://oauth2.googleapis.com/token |
| Scopes | https://www.googleapis.com/auth/cloud-platform |
Available tools
These tools let AI agents write logs, search for entries, create metrics from logs, configure sinks for export, and manage retention. Together they provide comprehensive observability for debugging, monitoring, and compliance.
| Tool | Description |
|---|---|
| Write log entry | Write a structured or plain-text log entry |
| List log entries | Query logs by resource type, severity, or time range |
| Tail logs | Stream new log entries in real-time |
| List logs | View all available logs in a project |
| Delete logs | Remove old log entries to manage storage |
| Create log sink | Export logs to BigQuery, Cloud Storage, or Pub/Sub |
| Get log sink | View sink configuration and destination |
| Update log sink | Change filter or destination |
| Delete log sink | Remove a sink |
| Create log metric | Generate a metric from log entries matching a filter |
| Get log metric | View metric configuration |
| Update log metric | Change metric filter or name |
| Delete log metric | Remove a metric |
| List exclusions | View log exclusion rules |
| Create exclusion | Exclude certain log patterns to reduce volume and cost |
Tips
Write logs as structured JSON with meaningful fields (service name, request ID, user ID) instead of plain text — this makes logs queryable and easier to analyze.
Create log-based metrics for critical events (errors, authentication failures) to surface important patterns and anomalies.
Configure alerting policies to notify your team immediately when metrics exceed critical thresholds.
Use exclusions to filter out noisy or low-value logs (for example, health checks, debug logs) before they're stored, reducing your logging bill significantly.
Create sinks to export logs to BigQuery for long-term analysis and compliance.
Also export logs to Cloud Storage for archival and audit purposes if your compliance requirements demand it.
Include correlation IDs and trace IDs in your logs so you can follow a user request through multiple services and understand the full execution path.
Cequence AI Gateway