# Redis Vector MCP

> Redis Vector lets your AI agent manage embeddings and run KNN similarity searches natively inside Redis. It turns your database into a full-featured vector store, letting you query complex, high-dimensional data structures—like semantic relationships or image feature vectors—without needing external clients or dedicated ML services. You can autonomously create indexes (`create_vector_index`), upsert data (`upsert_vector`), and run rapid similarity searches in one go.

## Overview
- **Category:** loved-by-devs
- **Price:** Free
- **Tags:** vector-search, embeddings, semantic-search, knn-search, indexing, machine-learning-data

## Description

Your agent takes over vector management right inside Redis. It treats your database like a full-featured vector store, letting you query complex data—like semantic relationships or image feature vectors—without needing to spin up external services or write extra client code.

When you connect your AI client via MCP, the server gives it native access to all vector operations. You won't need separate database connections or specialized ML libraries; everything stays contained within Redis.

### Managing Your Vector Data Structure

Before running any searches, you gotta set up the index. To see what indexes are already configured in your database, run `list_indexes`. If you want to know the specific details of an existing index—like its exact dimensions or the underlying search algorithm type—you use `get_index_info` and point it at the name you care about. When you're ready for a new data set, you initialize the structure by calling `create_vector_index`, specifying both the unique name and the required dimensionality for that index.

### Writing and Updating Embeddings

Your agent handles the data lifecycle too. You don't have to rebuild entire records just because an embedding changes. To inject new vectors into a document key or overwrite old embeddings without changing the overall record structure, you use `upsert_vector`. This tool requires the target key and the new embedding array as JSON.

If a vector component is obsolete or needs to be removed entirely, you can clean up with `delete_vector`. You pass it a specific key, and it wipes out that entire associated vector document from Redis.

### Running Similarity Searches (KNN)

The main job is searching. To run a rapid KNN similarity query, your agent calls `search_vectors`. You just provide an embedding array—that's the JSON array of floats representing your query vector—and it queries that against any active index you’ve established. The result is always the absolute nearest top-K neighbors found in your cluster, giving you semantic relationships instantly.

This setup keeps your entire semantic layer self-contained and fast within Redis. You'll run searches, update data, and manage schemas all through simple function calls to your agent.

## Tools

### create_vector_index
Creates a new RediSearch vector index by specifying its name and required dimensions.

### delete_vector
Removes an entire vector document associated with a specific key from Redis.

### get_index_info
Retrieves detailed metadata, such as dimensions and algorithm type, for one specified vector index.

### list_indexes
Returns a list of all available RediSearch vector indexes currently configured in the database.

### search_vectors
Performs a KNN similarity search by accepting a JSON array of floats and querying it against an active index.

### upsert_vector
Inserts or updates a vector component into a document key, requiring the target key and the embedding as a JSON array.

## Prompt Examples

**Prompt:** 
```
Search the index 'customer-support-vector' for the top 3 similar records to this embedding vector: [0.12, -0.45, 0.08, 0.99...]
```

**Response:** 
```
I processed the array using `search_vectors` on 'customer-support-vector'. Here are the 3 nearest key entries based on distance proximity:
1. doc:faq:882 (score: 0.89)
2. doc:faq:104 (score: 0.81)
3. doc:faq:002 (score: 0.77)
```

**Prompt:** 
```
Insert a new embedding into the database with the key 'user:439:preference' containing the vector `[0.2, -0.1...]`.
```

**Response:** 
```
Running `upsert_vector`... I have successfully saved the document 'user:439:preference' containing the provided embedding data matrix into Redis. It is now queryable.
```

**Prompt:** 
```
Retrieve the index information logic and schema mapping for 'docs-semantic-index'.
```

**Response:** 
```
I extracted the metadata using `get_index_info`. 'docs-semantic-index' holds 5,000 documents parameterized with the HNSW algorithm, set to 1536 float dimensions, utilizing the COSINE metric protocol.
```

## Capabilities

### Execute Nearest Neighbor Searches
The agent performs rapid KNN searches by providing a query vector and retrieving the nearest matching records from any defined index.

### Manage Index Schemas
It allows you to list all current indexes, check an index's dimensions, or create a new vector index structure on demand.

### Write and Update Embeddings
The agent inserts new vectors into specific document keys or overwrites existing embedding data for a key without changing the overall record structure.

