Skip to main content

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

VariableDefaultAllowed ValuesDescription
MCP_TRANSPORTstdiostdio, http, sse, streamable-httpCommunication protocol for MCP clients.
MCP_HOST0.0.0.0Valid IP AddressHost interface to bind for HTTP/SSE server.
MCP_PORT8770Valid TCP PortListening port for HTTP/SSE transports.
MCP_PATH/mcpURL PathBase path for JSON-RPC endpoints.
MCP_LOG_LEVELINFODEBUG, INFO, WARNING, ERRORServer log verbosity.
MCP_LOG_FORMATjsonjson, textStructured JSON or text log formatting.
MCP_HTTP_TIMEOUT300Integer (Seconds)Request timeout for HTTP clients.

Loki Backend Connection

VariableDefaultDescription
LOKI_URLhttp://loki:3100Grafana Loki HTTP API base URL (or gateway endpoint).
LOKI_TIMEOUT30Request timeout per backend query in seconds.
LOKI_VERIFY_SSLtrueEnable or disable SSL certificate verification.

Authentication & Multi-Tenancy

VariableDefaultDescription
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.

VariableDefaultDescription
LOKI_MAX_QUERY_BYTES5000000000 (5 GB)Hard ceiling on scanned bytes per query before rejection.
LOKI_MAX_TIME_WINDOW_HOURS336 (14 days)Maximum query time window in hours.
LOKI_MAX_LOG_LIMIT5000Maximum log lines returned in a single query call.
LOKI_HIGH_CARDINALITY_THRESHOLD10000Triggers 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