-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Description
The MCP Telegram server crashes during shutdown with connection-related
errors when the initial Telegram connection fails or is interrupted. This
occurs because the app_lifespan context manager always attempts to
disconnect the client, even when the connection was never successfully
established.
Steps to Reproduce
- Start the MCP server with invalid API credentials or during network
issues - Initial connection to Telegram fails
- Attempt to shut down the server (Ctrl+C or normal shutdown)
- Server crashes with connection-related errors during cleanup
Expected Behavior
The server should shut down gracefully regardless of connection state,
only attempting to disconnect when a connection was successfully
established.
Actual Behavior
Server crashes during shutdown because tg.client.disconnect() is called
unconditionally in the finally block, even when:
- The initial tg.client.connect() call failed
- The client was never successfully connected
- The client is already disconnected or in an invalid state
Environment
- MCP Telegram version: 0.1.11
- Python version: 3.10+
- Platform: Any
Metadata
Metadata
Assignees
Labels
No labels