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.
APIs & logs · MCP integration
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.
Connection in GateRook
stage-logs
Loki
stage / QAThe route
Your AI requests a tool. GateRook checks the endpoint policy, resolves credentials locally, and calls the configured service.
Understand the request flowAsk your AI
Find recent order 48213 errors in Loki and explain the sequence.
{
"connection": "stage-logs",
"query": "{app=\"orders\"} |= \"48213\" |= \"ERROR\"",
"from": "-15m",
"to": "now",
"limit": 20
}{
"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
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.
Use logs_tail and its returned cursor to collect subsequent entries. Each call has a bounded wait rather than an unending live stream.
Keep tenant-specific Loki connections clearly named and expose only the relevant connection on an endpoint.
From service to MCP
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.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.
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.
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.
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.
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
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.
| Setting | Example | How to use it |
|---|---|---|
Connector type | Loki | A built-in variant of the Logs connector. |
Name / environment | stage-logs / stage | Use the connection name to target log tool calls. |
URL | https://loki.stage.internal | The Loki API base URL. A Grafana Cloud Logs endpoint can also be configured. |
Tenant | orders-team | Optional X-Scope-OrgID. Leave empty for single-tenant Loki. |
Credentials mode | bearer | Choose none, bearer or basic to match the server. Grafana Cloud commonly uses basic authentication with its numeric user ID. |
Token or password | Enter in GateRook (write-only) | Store the credential in the connection. Add a PEM certificate when Loki uses a private CA. |
Know what you expose
The connector determines what is possible. Endpoint modes and connection policies determine what a particular AI client may use.
| Tool | Purpose | Access behavior |
|---|---|---|
logs_search | Search a bounded time range in the backend query language, with a cursor for older results. | Read only |
logs_tail | Read new log entries since a cursor, waiting up to eight seconds for another page. | Read only |
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
Use Test connection to isolate service access problems. Use Playground and Activity to inspect endpoint permissions and tool calls.
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.
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.
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
Connect AWS CloudWatch Logs to AI through MCP. Search and follow scoped logs with GateRook, using native queries, bounded time ranges and private credentials.
Connect Google Cloud Logging to AI through MCP. Search and follow scoped logs with GateRook, using native queries, bounded time ranges and private credentials.
Connect OpenSearch to AI through MCP. Search and follow scoped logs with GateRook, using native queries, bounded time ranges and private credentials.
Your infrastructure, on your terms
Start with one connection. Choose what your AI can do.