Skip to main content
Glama
balloonf
by balloonf

ssh_connect

Establish and manage SSH connections by creating new sessions with specified host, username, password, and port. Ideal for remote server access and command execution through the SSH MCP Server.

Instructions

SSH 서버에 연결하여 새 세션 생성

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostYes
passwordYes
portNo
session_nameNo
usernameYes

Implementation Reference

  • main.py:229-243 (handler)
    The main handler function for the 'ssh_connect' MCP tool. Decorated with @mcp.tool() for automatic registration. Creates an SSH session via SSHSessionManager and returns the session ID or error.
    @mcp.tool()
    async def ssh_connect(host: str, username: str, password: str, 
                         port: int = 22, session_name: str = None) -> str:
        """SSH 서버에 연결하여 새 세션 생성"""
        try:
            session_id = await ssh_manager.create_session(
                host=host,
                username=username, 
                password=password,
                port=port,
                session_name=session_name
            )
            return f"SSH session created: {session_id}"
        except Exception as e:
            return f"Connection failed: {str(e)}"
  • main.py:26-70 (helper)
    Core implementation of SSH connection in SSHSessionManager.create_session(). Establishes asyncssh connection, manages session metadata, limits concurrent sessions, and starts monitoring task.
    async def create_session(self, host: str, username: str, password: str, 
                           port: int = 22, session_name: Optional[str] = None) -> str:
        """새 SSH 세션 생성"""
        
        # 세션 수 제한 확인
        if len(self.connections) >= self.max_sessions:
            await self._cleanup_oldest_session()
        
        # 세션 ID 생성
        session_id = session_name or f"ssh_{uuid.uuid4().hex[:8]}"
        
        try:
            # SSH 연결 생성
            conn = await asyncssh.connect(
                host=host,
                port=port,
                username=username,
                password=password,
                known_hosts=None,  # 개발용 - 운영에서는 적절한 호스트 키 검증 필요
                client_keys=None,
                passphrase=None
            )
            
            # 세션 저장
            self.connections[session_id] = conn
            self.session_metadata[session_id] = {
                'host': host,
                'port': port,
                'username': username,
                'created_at': time.time(),
                'last_used': time.time(),
                'command_count': 0
            }
            
            # 연결 모니터링 태스크 시작
            self.connection_tasks[session_id] = asyncio.create_task(
                self._monitor_session(session_id)
            )
            
            logger.info(f"SSH session created: {session_id} -> {username}@{host}:{port}")
            return session_id
            
        except Exception as e:
            logger.error(f"Failed to create SSH session: {e}")
            raise Exception(f"SSH connection failed: {str(e)}")
  • main.py:229-229 (registration)
    The @mcp.tool() decorator registers the ssh_connect function as an MCP tool in FastMCP.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool creates a new SSH session, implying a network operation that may involve authentication and session management, but lacks details on critical behaviors such as error handling (e.g., connection failures), security implications (e.g., password transmission), session persistence, or rate limits. This is inadequate for a tool with potential side effects.

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 that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action, making it easy to parse, and every part contributes essential information, earning a top score for brevity and clarity.

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 complexity of SSH operations (involving network connectivity, authentication, and session management), no annotations, no output schema, and low parameter coverage, the description is incomplete. It fails to address key aspects like return values (e.g., session ID or status), error conditions, or behavioral nuances, making it insufficient for safe and effective use by 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 by explaining parameters, but it adds no semantic information beyond what the schema provides. The schema lists host, password, port, session_name, and username with basic types, but the description doesn't clarify their roles (e.g., host as IP/domain, password for authentication, port defaulting to 22, session_name for identification), leaving parameters largely unexplained.

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 clearly states the action ('SSH 서버에 연결하여 새 세션 생성' translates to 'Connect to SSH server to create new session'), specifying the verb (connect), resource (SSH server), and outcome (new session). However, it doesn't explicitly differentiate from siblings like ssh_execute (which might execute commands) or ssh_list_sessions (which lists existing sessions), keeping it from a perfect score.

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 valid credentials), when not to use it (e.g., if a session already exists), or refer to sibling tools like ssh_execute for command execution or ssh_close_session for termination, leaving usage context vague.

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