Skip to main content
Glama
redis

Redis MCP Server

Official
by redis

get_vector_from_hash

Retrieve vector embeddings stored as binary blobs in Redis hashes and convert them to usable float arrays for AI applications.

Instructions

Retrieve a vector from a Redis hash and convert it back from binary blob.

Args: name: The Redis hash key. vector_field: The field name inside the hash. Unless specifically required, use the default field name

Returns: The vector as a list of floats, or an error message if retrieval fails.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
vector_fieldNovector

Implementation Reference

  • The handler function decorated with @mcp.tool(), which registers and implements the get_vector_from_hash MCP tool. It retrieves a binary vector blob from a Redis hash field and converts it back to a list of floats.
    @mcp.tool()
    async def get_vector_from_hash(name: str, vector_field: str = "vector"):
        """Retrieve a vector from a Redis hash and convert it back from binary blob.
    
        Args:
            name: The Redis hash key.
            vector_field: The field name inside the hash. Unless specifically required, use the default field name
    
        Returns:
            The vector as a list of floats, or an error message if retrieval fails.
        """
        try:
            r = RedisConnectionManager.get_connection(decode_responses=False)
    
            # Retrieve the binary blob stored in the hash
            binary_blob = r.hget(name, vector_field)
    
            if binary_blob:
                # Convert the binary blob back to a NumPy array (assuming it's stored as float32)
                vector_array = np.frombuffer(binary_blob, dtype=np.float32)
                return vector_array.tolist()
            else:
                return f"Field '{vector_field}' not found in hash '{name}'."
    
        except RedisError as e:
            return f"Error retrieving vector field '{vector_field}' from hash '{name}': {str(e)}"
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses the tool retrieves and converts data (implying a read-only operation) and mentions error handling on failure. However, it omits behavioral details like performance characteristics, rate limits, authentication needs, or what constitutes 'fails' (e.g., missing key/field). It adds value but is incomplete for a mutation-sensitive context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded with the core purpose, followed by clear Arg/Returns sections. Every sentence earns its place by defining actions, parameters, and outcomes without redundancy. It's appropriately sized for a tool with two parameters.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, and no output schema, the description does a good job covering the tool's purpose, parameters, and return type (list of floats or error). It adequately explains the conversion from binary blob, which is critical context. However, it lacks details on error conditions or edge cases, leaving some gaps for a data retrieval tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It explains both parameters: 'name' as the Redis hash key and 'vector_field' as the field inside the hash, with a default value hint. This adds meaningful semantics beyond the schema's basic types, though it could detail format constraints (e.g., key naming rules).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('retrieve a vector from a Redis hash and convert it back from binary blob'), identifies the resource (Redis hash), and distinguishes it from siblings like 'get' (general key retrieval) or 'hget' (hash field retrieval without vector conversion). It precisely defines the tool's unique function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying it retrieves vectors from Redis hashes, suggesting it's for vector storage scenarios. However, it lacks explicit guidance on when to use this tool versus alternatives like 'get' or 'hget', or when not to use it (e.g., for non-vector data). The default field hint provides some practical direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/redis/mcp-redis'

If you have feedback or need assistance with the MCP directory API, please join our Discord server