Skip to main content
Glama

Run a Command in a Container Instance

run_instance_command
Destructive

Run a shell command inside a running container instance on Cycle, over the instance's SSH gateway, and return the shell output. Use this for one-time setup that must run inside a container — e.g. initializing a MongoDB replica set with 'mongosh --eval "rs.initiate({...})"'.

The instance must be RUNNING (start the container first). If the container has multiple instances, pass 'instance' (id or hostname); otherwise the sole instance is used. Containers reach each other by hostname over the environment's private network, so commands can reference sibling containers (e.g. mongo-1:27017).

This executes an arbitrary command inside your container — it is powerful and mutating. Always call with preview:true first: it echoes back the exact command and target without making any connection, so the user can confirm it is what they intend (nothing is validated — the command may still fail when run). Confirm with the user, then call again without preview. Never run a command without explicit confirmation.

Short-lived SSH credentials are generated for the run and expired immediately after. The command runs in an interactive shell; make destructive commands idempotent where possible.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesShell command to run inside the instance, e.g. mongosh --quiet --eval 'rs.initiate({...})'.
contextNoWhy are you calling this tool? Briefly describe the user's goal.
previewNoWhen true, echo the target + command and make NO connection. Use it to confirm intent with the user. Always run this first.
instanceNoInstance id or hostname. Optional when the container has a single instance.
containerYesContainer to run in.
environmentYesEnvironment the container lives in.
conversation_idNoConversation tracking id. Omit on your first tool call; every result then includes a conversation_id line — pass that exact value on all later calls in this conversation.
timeout_secondsNoMax seconds to wait for the command, 1-60 (default 60). 60 is the ceiling because a longer block dies at the MCP transport before this tool can report; a command that outlasts it keeps running in the container.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.9/5.0
Behavior5/5

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

Annotations flag destructive/openWorld/non-idempotent, and the description adds substantial context beyond them: the preview echo makes no connection and validates nothing, short-lived SSH credentials are generated and expired immediately, the command keeps running after the 60s transport cutoff, and destructive commands should be made idempotent.

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?

Purpose is front-loaded in the first sentence, followed by prerequisites, networking context, the safety workflow, and credential lifecycle — each paragraph earns its place with no filler. Preview is reinforced but that reinforcement is warranted for a destructive tool.

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?

With no output schema, the description still names the return value (shell output) and the timeout behavior (command outlasts the wait). Given the 8-param, destructive, open-world nature of the tool, nothing an agent needs to invoke it correctly is missing.

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 100%, so the baseline is 3. The description still adds meaning: it explains instance selection logic, why timeout is capped at 60s (MCP transport dies first), and the confirmation semantics of 'preview', going beyond the schema's own text.

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?

States a specific verb and resource ('Run a shell command inside a running container instance') with the transport mechanism (SSH gateway) and return value ('return the shell output'). The container-instance target clearly distinguishes it from the sibling run_vm_command.

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?

Gives explicit when-to-use ('one-time setup that must run inside a container'), prerequisites ('instance must be RUNNING — start the container first'), a multi-instance rule for the optional 'instance' param, and a mandatory workflow (always call preview:true first, confirm with the user, then re-call without preview).

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources