Skip to main content
Glama
widjis
by widjis

ssh_close_interactive_shell

Close an interactive SSH shell session to terminate remote terminal connections and free server resources. Specify the session ID to end the connection.

Instructions

Close an interactive shell session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesInteractive session ID to close

Implementation Reference

  • The main handler function that validates input using CloseInteractiveShellSchema, retrieves the shell session, closes the shell channel, marks it inactive, removes it from the shellSessions map, and returns a success message or throws an error if the session is not found or closing fails.
    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 tool, requiring a sessionId string.
    const CloseInteractiveShellSchema = z.object({
      sessionId: z.string().describe('Interactive session ID to close')
    });
  • src/index.ts:360-370 (registration)
    Tool registration in the ListTools response, defining name, description, and inputSchema matching the handler.
    {
      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)
    Dispatch case in the CallToolRequest handler that routes to the specific 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 output is lost, or if it requires specific permissions). This is a significant gap for a tool that likely involves session management.

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 that directly states the tool's purpose without unnecessary words. It's front-loaded and wastes no space, making it easy to parse 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 session management and the lack of annotations or output schema, the description is incomplete. It doesn't cover behavioral aspects like side effects, error conditions, or what happens post-closure, which are crucial for an AI agent to use this tool correctly in context.

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%, with the single parameter 'sessionId' well-documented in the schema. The description doesn't add any meaning beyond this (e.g., how to obtain the sessionId or format requirements), so it meets the baseline of 3 where 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 clearly states the verb ('close') and resource ('interactive shell session'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'ssh_disconnect' (which might close connections rather than specific shell sessions), leaving some ambiguity about when to use each.

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 like 'ssh_disconnect' or 'ssh_execute' for ending sessions. It mentions the resource but doesn't specify prerequisites (e.g., must have an active shell session) or exclusions, leaving usage context unclear.

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

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