ssh_close_session
Terminates SSH connections to remote servers by closing active sessions, helping manage resources and maintain security.
Instructions
Closes an SSH session
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID to close |
Implementation Reference
- src/session.ts:177-198 (handler)Implementation of the `closeSession` method that removes the session from the manager and closes the SSH and SFTP connections.
* Closes an SSH session */ async closeSession(sessionId: string): Promise<boolean> { logger.debug('Closing SSH session', { sessionId }); const session = this.sessions.get(sessionId); if (!session) { logger.warn('Session not found for closing', { sessionId }); return false; } try { await session.sftp.end(); session.ssh.dispose(); } catch (error) { logger.warn('Error closing session', { sessionId, error }); } this.sessions.delete(sessionId); logger.info('SSH session closed', { sessionId }); return true; } - src/mcp.ts:395-400 (registration)Tool handler registration and execution logic for `ssh_close_session` in `src/mcp.ts`.
case 'ssh_close_session': { const { sessionId } = SessionIdSchema.parse(args); const result = await sessionManager.closeSession(sessionId); logger.info('SSH session closed', { sessionId }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }