ssh_close_interactive_shell
Terminate an active SSH interactive shell session by specifying the session ID. Ensures proper resource management and connection cleanup on the SSH MCP Server.
Instructions
Close an interactive shell session
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Interactive session ID to close |
Input Schema (JSON Schema)
{
"properties": {
"sessionId": {
"description": "Interactive session ID to close",
"type": "string"
}
},
"required": [
"sessionId"
],
"type": "object"
}
Implementation Reference
- src/index.ts:1055-1084 (handler)Executes the logic to close an interactive SSH shell session: validates params, retrieves session, closes the shell channel, marks inactive, removes from session pool, returns success message or throws error.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)}` ); }
- src/index.ts:119-121 (schema)Zod schema defining the input parameters for the tool: requires sessionId string.const CloseInteractiveShellSchema = z.object({ sessionId: z.string().describe('Interactive session ID to close') });
- src/index.ts:361-370 (registration)Registers the tool in the ListTools handler response with name, description, and input schema definition.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 CallToolRequestHandler that routes the tool call to the specific handler method.case 'ssh_close_interactive_shell': return await this.handleCloseInteractiveShell(args);