googleapis/mcp-toolbox · error

failed to list relationship types: %w

Error message

failed to list relationship types: %w

What it means

This error wraps any failure from the Cypher read query 'CALL db.relationshipTypes()' while the falkordbschema tool builds its relationship inventory via extractRelationships. It is thrown when the FalkorDB/graph server cannot execute the procedure call (connection failure, auth failure, or query error). The wrapped cause (%w) carries the underlying driver error.

Source

Thrown at internal/tools/falkordb/falkordbschema/falkordbschema.go:329

		}

		nodeLabels = append(nodeLabels, types.NodeLabel{
			Name:       label,
			Count:      helpers.FirstRowInt64(countResult),
			Properties: helpers.CollectProperties(accumulator),
		})
	}
	helpers.SortNodeLabels(nodeLabels)
	return nodeLabels, nil
}

// extractRelationships lists the relationship types and derives each type's
// count, most common connectivity pattern, and property shapes from a sample
// of relationships.
func (t Tool) extractRelationships(ctx context.Context, source compatibleSource) ([]types.Relationship, error) {
	typesResult, err := runReadQuery(ctx, source, "CALL db.relationshipTypes()")
	if err != nil {
		return nil, fmt.Errorf("failed to list relationship types: %w", err)
	}

	var relationships []types.Relationship
	for _, relType := range helpers.FirstColumnStrings(typesResult) {
		escaped := escapeIdentifier(relType)

		countResult, err := runReadQuery(ctx, source, fmt.Sprintf("MATCH ()-[r:`%s`]->() RETURN count(r) AS count", escaped))
		if err != nil {
			return nil, fmt.Errorf("failed to count relationship type %q: %w", relType, err)
		}

		sampleResult, err := runReadQuery(ctx, source, fmt.Sprintf(
			"MATCH (a)-[r:`%s`]->(b) RETURN labels(a) AS startLabels, labels(b) AS endLabels, r LIMIT %d", escaped, t.Cfg.SampleSize))
		if err != nil {
			return nil, fmt.Errorf("failed to sample relationship type %q: %w", relType, err)
		}

		accumulator := make(map[string]map[string]bool)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Verify the FalkorDB source is reachable: check host, port, and credentials in the source config and test with a simple query.
  2. Ensure the FalkorDB/RedisGraph module version supports the db.relationshipTypes procedure; upgrade the server if not.
  3. Inspect the wrapped cause in the error message (%w) to identify the driver-level failure (network vs auth vs query).
  4. Retry after restoring the server; if transient network issues, re-run the schema tool.

Example fix

// before: schema tool fails at startup
source: my-graph
// after: corrected source config
source:
  kind: falkordb
  address: localhost:6379
  # ensure server is running: docker run -p 6379:6379 falkordb/falkordb
Defensive patterns

Strategy: validation

Validate before calling

// Before invoking the schema tool, verify the graph is reachable and supports the procedure
conn, err := client.Dial(ctx) // or run a smoke query
if err != nil { return fmt.Errorf("FalkorDB unavailable: %w", err) }
res, err := conn.Query("RETURN 1")
if err != nil { return fmt.Errorf("smoke query failed: %w", err) }

Type guard

func isGraphProcUnavailable(err error) bool {
    return err != nil && strings.Contains(strings.ToLower(err.Error()), "unknown procedure")
}

Try / catch

rels, err := tool.ExtractRelationships(ctx, src)
if err != nil {
    var qErr *driverErr
    if errors.As(err, &qErr) && isGraphProcUnavailable(qErr) {
        // upgrade FalkorDB module or use fallback schema discovery
    }
    return err
}

Prevention

When it happens

Trigger: extractRelationships calls runReadQuery with 'CALL db.relationshipTypes()' and the query returns an error: server unreachable, connection refused, bad credentials, database unavailable, or the procedure is unsupported by the graph backend.

Common situations: FalkorDB container not running or wrong host/port in the source config; Redis/FalkorDB module not loaded; auth credentials wrong; invoking the falkordb-schema tool against a database that lacks the db.relationshipTypes procedure (older module version).

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/36534039cdba4bfe. Report an issue: GitHub.