### Clean Up Data Vectors
You can delete isolated vector documents from Redis, keeping your semantic records clean and preventing bloat.

## Use Cases

### Finding related product FAQs
A support agent needs to find the best article match for vague user input. They prompt their AI client: 'Find 3 top matches in the customer-support-vector index.' The agent executes `search_vectors`, returning relevant document keys and proximity scores, solving the search instantly.

### Updating a user's preference vector
A new ML model generates updated usage vectors for a user. Instead of running an update script, the developer prompts: 'Update the embedding for key user:439:preference with this new array.' The agent runs `upsert_vector`, making the data immediately queryable.

### Auditing index readiness
A Data Architect is setting up a new RAG system. First, they run `list_indexes` to see what exists. Then, they use `get_index_info` on the target index to confirm it’s configured for 1536 float dimensions before proceeding.

### Cleaning out old data
The team retires an old product line and needs to remove all associated vectors. They prompt: 'Delete vector doc:product:old_sku.' The agent executes `delete_vector`, keeping the remaining semantic record set clean.

## Benefits

- Run rapid, native vector comparisons using `search_vectors`. You just provide the query embedding array and get back the top-K nearest matches—no complex client setup needed.
- Control your entire schema lifecycle. Use `list_indexes` to audit what's running, then use `get_index_info` to confirm dimensions before writing any data.
- Handle embeddings as part of your workflow. `upsert_vector` lets you attach or update a vector component to an existing document key in Redis with a simple prompt.
- Build clean pipelines by controlling the data lifecycle. Use `delete_vector` when records become obsolete, keeping your semantic store performant and accurate.
- Set up new search capabilities on the fly. When you need a totally fresh index for a new dataset, just call `create_vector_index`. It's fast.

## How It Works

The bottom line is: you talk naturally to your AI, and it handles all the complex database calls needed for vector math automatically.

1. Authorize the Redis Vector MCP connector. You must point it to a Redis instance running RediSearch.
2. Prompt your agent with an action, like: 'Find the top 5 nearest neighbors for this JSON embedding array in the 'products-index''.
3. The agent uses `search_vectors` (or another tool) to query the index directly and returns the list of matching keys and proximity scores.

## Frequently Asked Questions

**What is the format required for the 'Redis URL' parameter?**
The parameter requires standard Redis URI string formatting. Typically it looks like `redis://[username]:[password]@[host]:[port]`. For TLS/SSL-enabled endpoints spanning secure setups, use the `rediss://` scheme prefix.

**Does my Redis instance strictly need the RediSearch module?**
Yes, absolutely. The base Redis product (standard open-source) only manages key-value caching out of the box. You must be running the Redis Stack or a managed tier (like Redis Enterprise or compatible cloud offerings) that explicitly includes RediSearch to generate and query KNN vector indexes.

**Can I query using embedding arrays output directly from OpenAI models?**
Yes. Once you receive your numerical float array from an embedding model (like text-embedding-ada-002), you can pipe that exact JSON array into the `search_vectors` agent tool alongside the relevant index name to perform immediate proximity lookups.

**When I use `search_vectors`, what security protocols must be in place to authorize access?**
Authorization relies on standard Redis ACLs. You must configure the connection string with appropriate user credentials and required read permissions for the target index. The MCP connector respects these underlying server-side rules, preventing unauthorized data reads or writes.

**If my embedding model changes its output dimension, how do I update the schema using `create_vector_index`?**
You must drop the existing index and recreate it. Use `delete_vector` to clean up old data first, then run `create_vector_index` specifying the new, correct vector dimensions (e.g., 3072 instead of 1536). This ensures semantic consistency.

**If I send bad data to `upsert_vector`, will it crash my connection or just fail that single record?**
The tool handles invalid input gracefully by failing only the specific operation. If the provided key format is wrong, or the vector array structure is malformed, the connector returns an error code but keeps your overall MCP session stable.

**Can I change the similarity metric (like switching from COSINE to EUCLIDEAN) for my index after creation?**
No, you cannot change the core metric of a vector index. The metric is set during index creation using `create_vector_index`. If you need a different distance measure, you must delete and recreate the entire index structure.

**What happens to my data if I run too many queries with `search_vectors` in rapid succession?**
The performance is governed by Redis server load and your network bandwidth. While Vinkius manages connection stability, high-volume querying might trigger rate limits or increased latency on the Redis side. Batching requests helps maintain speed.