Tencent/WeKnora · error

client not connected

Error message

client not connected

What it means

Generic guard sentinel returned by mcpGoClient methods (Initialize when c.connected is false, ListTools and similar calls when c.initialized is false) whenever an operation is issued before the connection/initialize handshake completed. It signals call-order misuse, not a transport failure.

Source

Thrown at internal/mcp/errors.go:10

package mcp

import "errors"

var (
	// ErrUnsupportedTransport is returned when transport type is not supported
	ErrUnsupportedTransport = errors.New("unsupported transport type")

	// ErrNotConnected is returned when operation requires connection but client is not connected
	ErrNotConnected = errors.New("client not connected")

	// ErrAlreadyConnected is returned when trying to connect an already connected client
	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")

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Call Connect and then Initialize before any other client operation
  2. Track initialization state in the caller and defer dependent calls until Initialize returns success
  3. If races are possible, serialize access or check connected/initialized state under the client's lock
  4. Reconnect and re-initialize if the connection was dropped previously
Defensive patterns

Strategy: try-catch

When it happens

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

Common situations: See trigger scenarios.


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