disconnect
Terminate the active TN5250 session to disconnect from the IBM i system.
Instructions
Disconnect the active TN5250 session.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/ibmi_mcp/server.py:68-77 (handler)The MCP tool handler for 'disconnect' — a decorated @mcp.tool() function that disconnects the active TN5250 session. It checks if _session exists, calls await _session.disconnect(), sets _session = None, and returns a status dict.
async def disconnect() -> dict: """Disconnect the active TN5250 session.""" global _session if _session is None: return {"status": "already disconnected"} await _session.disconnect() _session = None return {"status": "disconnected"} - src/ibmi_mcp/server.py:67-67 (registration)The tool is registered via the @mcp.tool() decorator on the disconnect() function in server.py. The FastMCP instance 'mcp' automatically registers it.
@mcp.tool() - Tn5250Session.disconnect() — the session-level helper method that closes the TelnetStream, sets the state to DISCONNECTED, and clears the screen buffer.
async def disconnect(self) -> None: await self._stream.close() self._state = SessionState.DISCONNECTED self._screen.clear() - src/ibmi_mcp/tn5250/session.py:46-50 (schema)The SessionState enum defining the 'disconnected' state constant used by the disconnect logic.
class SessionState(Enum): DISCONNECTED = "disconnected" NEGOTIATING = "negotiating" CONNECTED = "connected" WAITING = "waiting"