Skip to main content
Glama

ssh_tunnel_close

Close SSH tunnels to terminate secure remote connections and free up network resources in the MCP SSH Manager.

Instructions

Close an SSH tunnel

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tunnelIdNoTunnel ID to close
serverNoClose all tunnels for this server

Implementation Reference

  • Main execution handler for ssh_tunnel_close tool. Accepts tunnelId parameter, retrieves the tunnel instance from the active tunnels map, calls its close() method if found, and returns true on success.
    export function closeTunnel(tunnelId) { const tunnel = tunnels.get(tunnelId); if (!tunnel) { throw new Error(`Tunnel ${tunnelId} not found`); } tunnel.close(); return true; }
  • Core close logic in SSHTunnel class. Sets state to CLOSED, closes all connections and server socket, handles remote forwarding cleanup, and removes from active tunnels map.
    close() { logger.info(`Closing tunnel ${this.id}`); this.state = TUNNEL_STATES.CLOSED; // Close all active connections for (const conn of this.connections) { conn.destroy(); } this.connections.clear(); // Close server if (this.server) { this.server.close(); this.server = null; } // Cancel remote forwarding if needed if (this.type === TUNNEL_TYPES.REMOTE) { this.ssh.unforwardIn(this.config.remoteHost, this.config.remotePort); } tunnels.delete(this.id); }
  • ssh_tunnel_close is registered in the 'advanced' tool group (line 67) for conditional enabling/disabling via tool configuration manager.
    'ssh_deploy', 'ssh_execute_sudo', 'ssh_alias', 'ssh_command_alias', 'ssh_hooks', 'ssh_profile', 'ssh_connection_status', 'ssh_tunnel_create', 'ssh_tunnel_list', 'ssh_tunnel_close', 'ssh_key_manage', 'ssh_execute_group', 'ssh_group_manage', 'ssh_history' ]

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/bvisible/mcp-ssh-manager'

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