Tencent/WeKnora · error

connection closed

Error message

connection closed

What it means

Sentinel error signaling that the MCP client's underlying connection was closed (by the server, network drop, or an explicit Close) while an operation was in flight or before it started. It fires whenever an operation is attempted against a client whose transport is no longer alive; callers use it to decide between reconnecting and failing fast.

Source

Thrown at internal/mcp/errors.go:31

	ErrAlreadyConnected = errors.New("client already connected")

	// ErrInitializeFailed is returned when MCP initialize handshake fails
	ErrInitializeFailed = errors.New("MCP initialize handshake failed")

	// ErrToolNotFound is returned when requested tool is not found
	ErrToolNotFound = errors.New("tool not found")

	// ErrResourceNotFound is returned when requested resource is not found
	ErrResourceNotFound = errors.New("resource not found")

	// ErrInvalidResponse is returned when server response is invalid
	ErrInvalidResponse = errors.New("invalid response from server")

	// ErrTimeout is returned when operation times out
	ErrTimeout = errors.New("operation timed out")

	// ErrConnectionClosed is returned when connection is closed unexpectedly
	ErrConnectionClosed = errors.New("connection closed")
)

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Reconnect the client (Connect + Initialize) before retrying the operation
  2. Detect connection loss via disconnect callbacks and trigger automatic reconnection
  3. Check server logs / network for why the connection dropped
  4. Surface a clear user-facing message that the MCP server session ended
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at internal/mcp/errors.go:31 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/0bad365515b74745. Report an issue: GitHub.