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);

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