Work Session tools

A Work Session is the approval-gated unit that scopes infrastructure-mutating MCP actions to an auditable record. MCP OAuth/browser callers need an active, approved Work Session for command and REST file-transfer creation. From December 1, 2026 (00:00 UTC), the same requirement applies to personal API tokens that still have command-execution or file-transfer scopes (see Token restrictions). Service tokens retain their endpoint-specific authorization rules. These tools cover the full session lifecycle—create, inspect, update, extend, and close—plus the AI-based security analysis that runs on completed sessions. They back requests like “start a session so I can restart nginx on prod-web-1” or “show me what happened in that session yesterday.”

An AI agent cannot approve or reject a Work Session; only a person can. When a session is created it commonly lands in pending and needs a human to approve it out-of-band, in the Alpacon web console or via Slack; a Work Session update can also be queued as a modification request that needs the same kind of approval. In both cases the affected tool returns a structured pending-approval result instead of failing outright—surface it to a human, then retry once approved.

Tools elsewhere that accept a work_session_id argument, such as execute_command, fall back to the ALPACON_WORK_SESSION environment variable when the argument is omitted; an explicit argument always wins.

For the equivalent CLI workflow, see alpacon work-session. For the underlying concept, see the Work Sessions overview.

Note

All tools accept workspace (required) and region (optional, defaults to the configured region). These common parameters are omitted from the tables below.

Summary

ToolDescriptionAccess
work_session_createCreate a Work Session scoping infrastructure actions to an auditable, approval-gated sessionAdditive
work_session_getGet a Work Session’s status, scopes, servers, requester type, and expiryRead-only
work_session_listList Work Sessions, optionally filtered by status or requester typeRead-only
work_session_updatePartially update a Work Session’s title, description, scopes, servers, or expiryIdempotent write
work_session_extendExtend the expiry of an approved or active Work SessionIdempotent write
work_session_timelineGet the unified chronological timeline of a Work SessionRead-only
work_session_recordsRead one page of a Websh session’s terminal recording captured in a Work SessionRead-only
work_session_analyzeManually trigger AI security analysis for a terminal Work SessionIdempotent write
work_session_closeMark a Work Session as completed and trigger AI security analysisDestructive

Creating and viewing

work_session_create

Creates a Work Session that scopes subsequent infrastructure actions to an auditable, approval-gated record. description should say what the work is and why—a vague one-liner like “maintenance” is hard for a human to approve; Markdown is supported. scopes declares which operations the session allows: command (execute_command, execute_file), webftp (file transfers), tunnel (port forwarding), or sudo (privilege elevation). servers lists the target server UUIDs. To run commands as an account other than the default, such as root, name it in target_account_username so it is approved with the session, then pass the same account as username to execute_command and execute_file. Running directly as root is declared here; the sudo scope is for elevating from another account.

A session created this way commonly lands in pending—it needs human approval before any scoped action runs. When that happens, the tool returns a structured pending-approval result instead of the raw session object; poll work_session_get and wait for active status before proceeding.

Access: Additive

Parameters

ParameterTypeRequiredDescription
scopesarrayYesOperations this session allows: command, webftp, tunnel, sudo
serversarrayYesTarget server UUIDs
expires_atstringYesISO 8601 datetime the session expires at
descriptionstringYesWhat the work is and why. Markdown supported
titlestringNoShort session title
target_account_usernamestringNoThe one OS account the session’s commands run as, such as root. Omit it to run as the default account

Example

“Start a work session to restart nginx on prod-web-1, command access only, expiring in 2 hours”

The agent calls work_session_create with scopes=["command"], servers set to prod-web-1’s UUID, and a descriptive description, then waits for human approval before running the restart.

work_session_get

Gets the current status, scopes, servers, requester type, and expiry of a Work Session. Use this to check whether a session created or updated by work_session_create / work_session_update has moved past pending into active.

Access: Read-only

Parameters

ParameterTypeRequiredDescription
session_idstringYesWork Session ID

Example

“Is my work session active yet?”

The agent calls work_session_get with the session ID and reports its current status.

work_session_list

