Skip to main content

MCP Servers

Connect k8s-autopilot to external tools using the Model Context Protocol

k8s-autopilot natively supports the Model Context Protocol (MCP). MCP lets you connect external tool providers — Kubernetes cluster inspectors, CI/CD platforms, monitoring systems, and cloud APIs — directly into the agent without writing custom code. Each MCP server exposes a set of tools that the agent can discover and call like native functions.

k8s-autopilot ships with 11 built-in MCP servers, but the system is completely open: you can connect any third-party or internal MCP server through the UI or configuration files.


Add an MCP Server

From the Settings UI

Go to Settings → MCP Servers and click + Add Server. Enter the server name, command, arguments, and environment variables. The server is saved to the configuration database and made available immediately — no restart needed.

From a Config File

MCP servers can also be configured in .mcp.json files using the standard format:

{
"mcpServers": {
"my-database": {
"command": "npx",
"args": ["-y", "@my-org/db-mcp-server"],
"env": {
"DATABASE_URL": "postgresql://localhost:5432/mydb"
}
},
"my-cloud": {
"command": "uvx",
"args": ["cloud-mcp-server"],
"env": {
"API_KEY": "${MY_CLOUD_API_KEY}"
}
}
}
}

Each server entry defines:

FieldTypeWhat It Does
commandstringExecutable to launch (npx, python, uvx, docker, or a binary name)
argslistArguments passed to the server process
envobjectEnvironment variables for the server process
urlstringURL for HTTP/SSE transport (use instead of command for remote servers)
transportstringTransport type: stdio (default), http, or sse
headersobjectHTTP headers for remote transports (e.g. auth tokens)
disabled_toolslistGlob patterns for tools to exclude (e.g. ["delete_*", "drop_*"])
allowed_toolslistGlob patterns for tools to include (only matching tools are loaded)

Environment Variable Expansion

Config values support ${VAR} and ${VAR:-default} syntax (POSIX :- semantics). The :- form falls back to the default when the variable is unset or empty:

{
"env": {
"PROMETHEUS_URL": "${PROMETHEUS_BASE_URL:-http://localhost:9090}",
"API_TOKEN": "${MY_SECRET_TOKEN}"
}
}

If a ${VAR} reference has no default and the variable is unset in the environment, k8s-autopilot rejects the config with a clear error message rather than passing through an empty string.


Where Configs Are Loaded From

k8s-autopilot discovers MCP server configs from multiple locations and merges them together. The database is the source of truth — file-based configs are auto-seeded into the database on first discovery:

PriorityLocationSource Label
1Database (Settings UI)db
2Global user configs
~/.agents/.mcp.json or ~/.agents/mcp.json
~/.k8s_autopilot/.mcp.json or ~/.k8s_autopilot/mcp.json
global
3Project-level configs
.mcp.json, mcp.json, .k8s_autopilot/.mcp.json in project root
project
4Plugin configs
plugins/{name}/.mcp.json for non-agent plugins
plugin:{name}
5Installed plugin configs
Plugins installed from marketplace that bundle MCP servers
plugin:{name}
Operator Isolation

Operator-bundled MCP servers (in built_in_subagents/) are not loaded globally. They are strictly isolated — each operator connects to its own MCP servers only when invoked.


How Tools Are Named

When k8s-autopilot connects to an MCP server, it discovers all available tools and registers them with a namespaced name:

mcp__{server}__{tool}

For example, a tool get_pods from server kubernetes becomes:

mcp__kubernetes__get_pods

This prevents name collisions when multiple servers expose tools with the same name.


Transports

The MCP server runs as a local subprocess of k8s-autopilot, communicating via standard input/output (stdin/stdout). No network ports or firewall configurations are needed.

{
"command": "npx",
"args": ["-y", "kubernetes-mcp-server@latest"]
}

HTTP

For Docker Compose, remote deployments, or shared MCP servers across teams, use HTTP transport:

{
"url": "http://my-mcp-server:8080",
"transport": "http",
"headers": {
"Authorization": "Bearer ${MCP_AUTH_TOKEN}"
}
}

You can also override built-in operator servers to HTTP transport using the MCP_SERVERS environment variable (a JSON array):

MCP_SERVERS='[
{"name": "helm_mcp_server", "url": "http://helm-mcp:8080", "transport": "http"},
{"name": "prometheus-mcp-server", "url": "http://prom-mcp:8080", "transport": "http"}
]'

SSE (Server-Sent Events)

For servers that use the SSE streaming protocol:

{
"url": "http://my-server:8080/sse",
"transport": "sse"
}

If transport is not specified, k8s-autopilot auto-detects it: if url contains "sse" it uses SSE; if url is present it uses HTTP; otherwise it defaults to stdio.


Trust and Security

Trust Levels & SHA-256 Fingerprinting

