Skip to content

MCP Server

The KSail MCP (Model Context Protocol) server exposes all KSail commands as tools for MCP-compatible AI assistants and automation systems. This enables AI assistants like Claude Desktop to create, configure, and manage Kubernetes clusters, and lets automation scripts orchestrate complex cluster operations through a universal interface.

KSail can be found in the GitHub MCP Registry — search for io.github.devantler-tech/ksail to discover and install it directly from supported MCP clients.

  • KSail CLI installed and in PATH
  • Docker running (for local cluster operations)
  • An MCP-compatible client (Claude Desktop, VSCode with KSail extension, or custom MCP client)

The MCP server runs over stdio and is invoked by MCP clients:

Terminal window
ksail open mcp

The server listens on stdin, exposes supported KSail commands as MCP tools, and exits when the client disconnects. See Integration Examples for typical usage patterns.

The MCP server generates tools from the KSail command tree, consolidating commands by permission level into 5 tools:

ToolAccessDescriptionSubcommand parameter
cluster_readRead-onlyManage cluster lifecyclecommand
cluster_writeWriteManage cluster lifecyclecommand
tenant_writeWriteManage tenant lifecycletenant_command
workload_readRead-onlyManage workload operationsworkload_command
workload_writeWriteManage workload operationsworkload_command

These commands are not exposed as tools (interactive or long-running commands and shell helpers): completion, help, open, operator.

Each tool takes a subcommand parameter selecting the operation, plus the merged flags of its subcommands. Subcommands marked below also accept positional arguments via the args parameter.

cluster_read

Manage cluster lifecycle — read-only subcommands of ksail cluster. Select the operation via the command parameter.

SubcommandDescriptionAccepts args
diagnoseDiagnose failing cluster resourcesYes
diffShow configuration drift between ksail.yaml and live clusterYes
infoDisplay cluster informationYes
listList clustersYes
repairRepair local KSail/Talos state filesYes

cluster_write

Manage cluster lifecycle — write subcommands of ksail cluster. Select the operation via the command parameter.

SubcommandDescriptionAccepts args
backupBackup cluster resourcesYes
createCreate a clusterYes
deleteDestroy a clusterYes
initInitialize a new projectYes
restoreRestore cluster resources from backupYes
startStart a stopped clusterYes
stopStop a running clusterYes
updateUpdate a cluster configurationYes

tenant_write

Manage tenant lifecycle — write subcommands of ksail tenant. Select the operation via the tenant_command parameter.

SubcommandDescriptionAccepts args
createCreate a new tenantYes
deleteDelete a tenantYes

workload_read

Manage workload operations — read-only subcommands of ksail workload. Select the operation via the workload_command parameter.

SubcommandDescriptionAccepts args
describeDescribe resourcesYes
explainGet documentation for a resourceYes
exportExport container images from the clusterYes
forwardForward one or more local ports to a podYes
gen_clusterroleCreate a cluster roleYes
gen_clusterrolebindingCreate a cluster role binding for a particular cluster roleYes
gen_configmapCreate a config map from a local file, directory or literal valueYes
gen_cronjobCreate a cron job with the specified nameYes
gen_deploymentCreate a deployment with the specified nameYes
gen_helmreleaseGenerate a HelmRelease resourceYes
gen_ingressCreate an ingress with the specified nameYes
gen_jobCreate a job with the specified nameYes
gen_namespaceCreate a namespace with the specified nameYes
gen_poddisruptionbudgetCreate a pod disruption budget with the specified nameYes
gen_priorityclassCreate a priority class with the specified nameYes
gen_quotaCreate a quota with the specified nameYes
gen_roleCreate a role with single ruleYes
gen_rolebindingCreate a role binding for a particular role or cluster roleYes
gen_secret_docker-registryCreate a secret for use with a Docker registryYes
gen_secret_genericCreate a secret from a local file, directory, or literal valueYes
gen_secret_tlsCreate a TLS secretYes
gen_service_clusteripCreate a ClusterIP serviceYes
gen_service_externalnameCreate an ExternalName serviceYes
gen_service_loadbalancerCreate a LoadBalancer serviceYes
gen_service_nodeportCreate a NodePort serviceYes
gen_serviceaccountCreate a service account with the specified nameYes
getGet resourcesYes
imagesList container images required by cluster componentsNo
logsPrint container logsYes
scanRun security scans on Kubernetes manifestsYes
validateValidate Kubernetes manifests and kustomizationsYes
waitWait for a specific condition on one or many resourcesYes

workload_write

Manage workload operations — write subcommands of ksail workload. Select the operation via the workload_command parameter.

