When using the HTTP transport instead of stdio, one of my MCP clients (goclaw) establishes a connection to fetch the tool list, then immediately drops the connection pending further calls. This triggers FastMCP's lifespan teardown, which sets self.client = None.
When the client subsequently sends a CallToolRequest, get_client() crashes because it is written as a strict getter with no fallback, resulting in a Zammad client not initialized error.
Processing request of type ListToolsRequest
INFO: "DELETE /mcp/ HTTP/1.1" 307 Temporary Redirect
Terminating session: <id>
Zammad client cleaned up
...
Processing request of type CallToolRequest
Error: Zammad client not initialized
Proposed Fix: Implement lazy initialization in mcp_zammad/server.py around line 431. If the client has been torn down by a stateless HTTP disconnect, it should rebuild itself on the fly using the existing environment variables.
Change get_client to:
def get_client(self) -> ZammadClient:
"""Get the Zammad client, ensuring it's initialized."""
if not self.client:
# Lazy initialization to survive stateless HTTP transport / session reconnects
self.client = ZammadClient()
return self.client
When using the HTTP transport instead of stdio, one of my MCP clients (goclaw) establishes a connection to fetch the tool list, then immediately drops the connection pending further calls. This triggers FastMCP's lifespan teardown, which sets self.client = None.
When the client subsequently sends a CallToolRequest, get_client() crashes because it is written as a strict getter with no fallback, resulting in a
Zammad client not initializederror.Proposed Fix: Implement lazy initialization in mcp_zammad/server.py around line 431. If the client has been torn down by a stateless HTTP disconnect, it should rebuild itself on the fly using the existing environment variables.
Change get_client to: