googleapis/mcp-toolbox · error
unable to create session: %v
Error message
unable to create session: %v
What it means
This error wraps any failure that occurs while creating the Cassandra session during source initialization in the MCP Toolbox. Config.Initialize calls initCassandraSession, and if the cluster cannot be contacted or configured incorrectly, the underlying gocql error is wrapped with this message.
Source
Thrown at internal/sources/cassandra/cassandra.go:62
type Config struct {
Name string `yaml:"name" validate:"required"`
Type string `yaml:"type" validate:"required"`
Hosts []string `yaml:"hosts" validate:"required"`
Keyspace string `yaml:"keyspace"`
ProtoVersion int `yaml:"protoVersion"`
Username string `yaml:"username"`
Password string `yaml:"password"`
CAPath string `yaml:"caPath"`
CertPath string `yaml:"certPath"`
KeyPath string `yaml:"keyPath"`
EnableHostVerification bool `yaml:"enableHostVerification"`
}
// Initialize implements sources.SourceConfig.
func (c Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {
session, err := initCassandraSession(ctx, tracer, c)
if err != nil {
return nil, fmt.Errorf("unable to create session: %v", err)
}
s := &Source{
Config: c,
Session: session,
}
return s, nil
}
// SourceConfigType implements sources.SourceConfig.
func (c Config) SourceConfigType() string {
return SourceType
}
var _ sources.SourceConfig = Config{}
type Source struct {
Config
Session *gocql.SessionView on GitHub (pinned to 8cc6e09de2)
Solutions
- Check that the Cassandra cluster is reachable from the toolbox host (hosts list, port 9042, firewall).
- Verify username/password are both set together and correct.
- Confirm ProtoVersion matches your Cassandra/ScyllaDB server version.
- Verify the keyspace exists; omit it if you don't need one.
- Inspect the wrapped inner error (%v) for the root cause.
Example fix
// before
c := cassandra.Config{Hosts: []string{"wrong-host"}}
// after
c := cassandra.Config{Hosts: []string{"127.0.0.1"}, Username: "cassandra", Password: "cassandra", Keyspace: "myks"} Defensive patterns
Strategy: validation
Validate before calling
if len(cfg.Hosts) == 0 { return errors.New("cassandra hosts required") }
if cfg.Password != "" && cfg.Username == "" { return errors.New("password requires username") } Try / catch
src, err := cfg.Initialize(ctx, tracer)
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) { /* handle connectivity */ }
return fmt.Errorf("cassandra init failed: %w", err)
} Prevention
- Pre-validate hosts, username/password pairing before Initialize.
- Smoke-test connectivity to the CQL port from the deployment environment.
- Pin ProtoVersion to a value your server supports.
When it happens
Trigger: Calling Initialize on a cassandra.Config when initCassandraSession fails: invalid auth config, unreachable hosts, bad protocol version, or keyspace issues.
Common situations: Cassandra cluster down or wrong host/port, wrong ProtoVersion for the server, keyspace that does not exist, network/firewall blocking the CQL port 9042.
Related errors
- failed to create Cassandra session: %w
- unable to create db connection: %w
- unable to initialize source %q: %w
- error initializing Valkey client: %s
- failed to initialize resources: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/51efb76cc9065ab8.
Report an issue: GitHub.