Skip to content

Bug: PGVectorRetriever crashes on initialization due to deprecated SentenceTransformer API ("list" object has no attribute "items") #2

@Merdan0595

Description

@Merdan0595

Hi team!
I discovered a reproducible bug in PGVectorRetriever that prevents using
the pgvector backend in vector-mcp.

Error

When calling create_collection (or any tool using pgvector),
the server crashes with:
AttributeError: 'list' object has no attribute 'items'

Stack trace ends in:
sentence_transformers/models/Transformer.forward
trans_features = {key: value for key, value in features.items()}
AttributeError: 'list' object has no attribute 'items'

Root cause

In vector_mcp/retriever/pgvector_retriever.py, inside __init__:

self.embed_dim = len(
    self.embedding_function(["The quick brown fox jumps over the lazy dog."])[0]
)

Here self.embedding_function is a SentenceTransformer instance.
The forward pass expects a dict of features, not a list.

Because of this, initialization of PGVectorRetriever fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions