Skip to content
Draft, pre-release documentation

An agent or program you already run can use a Kasm session’s desktop through Kasm Session Runtime. Claude Code, Codex, any MCP client, a Playwright test or a Python script all reach the same 68 methods. Your code decides what to do next. The runtime delivers each action to the browser, the native application or the screen, reports what happened, and records the call.

None of this needs a model in the runtime. Scripted steps, browser and accessibility control, recipes and an outside agent need none. The three vision methods (screen.judge, screen.ground and screen.ask) need one, and Screen and input says where their answers come from.

For a coding agent such as Claude Code, Codex, OpenCode or Hermes, the Kasm toolkit is the shortest way in. kcli, the Kasm command line, serves the agent an MCP server that launches a session by workspace name and supplies both credentials below for it. The agent also gets skills and instructions for working in a session. See Install the toolkit.

The rest of this page is how the runtime is reached directly, for a script, a test, or a client without kcli.

Way in Address Credential
MCP over HTTP https://<host>/desktop/<kasm_id>/runtime/mcp Kasm sign-in and the session token
Plain HTTP POST https://<host>/desktop/<kasm_id>/runtime/v1/call/<method> Kasm sign-in and the session token
MCP over stdio a process the client starts inside the session none; the pipe is the boundary

The MCP and HTTP routes serve the same methods and record the same row for each call. Most callers use one of the two HTTP routes from outside the session. Stdio is for a client that runs inside the session and starts kasm-session-runtime mcp itself.

GET /v1/openapi.json returns an OpenAPI document for every route the runtime serves, with the credential each one takes. It needs no token.

A request passes two checks. Kasm’s proxy requires the user’s Kasm sign-in, which a login sets as a cookie (POST /api/authenticate returns it), and the kasm_url that public/request_kasm returns carries one. The runtime then requires the session token in the X-Kasm-Runtime-Session-Token header. Kasm’s proxy overwrites Authorization, so the token has no other header to travel in.

Cookie: session_token=<kasm login cookie>; username=<kasm username>
X-Kasm-Runtime-Session-Token: <session token>

The token is a value you choose and set as KASM_RUNTIME_SESSION_TOKEN in the session’s environment when you request the session. Setting it both configures the runtime and starts its MCP and HTTP routes. Without it they stay off. The runtime compares tokens in constant time and answers 401 to a missing or wrong one.

The session token travels in that header only. The messaging token (KASM_RUNTIME_INBOX_TOKEN) belongs to the sidebar and can also be sent as ?token= on the activity and inbox routes.

The routes are served through the workspace’s port map named runtime (port 9434). Administrators add it once per workspace image; Enable the runtime on a workspace has the steps.

The session token is the whole credential. Whoever holds it, and the user’s Kasm sign-in, can click and type in every application in the session, read the screen and the page text, start and kill processes, run shell commands as the session user, and read and write files under the home directory and /tmp. Treat it like a login to the desktop. What the runtime can reach lists the limits.

Page Methods
Web pages dom.*: targets, listing, clicking, reading, filling, waiting, uploads, dialogs
Desktop applications a11y.*, windows.*, apps.*
Screen and input screen.*, input.*, clipboard.*
Files, processes and the shell file.get, directory.get, downloads.*, proc.*, launch, shell, wait_while
Asking a person human.ask
Recipes recipes.index, recipes.describe, recipes.guide, recipes.run

MCP methods has every parameter and result.

  • Calls run one at a time on every route. A second call waits for the first. Waiting methods such as windows.wait and screen.wait hold the desktop while they wait.
  • Every call is one row in the run’s report, and appears in the sidebar’s Activity tab as it runs. /events streams the same record and /artifacts/trace.jsonl serves it, both with the session token in the header.
  • An MCP client may show dotted names with underscores (apps_start for apps.start). The methods are the same.
  • The MCP initialize reply carries guidance for the model: reuse running applications, start installed ones with apps.start, prefer an installed desktop application to its website, and call recipes.index before driving an application by hand.
  • Coordinates are screen pixels. A caller that works from screenshots can ask for a fixed 1280 by 800 canvas with the X-Kasm-Runtime-Coordinates: agent header, and the runtime converts.

A failed method returns an MCP result with isError: true, or an HTTP error with a class.

Status Class Meaning
400, 404, 413 malformed Bad or missing parameters, no such method, or a body over 8 MiB. Nothing touched the session
422 resolution Something was not found, a wait timed out, or a capability is unavailable. Retry or try another way
500 environment The runtime itself is broken. Retrying does not help
503 shutting_down The runtime is stopping. The call did not run

Use your own agent or script when the decisions belong in code you already run, or when you want to add a Kasm desktop to an agent or test suite you have. If a person should work with an agent in the session, see Agent in your workspace. If the steps are known in advance and should run unattended, see Scenarios.