Your agent or script
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.
With the Kasm toolkit
Section titled “With the Kasm toolkit”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.
One method set, three ways in
Section titled “One method set, three ways in”| 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.
Reaching the runtime
Section titled “Reaching the runtime”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.
What a token holder can do
Section titled “What a token holder can do”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.
What the methods cover
Section titled “What the methods cover”| 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.
How a session behaves
Section titled “How a session behaves”- Calls run one at a time on every route. A second call waits for the first. Waiting methods such as
windows.waitandscreen.waithold 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.
/eventsstreams the same record and/artifacts/trace.jsonlserves it, both with the session token in the header. - An MCP client may show dotted names with underscores (
apps_startforapps.start). The methods are the same. - The MCP
initializereply carries guidance for the model: reuse running applications, start installed ones withapps.start, prefer an installed desktop application to its website, and callrecipes.indexbefore 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: agentheader, and the runtime converts.
Errors
Section titled “Errors”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 |
Choosing between this and the other ways
Section titled “Choosing between this and the other ways”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.