Skip to main content
Glama
TMYTiMidlY

portal-mcp-server

by TMYTiMidlY

remote_shell

Run commands on one remote host in a persistent shell session so working directory, environment variables, and activated virtualenvs carry over between calls.

Instructions

Run a command (or a sequence) on ONE remote host in a persistent shell session: cwd and environment (cd / export / venv activation) survive across calls. Use it only when you need that continuity — otherwise remote_exec is faster (no session setup) and can target many hosts; for a long task to background and poll, use remote_job.

Pick one:

  • command="pytest" → {host, session_id, command, exit_code, output, duration_s}. ONE command per call is the preferred shape: the session PERSISTS across separate calls, so cwd / exports / venv from an earlier call still apply to the next — you keep step-by-step continuity AND get to read each step's real output before deciding the next.

  • commands=["cd /app","source .venv/bin/activate","pytest"] → runs the sequence in order in ONE call (same session). Reach for it ONLY for a fixed sequence you do NOT need to inspect between steps; you can't judge one step's output before the next runs. Returns {host, session_id, results:[…]}; stop_on_error=True (default) halts at the first failure and adds stopped_at.

Behavior:

  • bash or zsh; an unknown login shell falls back to bash (if bash is missing the call is refused — use remote_exec).

  • Output is the COMBINED stdout+stderr stream (use remote_exec when you need them split). Oversize output is capped and flagged truncated=true.

  • A command that wedges on an interactive prompt (sudo password, ssh first-connect, passphrase, …) is auto-aborted, returning exit_code -1 + error:"interactive_prompt_blocked" + session_preserved:true — cwd/env survive, so the next command runs straight away.

★ No sudo or secret injection here (both are one-shot by nature): to run as root use remote_exec(use_sudo=True); for a command needing a secret use remote_exec(secrets=[…]).

timeout (per command, seconds; REQUIRED — no default): the call is held open until the command exits or timeout elapses. Keepalive pings stop the client aborting a hung call, so timeout is your real cut-off — pass a SMALL one for an exploratory / re-runnable command (e.g. 10–30) to fail fast, raising it only for a genuinely slow but bounded command. Hard ceiling (PORTAL_MAX_TIMEOUT, default 300s): a request above it is refused — use remote_job for a long task.

⚠️ By convention, write operations should target /tmp/ on the remote unless the user approved another path (not enforced here).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostYes
commandNo
timeoutYes
commandsNo
stop_on_errorNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv4.0.3

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and discharges it: shell fallback (bash/zsh, refusal if bash missing), combined stdout+stderr, truncation flag, auto-abort of interactive prompts with exit_code -1 and session_preserved:true, no sudo/secret injection, and the hard PORTAL_MAX_TIMEOUT ceiling. It also discloses the /tmp write convention that is not enforced.

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?

Front-loaded and sectioned (Pick one / Behavior / timeout / warning), and almost every sentence earns its place. However, session persistence is explained twice and the markdown bolding/emoji adds some bulk, so it is slightly longer than strictly needed.

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

Completeness4/5

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

Given the complexity (persistent sessions, two modes, mandatory timeout) and that an output schema exists, coverage is nearly complete. The one real omission is session lifecycle: session_id appears only in return shapes, and nothing says how a session is created, reused, or torn down via the sibling remote_close.

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?

Schema coverage is 0%, so the description must compensate, and it does for command, commands, stop_on_error (default true, halts at first failure and adds stopped_at) and timeout (required, no default, keepalive rationale, ceiling). The required 'host' parameter gets no format guidance (hostname vs alias from the hosts sibling) and session_id is only ever an output, never explained as an input, leaving a gap on 1 of 5 parameters.

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?

Opens with a specific verb+resource+scope: 'Run a command (or a sequence) on ONE remote host in a persistent shell session.' It immediately names the two siblings it is not (remote_exec for one-shot/multi-host, remote_job for backgrounded long tasks), so an agent can route without opening any schema.

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 routing rules: use this 'only when you need that continuity,' otherwise remote_exec is faster, and remote_job for long backgrounded work. It further splits the two invocation modes (command vs commands) and states exactly when each applies, including the caveat that sequences cannot be inspected between steps.

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