Not all MCP configs are equally trusted. Configs committed to a shared Git repository could be contributed by anyone, so k8s-autopilot uses SHA-256 fingerprinting to gate project-level configs:

  • Global configs (~/.agents/, ~/.k8s_autopilot/) — Always trusted. You control these directly on your machine.
  • Database configs (Settings UI) — Always trusted. You added them explicitly in the console.
  • Built-in operator configs — Always trusted. They ship verified with k8s-autopilot.
  • Project-level configs (.mcp.json in project root) — Require explicit approval on first use. k8s-autopilot records your trust decision by hashing the file's SHA-256 fingerprint. If the file is modified in Git, the agent asks for confirmation again.

Semantic Tool Profiling

When an MCP server connects, k8s-autopilot automatically analyzes every tool it exposes and classifies it into a security tier. This happens at registration time with zero runtime overhead:

TierClassificationBehaviorExamples
Tier 1 — Read-onlyStrictly idempotent inspectionRuns automaticallyget_pods, query_metrics, list_releases, search_charts
Tier 2 — Low-impactReversible or transient mutationsRuns with light confirmationdry_run_install, add_label, annotate
Tier 3 — MutatingModifies live infrastructureGated by HITL approvalinstall_chart, scale_deployment, apply_manifest, sync_app
Tier 4 — DestructiveIrreversible deletion or evictionBlocked without explicit allowlistdelete_namespace, uninstall_release, drain_node, drop_database

The profiler checks both MCP tool annotations (the standard readOnlyHint and destructiveHint fields) and heuristic verb analysis (scanning tool names for patterns like get_, list_, delete_, uninstall_). Annotations always take precedence over heuristics.

Headless Mode Safety

When k8s-autopilot runs without a web UI (headless mode, CI/CD pipelines, Slack integration), the HeadlessMCPGuardMiddleware automatically blocks all Tier 3 and Tier 4 MCP tool calls that lack a coherent readOnlyHint=true annotation. This prevents unattended mutations from running in autonomous environments.

Tool Filtering

You can restrict which tools are exposed by any server using glob patterns:

{
"mcpServers": {
"kubernetes": {
"command": "npx",
"args": ["-y", "kubernetes-mcp-server@latest"],
"allowed_tools": ["get_*", "list_*", "describe_*"],
"disabled_tools": ["delete_*", "exec_*"]
}
}
}
  • allowed_tools — Only matching tools are loaded (allowlist).
  • disabled_tools — Matching tools are excluded (denylist).
  • If both are specified, disabled_tools is checked first.

Just-In-Time (JIT) Connection Lifecycle

MCP connections follow a Just-In-Time pattern for operator-bundled servers:

1. You ask a question routed to an operator
2. Operator's CompiledSubAgent wrapper opens the MCP connection
3. Operator executes its tools via MCP
4. Connection closes immediately after the operator completes

This prevents idle processes and memory leaks when many servers are registered but only a subset is used per conversation. Global (non-operator) MCP servers stay connected for the duration of the session.


MCP Timeout Settings

VariableDefaultWhat It Controls
MCP_TIMEOUT30Per-tool execution timeout in seconds
MCP_TIMEOUT_TOTAL600Total operation timeout in seconds
MCP_TIMEOUT_CONNECT300Server connection / startup timeout in seconds
MCP_DEFAULT_TRANSPORTsseDefault transport for new servers: sse, stdio, or http

Enabling and Disabling Servers

You can enable or disable any MCP server from the Settings → MCP Servers panel in the UI. Disabled servers are not connected during startup, and their tools are hidden from the agent.

From a config file, use the enabled field:

{
"mcpServers": {
"my-server": {
"command": "my-mcp-server",
"enabled": false
}
}
}

Built-in MCP Servers Reference

Server NameOperatorToolsKey Capabilities
helm-mcp-serverHelm Operator22Install, upgrade, rollback, uninstall, dry-run, value schema validation
argocd-mcp-serverApp Operator29Application onboarding, synchronization, rollback, health audits
argo-rollout-mcp-serverApp Operator18Canary promotions, blue-green cutovers, AnalysisTemplate monitoring
traefik-mcp-serverApp Operator11IngressRoute configuration, weighted traffic splitting, middleware
kubernetes-mcp-serverK8s Operator32Workloads, pod logs & exec, events, node diagnostics, RBAC, contexts
prometheus-mcp-serverObservability28PromQL execution, ServiceMonitors, alerting & recording rules, cardinality
alertmanager-mcp-serverObservability14Active alert triage, silences, receiver testing, notification routing
opentelemetry-mcp-serverObservability19Collector CRD provisioning, auto-instrumentation injection, sampling
loki-mcp-serverObservability9LogQL log streams, label discovery, trace-to-log correlation
tempo-mcp-serverObservability16TraceQL distributed tracing queries, RED metrics, waterfall timelines
github-mcp-serverHelm / Core12Repository management, Helm chart branch commits, PR creation

Next Steps