Integrations
Enables querying Google Cloud Logging using natural language, translating natural language queries into Google Cloud Logging Query Language (LQL) with Vertex AI, and retrieving log entries from various Google Cloud services.
Allows querying logs from Kubernetes clusters through natural language, enabling filtering and retrieval of Kubernetes-specific log data.
Offers OpenAPI/Swagger documentation for the API endpoints, making the logging query capabilities discoverable and testable.
MCP Logging NL Query Server
This project provides a Model Context Protocol (MCP) server that allows developers and AI Agents to query Google Cloud Logging using natural language. The server uses Vertex AI Gemini 2.5 to translate natural language queries into Google Cloud Logging Query Language (LQL), then queries Cloud Logging and returns the results.
Features
- Natural language to LQL translation using Vertex AI Gemini 2.5
- Flexible log querying: filter on monitored resource, log name, severity, time, and more
- REST API for easy integration
- Ready for deployment on Google Cloud Run or GKE
API Usage
Endpoints
1. Natural Language Query
POST /logs/nl_query
Request:
Response:
2. LQL Filter Query
POST /logs/query
Request:
Response:
OpenAPI & Tooling
- OpenAPI/Swagger docs available at
/docs
and/openapi.json
when running. - Both endpoints are also discoverable as MCP tools for agent frameworks (Smithery, Claude Desktop, etc).
Example curl commands
Tests
- Example test script:
test_main.py
(see repo)
.gitignore
- Standard Python ignores included (see repo)
Deployment
Running on Google Cloud Run
You can deploy this server to Google Cloud Run for a fully managed, scalable solution.
Steps:
- Build the Docker image:Copy
- Deploy to Cloud Run:ReplaceCopy
YOUR_PROJECT_ID
andYOUR_REGION
with your actual GCP project ID and region (e.g.,us-central1
). - Set Environment Variables:
- In the Cloud Run deployment UI or with the
--set-env-vars
flag, provide:VERTEX_PROJECT=your-gcp-project-id
VERTEX_LOCATION=us-central1
(or your region)
- Credentials:
- Prefer using the Cloud Run service account with the right IAM roles (Logging Viewer, Vertex AI User).
- You usually do NOT need to set
GOOGLE_APPLICATION_CREDENTIALS
on Cloud Run unless using a non-default service account key.
- In the Cloud Run deployment UI or with the
- IAM Permissions:
- Ensure the Cloud Run service account has:
roles/logging.viewer
roles/aiplatform.user
- Ensure the Cloud Run service account has:
- Accessing the Service:
- After deployment, Cloud Run will provide a service URL (e.g.,
https://mcp-logging-server-xxxxxx.a.run.app
). - Use this as your
$MCP_BASE_URL
in API requests.
- After deployment, Cloud Run will provide a service URL (e.g.,
Google Cloud Authentication Setup
This project requires Google Cloud Application Default Credentials (ADC) to access Logging and Vertex AI APIs.
Steps to Set Up Credentials:
- Create a Service Account:
- Go to the Google Cloud Console → IAM & Admin → Service Accounts.
- Select your project.
- Create or select a service account with permissions: Logging Viewer and Vertex AI User.
- Create and Download a Key:
- In the Service Account, click "Manage keys" → "Add key" → "Create new key" (choose JSON).
- Download the JSON key file to your computer.
- Set the Environment Variable:
- In your terminal, set the environment variable to the path of your downloaded key:Copy
- Replace
/path/to/your/service-account-key.json
with the actual path.
- In your terminal, set the environment variable to the path of your downloaded key:
- (Optional) Set Project and Location:
- You may also need:Copy
- You may also need:
- Verify Authentication:
- Run a simple
gcloud
or Python client call to ensure authentication is working. - If you see
DefaultCredentialsError
, check your environment variable and file path.
- Run a simple
Prerequisites
- Python 3.9+
- Google Cloud project with Logging and Vertex AI APIs enabled
- Service account with permissions for Logging Viewer and Vertex AI User
- Set environment variables:
VERTEX_PROJECT
: Your GCP project IDVERTEX_LOCATION
: Vertex AI region (default:us-central1
)GOOGLE_APPLICATION_CREDENTIALS
: Path to your service account JSON key file
Local Development
Deploy to Cloud Run
Example Natural Language Queries
- Show all logs from Kubernetes clusters
- Show error logs from Compute Engine and AWS EC2 instances
- Find Admin Activity audit logs for project my-project
- Find logs containing the word unicorn
- Find logs with both unicorn and phoenix
- Find logs where textPayload contains both unicorn and phoenix
- Find logs where textPayload contains the phrase 'unicorn phoenix'
- Show logs from yesterday for Cloud Run service 'my-service'
- Show logs from the last 30 minutes
- Show logs for logName containing request_log in GKE
- Show logs where pod_name matches foo or bar using regex
- Show logs for Compute Engine where severity is WARNING or higher
- Show logs for Cloud SQL instances in us-central1
- Show logs for Pub/Sub topics containing 'payments'
- Show logs for log entries between two timestamps
- Show logs where jsonPayload.message matches regex 'foo.*bar'
- Show logs where labels.env is not prod
For more LQL examples, see the official documentation.
License
Apache 2.0
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Allows developers and AI Agents to query Google Cloud Logging using natural language, translating queries into Google Cloud Logging Query Language (LQL) with Vertex AI Gemini 2.5.
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol server that enables AI assistants like Claude to interact with Google Cloud Platform environments through natural language, allowing users to query and manage GCP resources during conversations.Last updated -910262TypeScriptMIT License
- -securityFlicense-qualityEnables managing Google Cloud Platform resources through natural language commands in Claude Desktop, supporting comprehensive operations across compute, storage, databases, networking, monitoring, and IAM without manual credential setup.Last updated -8Python
- -securityFlicense-qualityA server implementing the Model Context Protocol that enables AI assistants like Claude to interact with Google's Gemini API for text generation, text analysis, and chat conversations.Last updated -Python
- -securityFlicense-qualityA Model Context Protocol server that enables Claude Desktop to interact with Google's Gemini 2.5 Pro Experimental AI model, with features like Google Search integration and token usage reporting.Last updated -JavaScript