Skip to main content
Glama

ssh_session_open

Open a persistent SSH session for commands requiring shared state across multiple invocations. Supports exec, shell, and pty modes.

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 only after an idle or maximum-lifetime timeout (it is NOT bound to the certificate TTL).

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?

No annotations exist, but the description thoroughly discloses behavioral traits: session reuse, preflighting against policy, session lifecycle (must close, idle/max-lifetime timeout, not bound to certificate TTL), and policy restrictions on modes. This fully compensates for missing annotations.

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

Conciseness4/5

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

The description is a single paragraph but well-structured with clear sentences covering purpose, usage, modes, conditions, session lifecycle, and closing requirement. It is detailed without being overly verbose, though some information (like preflighting) could be slightly condensed.

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?

All critical aspects are covered: purpose, modes, conditions (sudo, pty), session lifecycle (close, timeout), policy revalidation, and return value (session_id). With output schema existing, the description is complete for an agent to correctly invoke the tool.

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?

Input schema has 100% coverage with descriptions for all 5 parameters. The description adds context beyond schema: e.g., explains what sudo does in different modes, clarifies that ttl_seconds can be omitted for maximum allowed, and reiterates conditionality for mode and sudo. This is valuable but not essential given schema completeness, so score 4.

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, contrasting with sibling tools like ssh_execute which are for isolated commands. It also explains the three modes (exec, shell, pty) and their appropriate use cases, making the purpose unambiguous.

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?

Explicit guidance is provided: use when needing shared state across commands, prefer ssh_execute for isolated commands. It also details when to use each mode, conditions for sudo (requires allow_sudo=true) and pty (requires allow_pty=true), and warns against retrying if conditions aren't met.

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