Skip to main content
Glama
balloonf
by balloonf

ssh_execute

Execute commands on remote systems via established SSH sessions, managing inputs and timeouts for efficient remote task execution through the SSH MCP Server interface.

Instructions

SSH 세션에서 명령 실행

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYes
session_idYes
timeoutNo

Implementation Reference

  • main.py:245-267 (handler)
    The handler function for the 'ssh_execute' MCP tool. It is registered via @mcp.tool() decorator and handles executing commands on an existing SSH session, formatting and returning the output.
    @mcp.tool()
    async def ssh_execute(session_id: str, command: str, timeout: int = 30) -> str:
        """SSH 세션에서 명령 실행"""
        try:
            result = await ssh_manager.execute_command(session_id, command, timeout)
            
            output = []
            output.append(f"Session: {session_id}")
            output.append(f"Command: {command}")
            output.append(f"Exit Status: {result['exit_status']}")
            
            if result['stdout']:
                output.append("STDOUT:")
                output.append(result['stdout'])
            
            if result['stderr']:
                output.append("STDERR:")
                output.append(result['stderr'])
            
            return "\n".join(output)
            
        except Exception as e:
            return f"Command execution failed: {str(e)}"
  • Supporting method in SSHSessionManager class that performs the core SSH command execution using asyncssh, handles timeouts, updates session metadata, and returns structured results.
    async def execute_command(self, session_id: str, command: str, 
                            timeout: int = 30) -> Dict[str, Any]:
        """세션에서 명령 실행"""
        
        if session_id not in self.connections:
            raise Exception(f"Session '{session_id}' not found")
        
        conn = self.connections[session_id]
        metadata = self.session_metadata[session_id]
        
        try:
            # 명령 실행
            result = await asyncio.wait_for(
                conn.run(command, check=False),
                timeout=timeout
            )
            
            # 메타데이터 업데이트
            metadata['last_used'] = time.time()
            metadata['command_count'] += 1
            
            return {
                'session_id': session_id,
                'command': command,
                'stdout': result.stdout,
                'stderr': result.stderr,
                'exit_status': result.exit_status,
                'execution_time': time.time()
            }
            
        except asyncio.TimeoutError:
            raise Exception(f"Command timeout after {timeout} seconds")
        except Exception as e:
            logger.error(f"Command execution failed in session {session_id}: {e}")
            raise Exception(f"Command execution failed: {str(e)}")
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions execution but doesn't disclose critical traits like whether it's read-only/destructive, authentication needs, error handling, or output format (e.g., stdout/stderr). This is inadequate for a command execution tool.

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 a single, efficient sentence in Korean with no wasted words. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration.

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

Completeness2/5

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

Given the tool's complexity (executing commands over SSH), lack of annotations, no output schema, and 0% schema coverage, the description is insufficient. It doesn't cover behavioral aspects, parameter meanings, or output expectations, leaving significant gaps for an AI agent.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate but adds no parameter details. It doesn't explain what 'session_id' refers to (e.g., from ssh_connect), what 'command' entails, or 'timeout' implications. The description fails to provide meaningful context beyond the schema.

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

Purpose4/5

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

The description 'SSH 세션에서 명령 실행' clearly states the action (execute command) and resource (SSH session) in Korean, which translates to 'Execute command in SSH session'. It's specific about what the tool does, though it doesn't explicitly differentiate from siblings like ssh_connect or ssh_session_info.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an active SSH session via ssh_connect first) or contrast with siblings like ssh_list_sessions. Usage is implied but not explicitly stated.

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

Related 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/balloonf/ssh_mcp'

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