Skip to main content
Glama

ssh_close_interactive_shell

Close an active SSH interactive shell session to free up server resources and terminate remote command execution.

Instructions

Close an interactive shell session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesInteractive session ID to close

Implementation Reference

  • The handler function that implements the core logic for closing an interactive SSH shell session. It validates input, retrieves the session from the pool, closes the shell channel, cleans up the session state, and returns a success response.
    private async handleCloseInteractiveShell(args: unknown) {
      const params = CloseInteractiveShellSchema.parse(args);
      
      const session = shellSessions.get(params.sessionId);
      if (!session) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Session ID '${params.sessionId}' not found`
        );
      }
    
      try {
        session.shell.close();
        session.isActive = false;
        shellSessions.delete(params.sessionId);
    
        return {
          content: [
            {
              type: 'text',
              text: `Interactive shell session '${params.sessionId}' closed successfully`,
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to close session: ${error instanceof Error ? error.message : String(error)}`
        );
      }
  • Zod schema defining the input parameters for the ssh_close_interactive_shell tool, specifically requiring a sessionId string.
    const CloseInteractiveShellSchema = z.object({
      sessionId: z.string().describe('Interactive session ID to close')
    });
  • src/index.ts:361-370 (registration)
    Tool registration in the ListTools response, defining the name, description, and input schema for ssh_close_interactive_shell.
      name: 'ssh_close_interactive_shell',
      description: 'Close an interactive shell session',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: { type: 'string', description: 'Interactive session ID to close' }
        },
        required: ['sessionId']
      },
    },
  • src/index.ts:503-504 (registration)
    Switch case in the CallToolRequestHandler that routes calls to the ssh_close_interactive_shell handler function.
    case 'ssh_close_interactive_shell':
      return await this.handleCloseInteractiveShell(args);
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 action ('Close') but doesn't explain what happens upon closure (e.g., whether the session is terminated gracefully, if resources are freed, or if there are side effects like killing processes). For a tool that likely involves mutation, this lack of detail is a significant gap.

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, direct sentence that front-loads the essential action without any fluff. It efficiently communicates the core purpose, making it easy for an agent to parse and understand quickly.

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 closing an interactive shell (likely a mutation with potential side effects), no annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects, usage context, or what to expect after invocation, leaving the agent under-informed for safe and effective use.

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?

The input schema has 100% description coverage, with the single parameter 'sessionId' clearly documented. The description doesn't add any meaning beyond what the schema provides (e.g., it doesn't clarify where to get the sessionId or its format). Given the high schema coverage, a baseline score of 3 is appropriate.

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 the resource ('an interactive shell session'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this tool from sibling tools like 'ssh_disconnect' or 'ssh_execute', which might also involve session termination or cleanup, so it doesn't reach the highest 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 an active session from 'ssh_start_interactive_shell'), exclusions, or how it differs from other session-related tools like 'ssh_disconnect'. This leaves the agent with minimal context for selection.

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

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