Lists Work Sessions in the workspace. Filter by status (pending, approved, active, completed, rejected, cancelled, expired, revoked) or by requester_type (user for human-requested sessions, agent for AI-requested sessions).

Access: Read-only

Parameters

ParameterTypeRequiredDescription
statusstringNoFilter by session status
requester_typestringNoFilter by user or agent
limitintegerNoMaximum number of results to return (default: 20)

Example

“Show me all pending work sessions opened by agents”

The agent calls work_session_list with status="pending" and requester_type="agent".

Target visibility in responses

The session returned by work_session_get, and each session in work_session_list, follows the API’s target visibility rules:

FieldMeaning
servers, clustersOnly targets within the caller’s read access; omitted targets disclose neither IDs nor names
servers_hidden, clusters_hiddenNon-negative integer counts of targets omitted from the respective lists; 0 means none were withheld

An empty servers list with servers_hidden: 2 means two target servers were withheld. It does not mean the session has no servers. Preserve and report these counts when summarizing results; do not invent names or treat the returned list as the complete target set when a count is positive.

A caller who can manage the session receives all target details. For that caller, servers_hidden: 0 and clusters_hidden: 0. A person authorized to approve or reject the session’s pending approval request can also see all target details. Read access to an approval request alone does not reveal all targets. MCP still cannot approve or reject a session.

When any count in a result is above 0, work_session_get and work_session_list also return hidden_targets_note, a top-level string beside data. It names each count, including those nested in the session (old_hidden and new_hidden in adjustments.servers, and servers_hidden in pending_modification_request.changes and account_flag), and says the returned list is not the session’s whole target set. For a list, it names each session that has a count by its ID. The MCP server builds the note from the counts the API returns and leaves data unchanged; Alpacon Server 2.48.0 and later provide the counts. With one of these server versions, an MCP release from before the note still returns the counts in data.

work_session_timeline

Gets the unified, chronological timeline of a Work Session: commands, file transfers, Websh activity, and sudo grants in execution order, oldest first. The tool reads the timeline by cursor, following up to 10 pages per call and merging them, and reports in a pagination object whether it reached the end of the session. Check pagination.complete before treating the result as the whole timeline; if the call stopped at its bound, pass pagination.next_cursor back as cursor to continue. A resumed call contains only entries after its cursor, so it never reports complete on its own; stopped_because: end_of_list means it read to the end. The walk only reads forward, so a result that stopped early holds the start of the session and omits its most recent activity.

The timeline carries no Websh terminal recordings. It lists each Websh session as a websh_session item, and the id of that item is what work_session_records takes to read the recording. The include_records parameter is refused with a validation error for any value; omit it.

Access: Read-only

Parameters

ParameterTypeRequiredDescription
session_idstringYesWork Session ID
cursorstringNoThe pagination.next_cursor of a previous call, to resume where it stopped
page_sizeintegerNoItems per request, 1 to 500 (server default: 100). A larger value is refused
include_recordsbooleanNoOmit it. Any value is refused with a validation error that points to work_session_records

Example

“What happened in that work session, in order?”

The agent calls work_session_timeline with the session ID and walks through the returned activity in execution order.

work_session_records

Reads one page of a Websh terminal recording captured inside a Work Session: the terminal output in chunks, oldest first, as {added_at, record} items. Call work_session_timeline first and pass the id of one of its websh_session items as websh_session_id. The Websh session must belong to this Work Session and must not be a tunnel, which records no terminal.

One call reads one page and never pages on by itself. The response is the server’s page as it answered it, count, next, previous, and results. Pass next back as cursor to read the following page, and stop when next is null. A page is also cut by a byte budget, so a page with fewer items than page_size is not the end of the recording; only a null next is. A cursor belongs to the Websh session it came from, so keep the same websh_session_id while paging one recording.

Note

Reading a recording is a paid-plan feature. A Free workspace, and a session older than the plan’s audit window, is answered with a 402 plan-limit error.

Access: Read-only

Parameters

ParameterTypeRequiredDescription
session_idstringYesWork Session ID
websh_session_idstringYesThe id of a websh_session item on the Work Session’s timeline
cursorstringNoThe next value of the previous page. Omit it to start at the beginning of the recording
page_sizeintegerNoChunks per page, 1 to 16 (default: 8). A value outside that range is refused

