Skip to main content
Server Mode transforms ChatCLI into a high-performance gRPC service that can be accessed remotely from any terminal. This allows centralizing AI access on a server (bare-metal, VM, Docker, or Kubernetes) and connecting from anywhere.

Why Use Server Mode?

Centralization

A single server with configured API keys serves multiple clients

Security

API keys stay on the server, never exposed on client terminals

Flexibility

Clients can use their own credentials (API key or OAuth) if desired

Performance

Communication via gRPC with TLS support and progressive streaming
Server mode offers native integration with the K8s Watcher for Kubernetes deployment monitoring.

Starting the Server

1

Simplest mode

Server on the default port (50051):
2

With custom port and authentication

3

With TLS enabled

4

With integrated K8s Watcher (optional)

5

With provider fallback (optional)

6

With MCP (optional)

Available Flags

Fallback Flags (optional)

MCP Flag (optional)

Prometheus Metrics

The server exposes Prometheus metrics at http://localhost:9090/metrics by default. Metrics include:
  • gRPC: chatcli_grpc_requests_total, chatcli_grpc_request_duration_seconds, chatcli_grpc_in_flight_requests
  • LLM: chatcli_llm_requests_total, chatcli_llm_request_duration_seconds, chatcli_llm_errors_total
  • Watcher: chatcli_watcher_collection_duration_seconds, chatcli_watcher_alerts_total, chatcli_watcher_pods_ready
  • Session: chatcli_session_active_total, chatcli_session_operations_total
  • Server: chatcli_server_uptime_seconds, chatcli_server_info
  • Go runtime: goroutines, memory, GC (via GoCollector/ProcessCollector)
To disable, use --metrics-port 0.

Security Variables

gRPC reflection now requires two conditions: the --grpc-reflection flag AND the CHATCLI_GRPC_REFLECTION=true variable. This prevents accidental exposure in production. See the security documentation for all hardening measures.
The default bind address is 127.0.0.1 (secure for local use). In Kubernetes, the server auto-detects the environment via KUBERNETES_SERVICE_HOST and automatically binds to 0.0.0.0 โ€” no additional configuration needed. An explicit CHATCLI_BIND_ADDRESS value always takes precedence.

K8s Watcher Flags (optional)

Use --watch-config to monitor multiple deployments simultaneously with Prometheus metrics. See K8s Watcher for the YAML file format.

Server Authentication

By default, the server does not require authentication. Any client can connect:

Credential Modes

The server supports multiple LLM credential modes, providing full flexibility:
The server uses its own API keys configured via environment variables:
No additional client configuration needed.
The client can send its own API key, which the server uses instead of its own:
The client can use OAuth tokens from the local auth store (~/.chatcli/auth-profiles.json):
For the StackSpot provider, send the complete credentials:
To use GitHub Copilot, log in via Device Flow and connect with --use-local-auth:
For local models via Ollama, just provide the URL:

gRPC Architecture

The server implements a gRPC service with the following RPCs:

gRPC with Multiple Replicas

gRPC uses persistent HTTP/2 connections that, by default, pin to a single pod via kube-proxy. For scenarios with multiple replicas in Kubernetes:
  • 1 replica: Standard ClusterIP Service โ€” no extra configuration needed
  • Multiple replicas: Use a headless Service (ClusterIP: None) so that DNS returns individual pod IPs, enabling client-side round-robin load balancing via gRPC dns:/// resolver
  • The ChatCLI client already has built-in keepalive (ping every 10s) and round-robin support
  • In the Helm chart, enable service.headless: true when replicaCount > 1
  • In the Operator, headless is activated automatically when spec.replicas > 1
For more details, see the K8s Operator documentation and Helm deployment.

Progressive Streaming

The StreamPrompt RPC splits the response into ~200 character chunks at natural boundaries (paragraphs, lines, sentences), providing a progressive response experience on the client.

Resource Discovery RPCs

The ListRemotePlugins, ListRemoteAgents, ListRemoteSkills, GetAgentDefinition, GetSkillContent, ExecuteRemotePlugin, and DownloadPlugin RPCs allow connected clients to discover and use resources installed on the server.
  • Plugins: Executed on the server via ExecuteRemotePlugin or downloaded via DownloadPlugin (binary streaming)
  • Agents/Skills: Markdown content transferred to the client via GetAgentDefinition/GetSkillContent for local prompt composition

AIOps Platform RPCs

The GetAlerts and AnalyzeIssue RPCs are used by the AIOps Operator to feed the autonomous remediation pipeline.

GetAlerts

Returns active alerts detected by the K8s Watcher:

AnalyzeIssue

Sends Issue context to the LLM and returns structured analysis with suggested actions:

REST API Gateway

In addition to gRPC, the operator now exposes a REST HTTP API on port :8090 with:
  • 30+ endpoints covering incidents, SLOs, runbooks, approvals, postmortems, analytics, clusters and audit
  • Authentication via X-API-Key with role mapping (viewer/operator/admin)
  • Rate limiting at 100 req/min per key
  • Web Dashboard embedded and served at /
For the complete reference, see the API Reference.

Remote Commands via InteractiveSession

When connecting to a server via chatcli connect, the interactive session supports commands executed directly on the server: These commands are processed by the server and return results via bidirectional gRPC streaming (InteractiveSession).

K8s Watcher Integration

When the server is started with --watch-config or --watch-deployment, the K8s Watcher continuously monitors deployments and automatically injects the Kubernetes context into all prompts from remote clients.
Any connected user can ask questions about the deployments without additional configuration:

Rate Limiting

The server implements per-client rate limiting using a token bucket to protect against abuse: When the limit is reached, the server returns gRPC ResourceExhausted with a Retry-After header indicating how many seconds the client should wait.
In environments with multiple legitimate clients, increase the burst to accommodate usage spikes. RPS controls the sustained rate.

SSRF Prevention

The server validates all URLs configured in provider_config before use, blocking:
  • Private IPs: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
  • Cloud metadata: 169.254.169.254 (AWS, GCP, Azure)
  • Link-local: 169.254.0.0/16, fe80::/10
  • Loopback: 127.0.0.0/8, ::1
This prevents malicious LLM providers or misconfigurations from accessing internal network resources. Validation occurs before any HTTP request is sent.

Message Size Limits

These limits protect against resource exhaustion attacks and ensure server stability under load.

Audit Logging

The server can generate audit logs in JSON-lines format for complete traceability: Each request receives a unique Request ID for correlation. Recorded events include:
  • Authentication (success/failure)
  • Prompt and plugin execution
  • Session operations (save/load/delete)
  • Configuration changes
The JSON-lines format facilitates integration with tools like jq, Elasticsearch, Loki, and Splunk. Each line is an independent JSON object with timestamp, request ID, action, and result.

Log Rotation

Environment Variables

All environment variables used by local ChatCLI also work on the server:

Next Steps

Remote Connection

Connect to the server remotely

K8s Watcher

Multi-target + Prometheus

K8s Operator

K8s Operator (AIOps)

Deploy

Deploy with Docker and Helm