SubcommandDescriptionAccepts args
applyApply manifestsYes
apply_edit-last-appliedEdit latest last-applied-configuration annotations of a resource/objectYes
apply_set-last-appliedSet the last-applied-configuration annotation on a live object to match the contents of a fileYes
apply_view-last-appliedView the latest last-applied-configuration annotations of a resource/objectYes
cipher_decryptDecrypt a file with SOPSYes
cipher_editEdit an encrypted file with SOPSYes
cipher_encryptEncrypt a file with SOPSYes
cipher_importImport an age key to the system’s SOPS key locationYes
cipher_rotateRotate data keys for SOPS-encrypted filesYes
createCreate resourcesYes
create_clusterroleCreate a cluster roleYes
create_clusterrolebindingCreate a cluster role binding for a particular cluster roleYes
create_configmapCreate a config map from a local file, directory or literal valueYes
create_cronjobCreate a cron job with the specified nameYes
create_deploymentCreate a deployment with the specified nameYes
create_helmreleaseCreate or update a HelmRelease resourceYes
create_ingressCreate an ingress with the specified nameYes
create_jobCreate a job with the specified nameYes
create_kustomizationCreate or update a Kustomization resourceYes
create_namespaceCreate a namespace with the specified nameYes
create_poddisruptionbudgetCreate a pod disruption budget with the specified nameYes
create_priorityclassCreate a priority class with the specified nameYes
create_quotaCreate a quota with the specified nameYes
create_roleCreate a role with single ruleYes
create_rolebindingCreate a role binding for a particular role or cluster roleYes
create_secretCreate a secret using a specified subcommandYes
create_secret_docker-registryCreate a secret for use with a Docker registryYes
create_secret_genericCreate a secret from a local file, directory, or literal valueYes
create_secret_tlsCreate a TLS secretYes
create_serviceCreate a service using a specified subcommandYes
create_service_clusteripCreate a ClusterIP serviceYes
create_service_externalnameCreate an ExternalName serviceYes
create_service_loadbalancerCreate a LoadBalancer serviceYes
create_service_nodeportCreate a NodePort serviceYes
create_serviceaccountCreate a service account with the specified nameYes
create_source_gitCreate or update a GitRepository sourceYes
create_source_helmCreate or update a HelmRepository sourceYes
create_source_ociCreate or update an OCIRepository sourceYes
create_tokenRequest a service account tokenYes
debugCreate debugging sessions for troubleshooting workloads and nodesYes
deleteDelete resourcesYes
execExecute a command in a containerYes
exposeExpose a resource as a serviceYes
importImport container images to the clusterYes
installInstall Helm chartsYes
pushPackage and push an OCI artifact to a registryYes
reconcileTrigger reconciliation for GitOps workloadsYes
rolloutManage the rollout of a resourceYes
rollout_historyView rollout historyYes
rollout_pauseMark the provided resource as pausedYes
rollout_restartRestart a resourceYes
rollout_resumeResume a paused resourceYes
rollout_statusShow the status of the rolloutYes
rollout_undoUndo a previous rolloutYes
scaleScale resourcesYes
watchWatch for file changes and auto-apply workloadsNo

MCP clients can discover available tools dynamically and toggle them on/off as needed. Each tool includes its name, a description, and a JSON schema with the subcommand selector enum and merged flags.

All tools carry MCP behavioral annotations that allow clients to make smarter decisions:

AnnotationRead tools (*_read)Write tools (*_write)
readOnlyHinttrue — no cluster or infrastructure mutationsfalse
destructiveHintfalsetrue — clients should warn before running
idempotentHinttruefalse
openWorldHinttrue — may interact with external systems such as clusters or registriestrue — may affect external systems

Clients that support MCP annotations (such as Claude Desktop) use these hints to distinguish read-only operations from destructive or non-idempotent actions, while recognizing that both read and write tools may interact with external systems.

All MCP tools return a structured JSON envelope, making responses easy to parse programmatically:

Success:

{
"status": "success",
"command": "ksail cluster info",
"output": "..."
}

Error:

{
"status": "error",
"command": "ksail cluster info",
"error": "docker is not running",
"output": "..."
}
FieldPresent whenDescription
statusAlways"success" or "error"
commandAlwaysFull command path (e.g. "ksail cluster info")
outputOptionalCaptured stdout/stderr from the command
errorError onlyHuman-readable error message

For step-by-step setup instructions for each AI client — including PATH configuration, example prompts, and a tool reference — see Using KSail with AI Assistants.

Many MCP clients, including Claude Desktop, Cursor, and Windsurf, use the following mcpServers configuration pattern:

{
"mcpServers": {
"ksail": {
"command": "ksail",
"args": ["open", "mcp"]
}
}
}

The KSail VSCode extension handles MCP registration automatically — no manual configuration needed.

If you’re building your own MCP client:

import json
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async with stdio_client(StdioServerParameters(command="ksail", args=["open", "mcp"])) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
print([t.name for t in tools.tools])
result = await session.call_tool("cluster_read", arguments={"command": "info"})
response = json.loads(result.content[0].text)
if response["status"] == "success":
print(response.get("output", ""))
else:
print(f"Error: {response['error']}")

See Tool Responses for the full JSON envelope format.

The server uses stdio for communication, runs commands in the current working directory (set by the client), keeps the connection alive for 30 seconds after the last request, and returns results in pages of 100 items for large lists.

Security Note: Only run the MCP server with trusted MCP clients; any connected client can invoke KSail tools that execute commands with the full permissions of the user running ksail open mcp, so a compromised or misconfigured client could perform arbitrary cluster or filesystem operations on your behalf.

Ensure KSail is installed and in your PATH:

Terminal window
which ksail
# Should return the path to ksail binary
  1. Check the client configuration syntax (JSON formatting)
  2. Restart the MCP client after changing configuration
  3. Check client logs for connection errors

Commands fail with “Docker not running”

Section titled “Commands fail with “Docker not running””

Cluster operations require Docker:

Terminal window
docker ps
# Should list running containers without errors

Some operations (cluster creation, workload deployment) can take several minutes. Ensure your MCP client has appropriate timeout settings.

The server executes commands relative to the working directory set by the MCP client. For Claude Desktop and other clients that don’t set a working directory, ensure:

  • You’re in a directory with a ksail.yaml file when using cluster commands
  • Or use absolute paths in tool arguments

The VSCode extension automatically sets the working directory to the workspace root.

The MCP server is complementary to the AI Chat feature:

  • Use ksail open chat for interactive, conversational workflows with a rich TUI
  • Use ksail open mcp to expose KSail to external AI assistants like Claude Desktop

You can use both simultaneously — the chat command is excluded from MCP tools to avoid conflicts.

Use MCP tool calls in automation frameworks to orchestrate sequences of KSail operations — for example, cluster_write (init → create) → workload_write (apply, then cipher_encrypt). Use the same connection pattern shown in Custom MCP Client.