Skip to content

HTTP Transport drops session and causes "Zammad client not initialized" #202

@Erudition

Description

@Erudition

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions