Skip to main content
Glama

ssh_disconnect

Close active SSH connections in the SSH MCP server by specifying the connection ID to terminate remote sessions.

Instructions

Close an SSH connection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesID of an active SSH connection

Implementation Reference

  • The main handler function that executes the ssh_disconnect tool. It validates the connectionId, closes the SSH connection with conn.end(), removes it from the connections map, and returns a success or error message.
    private async handleSSHDisconnect(params: any) {
      const { connectionId } = params;
      
      // Check if the connection exists
      if (!this.connections.has(connectionId)) {
        return {
          content: [{ type: "text", text: `No active SSH connection with ID: ${connectionId}` }],
          isError: true
        };
      }
      
      const { conn, config } = this.connections.get(connectionId)!;
      
      try {
        // Close the connection
        conn.end();
        this.connections.delete(connectionId);
        
        return {
          content: [{ type: "text", text: `Disconnected from ${config.username}@${config.host}:${config.port}` }]
        };
      } catch (error: any) {
        return {
          content: [{ type: "text", text: `Failed to disconnect: ${error.message}` }],
          isError: true
        };
      }
    }
  • The input schema definition for the ssh_disconnect tool, declared in the server's capabilities during initialization.
    ssh_disconnect: {
      description: "Close an SSH connection",
      inputSchema: {
        type: "object",
        properties: {
          connectionId: {
            type: "string",
            description: "ID of an active SSH connection"
          }
        },
        required: ["connectionId"]
      }
    }
  • src/index.ts:286-287 (registration)
    Registration of the ssh_disconnect tool handler in the switch statement within the CallToolRequestSchema handler.
    case 'ssh_disconnect':
      return this.handleSSHDisconnect(request.params.arguments);
  • The tool schema returned by the ListToolsRequestSchema handler, including name, description, and inputSchema.
    {
      name: 'ssh_disconnect',
      description: 'Close an SSH connection',
      inputSchema: {
        type: 'object',
        properties: {
          connectionId: { type: 'string', description: 'ID of an active SSH connection' }
        },
        required: ['connectionId']
      }
  • src/index.ts:184-267 (registration)
    The ListToolsRequestSchema handler registration which includes ssh_disconnect in the list of available tools.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: 'ssh_connect',
          description: 'Connect to a remote server via SSH',
          inputSchema: {
            type: 'object',
            properties: {
              host: { type: 'string', description: 'Hostname or IP address of the remote server' },
              port: { type: 'number', description: 'SSH port (default: 22)' },
              username: { type: 'string', description: 'SSH username' },
              password: { type: 'string', description: 'SSH password (if not using key-based authentication)' },
              privateKeyPath: { type: 'string', description: 'Path to private key file (if using key-based authentication)' },
              passphrase: { type: 'string', description: 'Passphrase for private key (if needed)' },
              connectionId: { type: 'string', description: 'Unique identifier for this connection' }
            },
            required: ['host', 'username']
          }
        },
        {
          name: 'ssh_exec',
          description: 'Execute a command on the remote server',
          inputSchema: {
            type: 'object',
            properties: {
              connectionId: { type: 'string', description: 'ID of an active SSH connection' },
              command: { type: 'string', description: 'Command to execute' },
              cwd: { type: 'string', description: 'Working directory for the command' },
              timeout: { type: 'number', description: 'Command timeout in milliseconds' }
            },
            required: ['connectionId', 'command']
          }
        },
        {
          name: 'ssh_upload_file',
          description: 'Upload a file to the remote server',
          inputSchema: {
            type: 'object',
            properties: {
              connectionId: { type: 'string', description: 'ID of an active SSH connection' },
              localPath: { type: 'string', description: 'Path to the local file' },
              remotePath: { type: 'string', description: 'Path where the file should be saved on the remote server' }
            },
            required: ['connectionId', 'localPath', 'remotePath']
          }
        },
        {
          name: 'ssh_download_file',
          description: 'Download a file from the remote server',
          inputSchema: {
            type: 'object',
            properties: {
              connectionId: { type: 'string', description: 'ID of an active SSH connection' },
              remotePath: { type: 'string', description: 'Path to the file on the remote server' },
              localPath: { type: 'string', description: 'Path where the file should be saved locally' }
            },
            required: ['connectionId', 'remotePath', 'localPath']
          }
        },
        {
          name: 'ssh_list_files',
          description: 'List files in a directory on the remote server',
          inputSchema: {
            type: 'object',
            properties: {
              connectionId: { type: 'string', description: 'ID of an active SSH connection' },
              remotePath: { type: 'string', description: 'Path to the directory on the remote server' }
            },
            required: ['connectionId', 'remotePath']
          }
        },
        {
          name: 'ssh_disconnect',
          description: 'Close an SSH connection',
          inputSchema: {
            type: 'object',
            properties: {
              connectionId: { type: 'string', description: 'ID of an active SSH connection' }
            },
            required: ['connectionId']
          }
        }
      ]
    }));
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action (close) but doesn't describe effects (e.g., terminates session, frees resources), side effects, error conditions, or permissions required. This is a mutation tool with minimal behavioral context.

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 with zero wasted words. It's appropriately sized for a simple tool and front-loads the core action. Every word earns its place.

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?

For a mutation tool with no annotations and no output schema, the description is inadequate. It doesn't explain what happens after closing (success/failure states, return values), error handling, or dependencies on active connections. Given the complexity and lack of structured data, more context is needed.

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% (connectionId parameter fully documented in schema). The description adds no parameter-specific details beyond what the schema provides. Baseline 3 is appropriate when the schema does the heavy lifting.

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 'Close an SSH connection' clearly states the action (close) and resource (SSH connection). It distinguishes from siblings like ssh_connect (open) and ssh_exec (run commands), but doesn't explicitly mention this differentiation. The purpose is specific and unambiguous.

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 connection), exclusions, or relationships with sibling tools like ssh_connect. Usage context is implied but not 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

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/mixelpixx/SSH-MCP'

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