Skip to main content
Glama
kunwarmahen

SSH Read-Only MCP Server

by kunwarmahen

ssh_disconnect

Disconnect from a remote machine via SSH by providing host, username, and optional port. Securely closes the active session established through the read-only SSH MCP server.

Instructions

Disconnect from the remote machine.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostYesRemote host
usernameYesSSH username
portNoSSH port (default: 22)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The ssh_disconnect tool handler function. Uses @mcp.tool() decorator, accepts host/username/port params, looks up the connection in the global ssh_clients dict, closes the paramiko SSH client, deletes the entry, and returns a status message.
    @mcp.tool()
    def ssh_disconnect(
        host: str,
        username: str,
        port: int = 22
    ) -> str:
        """
        Disconnect from the remote machine.
        
        Args:
            host: Remote host
            username: SSH username
            port: SSH port (default: 22)
        
        Returns:
            Disconnection status message
        """
        connection_id = f"{username}@{host}:{port}"
        
        if connection_id in ssh_clients:
            try:
                ssh_clients[connection_id]['client'].close()
                del ssh_clients[connection_id]
                return f"Successfully disconnected from {connection_id}"
            except Exception as e:
                return f"Disconnection error: {str(e)}"
        else:
            return f"Not connected to {connection_id}"
  • The @mcp.tool() decorator on line 152 registers ssh_disconnect as a FastMCP tool.
    @mcp.tool()
  • Duplicate implementation of ssh_disconnect in the multicast variant of the server. Same logic - closes the paramiko client and removes it from the global ssh_clients dict.
    @mcp.tool()
    def ssh_disconnect(
        host: str,
        username: str,
        port: int = 22
    ) -> str:
        """
        Disconnect from the remote machine.
        
        Args:
            host: Remote host
            username: SSH username
            port: SSH port (default: 22)
        
        Returns:
            Disconnection status message
        """
        connection_id = f"{username}@{host}:{port}"
        
        if connection_id in ssh_clients:
            try:
                ssh_clients[connection_id]['client'].close()
                del ssh_clients[connection_id]
                return f"Successfully disconnected from {connection_id}"
            except Exception as e:
                return f"Disconnection error: {str(e)}"
        else:
            return f"Not connected to {connection_id}"
  • The @mcp.tool() decorator on line 266 registers ssh_disconnect in the multicast server variant.
    @mcp.tool()
Behavior2/5

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

No annotations provided, and the description doesn't disclose side effects (e.g., closing a terminal session), error conditions, or security implications. The behavioral burden is not met.

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

Conciseness3/5

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

Very concise (one sentence) but lacks essential context. Could be improved by front-loading usage context without being verbose.

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?

Does not mention output schema return value, error scenarios, or how the host/username map to an existing connection. Incomplete given the presence of an output schema and sibling tools.

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

Parameters3/5

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

Schema description coverage is 100%, so parameters are already explained. Description adds no additional meaning 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?

Description clearly states the action (disconnect) and target (remote machine), distinguishing from siblings like ssh_connect. However, it doesn't specify which connection is being disconnected (e.g., by host/username).

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?

No guidance on when to use this tool vs alternatives. Does not mention prerequisites (e.g., active connection) or when not to use it.

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/kunwarmahen/ssh-mcp-server'

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