Skip to content

APIs & logs · MCP integration

Bring Loki logs into an AI investigation through MCP.

Search Grafana Loki with LogQL from your MCP-compatible AI app. GateRook connects to the Loki API, attaches the configured tenant and credentials, and returns bounded log entries for the agent to inspect alongside database or API results.

Loki, in your AI workflow

Illustrative example

Connection in GateRook

stage-logs

Loki

stage / QA
Connector type
Loki
Name / environment
stage-logs / stage
URL
https://loki.stage.internal
Tenant
orders-team

The route

Your AI requests a tool. GateRook checks the endpoint policy, resolves credentials locally, and calls the configured service.

Understand the request flow

Ask your AI

Find recent order 48213 errors in Loki and explain the sequence.

logs_search · arguments
{
  "connection": "stage-logs",
  "query": "{app=\"orders\"} |= \"48213\" |= \"ERROR\"",
  "from": "-15m",
  "to": "now",
  "limit": 20
}
Example result
{
  "backend": "loki",
  "entries": [
    {
      "timestamp": "2026-10-22T12:29:00Z",
      "severity": "ERROR",
      "message": "Payment authorization timed out for order 48213"
    }
  ],
  "count": 1,
  "truncated": false
}

Sample configuration and output, not a live connection. Replace example values with your environment. Tool names here are connector names; the endpoint may expose a connection-specific name.

Put context to work

What you can do with Loki and AI

Trace a failed order

Search a single application stream for an order identifier, then compare the event with its SQL record. The response includes timestamps, severity and log messages.

Follow a new failure

Use logs_tail and its returned cursor to collect subsequent entries. Each call has a bounded wait rather than an unending live stream.

Work across tenants deliberately

Keep tenant-specific Loki connections clearly named and expose only the relevant connection on an endpoint.

From service to MCP

How to connect Loki

GateRook must be running on a computer that can reach your service. Open Connections, choose Add connection, and select Logs. Give the connection a name and environment.

New to GateRook? Start with the full setup guide.
  1. Find the Loki API endpoint

    Use the Loki service URL, not a Grafana dashboard URL. Confirm that the GateRook computer can reach it and obtain credentials for the intended tenant.

  2. Configure the Loki connection

    In Connections, choose Add connection and Loki. Set the name, environment, URL, optional tenant and the matching authentication mode. Enter the token or password in the connection form.

  3. Test a bounded log query

    Run Test connection, then finish Add to endpoint. Start with a specific stream selector and a short time range in Playground before connecting the AI app.

  4. Choose the endpoint and tool modes

    Add the tested connection to an endpoint. In Tools & policies, enable only the tools needed for the task. Start with Read only where supported; use Approval for any selected mutation and leave other tools Off. A connection alone does not grant an AI client access.

  5. Connect your AI and verify the first call

    In Clients, choose your AI app and endpoint, review the connection details, and connect. Try this guide’s example in Playground before asking your AI. Open Activity to inspect the tool, target, decision and returned result. The getting started guide covers this shared flow.

Connection settings

Configure Loki in GateRook

These are example values for the connection form. Enter credentials into GateRook’s secret fields, not into an AI prompt. Requirements and alternatives are noted per field.

Loki connection configuration
SettingExampleHow to use it
Connector typeLokiA built-in variant of the Logs connector.
Name / environmentstage-logs / stageUse the connection name to target log tool calls.
URLhttps://loki.stage.internalThe Loki API base URL. A Grafana Cloud Logs endpoint can also be configured.
Tenantorders-teamOptional X-Scope-OrgID. Leave empty for single-tenant Loki.
Credentials modebearerChoose none, bearer or basic to match the server. Grafana Cloud commonly uses basic authentication with its numeric user ID.
Token or passwordEnter in GateRook (write-only)Store the credential in the connection. Add a PEM certificate when Loki uses a private CA.

Know what you expose

Loki tools and access boundaries

The connector determines what is possible. Endpoint modes and connection policies determine what a particular AI client may use.

Available tools and access behavior
ToolPurposeAccess behavior
logs_searchSearch a bounded time range in the backend query language, with a cursor for older results.Read only
logs_tailRead new log entries since a cursor, waiting up to eight seconds for another page.Read only

Before you enable access

  • This integration reads logs. It does not edit entries, change retention or administer the logging service.
  • The connection scope, environment policy and result limits all apply. A truncated page is only part of the evidence.
  • Log messages may contain application data or sensitive payloads. Scope the source and review the data your AI app is permitted to receive.
  • Loki queries use LogQL and need a valid stream selector. An empty query is not supported.
  • The tenant is configured on the connection; it is not a free-form tenant selector given to the AI.

GateRook stores local connection secrets encrypted and resolves them for connectors. Allowed tool results are returned to your AI client and may be processed by its provider. Scope the data you expose as well as the actions you allow.

Practical answers

Loki connection questions

Use Test connection to isolate service access problems. Use Playground and Activity to inspect endpoint permissions and tool calls.

Is Grafana itself required?

GateRook talks to the Loki API. You can use a standalone Loki service or a compatible Grafana Cloud Logs endpoint; a dashboard URL is not the API address.

What query language does the AI use?

logs_search uses LogQL for a Loki connection. Begin with a stream selector such as {app="orders"} and add line filters for the event you are investigating.

Can I tail logs through MCP?

Yes. logs_tail returns bounded pages of new entries and a cursor for the next call, with a wait of up to eight seconds per call.

Keep exploring

AWS CloudWatch Logs

Connect AWS CloudWatch Logs to AI through MCP. Search and follow scoped logs with GateRook, using native queries, bounded time ranges and private credentials.

Google Cloud Logging

Connect Google Cloud Logging to AI through MCP. Search and follow scoped logs with GateRook, using native queries, bounded time ranges and private credentials.

OpenSearch

Connect OpenSearch to AI through MCP. Search and follow scoped logs with GateRook, using native queries, bounded time ranges and private credentials.

Browse all integration guides

Your infrastructure, on your terms

Bring Loki into the conversation.

Start with one connection. Choose what your AI can do.

Get GateRook

GateRook is in active development. Installers will appear here after a verified release.

macOS

Coming soon. The macOS build is not available yet.

Windows

Coming soon. The Windows build is not available yet.