Skip to main content
Glama
bvisible

MCP SSH Manager

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'
    ]
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 only states the action without behavioral details. It doesn't disclose whether closing is reversible, what happens to active connections, permission requirements, error conditions, or confirmation of closure. For a destructive operation with zero annotation coverage, this is inadequate.

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 front-loaded with the core action and resource, making it immediately scannable and appropriately sized for a simple operation.

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 tool that performs a destructive operation (closing resources) with no annotations and no output schema, the description is insufficient. It doesn't explain what 'close' entails behaviorally, what happens after closure, or what the tool returns. Given the complexity and lack of structured coverage, 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%, so parameters are documented in the schema. The description adds no additional meaning about tunnelId or server parameters beyond what's in the schema. Baseline 3 is appropriate when the schema does all the parameter documentation work.

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 ('Close') and resource ('an SSH tunnel'), making the purpose immediately understandable. It doesn't distinguish from sibling tools like ssh_tunnel_list or ssh_session_close, but the verb+resource combination is specific enough for basic understanding.

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 is provided about when to use this tool versus alternatives like ssh_session_close or ssh_tunnel_list. The description doesn't mention prerequisites (e.g., needing an existing tunnel) or context for choosing between tunnelId and server parameters.

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

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