Skip to main content
Glama

ssh_session_open

Open a persistent SSH session to run multiple commands with shared state or interactive programs. Returns a session ID for use with ssh_session_exec; close with ssh_session_close when done.

Instructions

Open a persistent SSH session that reuses the connection across commands. Use when you need multiple commands with shared state (e.g. cd to a directory and then operate in it) or interactive programs. For isolated commands prefer ssh_execute (simpler, stronger isolation guarantee). Available modes: exec (default, independent commands), shell (stateful sh: cd and variables persist), pty (shell with TTY for interactive programs). sudo=true ONLY if allow_sudo=true (see ssh_list_servers); if allow_sudo=false DO NOT retry. mode=pty ONLY if allow_pty=true. Every ssh_session_exec is preflighted against the current signer policy, so policy reloads revalidate target and bastion access, end-user groups, sudo, sudo_user, PTY, and the host's physical route for already-open sessions. On command-policy hosts, mode=exec is allowed; mode=shell and mode=pty are rejected. Returns session_id for use with ssh_session_exec. IMPORTANT: always close the session with ssh_session_close when done; an open session holds an SSH connection and is otherwise closed when the certificate that opened it expires, or after an idle or maximum-lifetime timeout (whichever comes first).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNoexec (default): isolated commands with no shared state. shell: persistent sh, cd and environment variables survive across ssh_session_exec calls. pty: shell with pseudo-terminal for interactive programs (editors, less, etc.); requires allow_pty=true. If allow_pty=false DO NOT use pty.
sudoNoif true, start with sudo -n elevation (NOPASSWD). In mode=shell/pty elevates the whole shell process. In mode=exec prepends sudo to each individual command. Requires allow_sudo=true in ssh_list_servers. If allow_sudo=false DO NOT retry.
serverYeslogical name of the target host (see ssh_list_servers)
sudo_userNotarget user for sudo (empty = root). Must be in the host's allowed_sudo_users list.
ttl_secondsNoconnection certificate validity in seconds; omit to use the maximum allowed by the host policy

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
serialYes
session_idYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It discloses session reuse, mode distinctions (exec/shell/pty), sudo behavior per mode, policy preflighting for open sessions, session closure and lifecycle timeouts, and the explicit need to close the session. This is comprehensive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is dense but every sentence contributes unique information. It front-loads the core purpose, then layered constraints, and ends with a critical closing instruction. No fluff; each clause earns its place given the complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (persistent sessions, multiple modes, policy checks, lifecycle), the description covers all essential aspects: when to use, mode differences, sudo/pty prerequisites, policy revalidation, return value (session_id), and closing requirement. The output schema exists, so return value details are adequately handled.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% coverage with detailed parameter descriptions, so baseline is 3. The description adds value by explaining mode semantics (state persistence, TTY for interactive programs) and sudo elevation behavior per mode, plus constraints tied to allow_sudo/allow_pty, which enriches the schema's meaning.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool opens a persistent SSH session that reuses connections, with specific use cases for shared state or interactive programs. It explicitly distinguishes from the sibling ssh_execute by recommending it for isolated commands, providing clear differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit when-to-use guidance: multiple commands with shared state (e.g., cd then operate) or interactive programs. It names the alternative (ssh_execute) and explains why to prefer it for isolated commands, and also covers constraints like sudo and pty prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/luisgf/infrabroker'

If you have feedback or need assistance with the MCP directory API, please join our Discord server