Loki MCP Server Configuration
The TalkOps Loki MCP Server is configured using standard environment variables passed via .env files, Docker run flags, or Kubernetes ConfigMap and Secret resources.
Server & Transport Settings
| Variable | Default | Allowed Values | Description |
|---|---|---|---|
MCP_TRANSPORT | stdio | stdio, http, sse, streamable-http | Communication protocol for MCP clients. |
MCP_HOST | 0.0.0.0 | Valid IP Address | Host interface to bind for HTTP/SSE server. |
MCP_PORT | 8770 | Valid TCP Port | Listening port for HTTP/SSE transports. |
MCP_PATH | /mcp | URL Path | Base path for JSON-RPC endpoints. |
MCP_LOG_LEVEL | INFO | DEBUG, INFO, WARNING, ERROR | Server log verbosity. |
MCP_LOG_FORMAT | json | json, text | Structured JSON or text log formatting. |
MCP_HTTP_TIMEOUT | 300 | Integer (Seconds) | Request timeout for HTTP clients. |
Loki Backend Connection
| Variable | Default | Description |
|---|---|---|
LOKI_URL | http://loki:3100 | Grafana Loki HTTP API base URL (or gateway endpoint). |
LOKI_TIMEOUT | 30 | Request timeout per backend query in seconds. |
LOKI_VERIFY_SSL | true | Enable or disable SSL certificate verification. |
Authentication & Multi-Tenancy
| Variable | Default | Description |
|---|---|---|
LOKI_AUTH_TOKEN | (empty) | Optional Bearer token for HTTP Authorization: Bearer <token> header. |
LOKI_BASIC_AUTH_USER | (empty) | Basic authentication username. |
LOKI_BASIC_AUTH_PASSWORD | (empty) | Basic authentication password. |
LOKI_ORG_ID | (empty) | Multi-tenant organization ID injected via the X-Scope-OrgID header. |
Query Guardrails & Safety Limits
These guardrails protect your Loki cluster and the LLM's context window from expensive, unconstrained searches.
| Variable | Default | Description |
|---|---|---|
LOKI_MAX_QUERY_BYTES | 5000000000 (5 GB) | Hard ceiling on scanned bytes per query before rejection. |
LOKI_MAX_TIME_WINDOW_HOURS | 336 (14 days) | Maximum query time window in hours. |
LOKI_MAX_LOG_LIMIT | 5000 | Maximum log lines returned in a single query call. |
LOKI_HIGH_CARDINALITY_THRESHOLD | 10000 | Triggers warnings when a label exceeds this unique value count. |
Kubernetes Deployment Example
apiVersion: apps/v1
kind: Deployment
metadata:
name: loki-mcp-server
namespace: monitoring
labels:
app.kubernetes.io/name: loki-mcp-server
app.kubernetes.io/part-of: talkops
spec:
replicas: 1
selector:
matchLabels:
app: loki-mcp-server
template:
metadata:
labels:
app: loki-mcp-server
spec:
containers:
- name: server
image: talkopsai/loki-mcp-server:latest
imagePullPolicy: IfNotPresent
env:
- name: MCP_TRANSPORT
value: "http"
- name: MCP_PORT
value: "8770"
- name: LOKI_URL
value: "http://loki-gateway.monitoring:80"
- name: LOKI_ORG_ID
value: "production-tenant"
- name: LOKI_MAX_QUERY_BYTES
value: "2000000000"
ports:
- containerPort: 8770
name: http-mcp
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 512Mi