Example

“Show me what was typed and printed in the terminal during that work session”

The agent reads the timeline with work_session_timeline, takes the id of the websh_session item, and calls work_session_records with it, passing next back as cursor until next is null.

Modifying

work_session_update

Partially updates a Work Session—only the fields you provide are sent, and passing an empty string clears a text field such as title. A pending session updates immediately. An approved or active session goes through the modification flow instead: when the server queues the change for approval, this tool returns a status="pending_approval" result, and the update only takes effect once a human approves it out-of-band.

expires_at is only honored for pending sessions; for approved or active sessions it is ignored, so use work_session_extend instead. A terminal session (completed, rejected, cancelled, expired, revoked) cannot be updated.

servers replaces the entire target server list. Read the session with the same caller, then send every server you want to keep along with any additions. A caller permitted to update the session is shown every existing target, with servers_hidden: 0, so this replacement does not silently remove a server hidden from that writer. A filtered list read by someone else is not a safe replacement list. Omit servers when you are not changing targets; hidden counts are read-only response fields.

Access: Idempotent write

Parameters

ParameterTypeRequiredDescription
session_idstringYesWork Session ID
titlestringNoNew title. Pass "" to clear
descriptionstringNoNew description. Pass "" to clear
scopesarrayNoReplacement list of allowed operations
serversarrayNoReplacement list of target server UUIDs
expires_atstringNoNew expiry. Only honored while the session is pending

Example

“Add db-02 to my active work session’s server list”

The agent calls work_session_update with servers set to the expanded list. Since the session is active, the change is queued as a modification request pending human approval.

work_session_extend

Extends the expiry of an approved or active Work Session. The new expires_at must be later than the current expiry. Sudo policies that end with the session, or have no end, follow the new deadline; a policy with its own end keeps it. Whether the extension applies at once follows the workspace’s approval policy.

When the session has a live sudo policy where the session approval takes the place of MFA, an extension from MCP, the CLI, an API token, or a service token waits for a person’s approval in an Enforce workspace. In an Advisory workspace it is refused: MCP returns error_code="work_session_sudo_bypass_console_only" and status_code=403, with the generic 403 recovery hints. Extend in the web console instead; the console bypasses this sudo-specific hold or refusal. The workspace’s usual extension approval policy still applies.

When an extension waits for approval, the tool returns status="pending_approval" and the session keeps its current expiry until a person decides; poll work_session_get until expires_at changes.

Access: Idempotent write

Parameters

ParameterTypeRequiredDescription
session_idstringYesWork Session ID
expires_atstringYesNew ISO 8601 datetime, later than the current expiry
reasonstringYesWhy more time is needed, in a short sentence. Shown to the approver when the extension needs a decision

Example

“Extend my work session by another hour—the database migration is still running”

The agent calls work_session_extend with expires_at set to the new expiry time and reason="Database migration still running".

Analysis and closing

work_session_analyze

Manually triggers AI security analysis for a terminal Work Session (completed, expired, or revoked—rejected and cancelled sessions never activated, so there’s nothing to analyze). Analysis normally runs automatically when a session is closed with work_session_close; use this tool to re-run one that failed. Set force=true to retry an analysis stuck in pending or processing—the server still enforces a minimum age guard and never discards a completed result.

Access: Idempotent write

Parameters

ParameterTypeRequiredDescription
session_idstringYesWork Session ID
forcebooleanNoRetry an analysis stuck in pending or processing (default: false)

Example

“That session’s security analysis failed—try it again”

The agent calls work_session_analyze with force=true to retry the stuck analysis.

work_session_close

Marks a Work Session as completed and triggers AI security analysis (Pass 1–4). Call this after all commands and file transfers for the session are done.

Access: Destructive

Parameters

ParameterTypeRequiredDescription
session_idstringYesWork Session ID

Example

“I’m done with the nginx fix, close the work session”

The agent calls work_session_close with the session ID, ending the session and kicking off its AI security analysis.

Last updated: